Astuce TextMate
octobre 24, 2010
Pour ceux qui utilise TextMate pour développer, il y a une option qui me manquait cruellement. Celle de pouvoir aller directement à la définition d’une méthode ou d’une classe.
Et bien il suffit d’utiliser ce bout de code dans un bundle :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | FUNC="$TM_CURRENT_WORD" DIR="$TM_PROJECT_DIRECTORY" OUTPUT='' FILES=(`find "$DIR" -type f | egrep '\.(module|inc|php|engine|install)$'`) # # Look for a function declaration within a files contents. # # <file> <function> # function lookup_function { local line=`nl -b a "$1" | grep 'function '"$2"'(' | awk '{print $1}'` if [[ "$line" -gt 0 ]]; then mate "$1" -l "$line" exit 0 fi } # Iterate files for (( i=0; i < ${#FILES[*]}; i++)); do file="${FILES[${i}]}" lookup_function "$file" "$FUNC" done # Nothing found echo 'Function '${FUNC}' was not found within the current project.' |
Catégorie(s): Développement, Mac, Php, Web | Comments (0)