Hi all,
I try to make a bundle command in order to find a php-function definition within project folder.
What I want to do is a "macro/snippet/command" that do the following:
- with the TM_CURRENT_WORD or TM_CURRENT_SELECTION - search the current project (like CMD-SHIFT-F) with a regex search (something like: (function)(.*)($TM_CURRENT_WORD)(/s+() ) - open the CMD-SHIFT-F window with the search-results so you can select the found result.
So is there a way to 'call' the search window, with the values filled in and run the search?
It would be even better if one result is present, directly via a simple popup: - if found one result goto file / and function - if multiple functions / files are found => selection box in order to select the file
Or does are there other suggestions?
Regards, Feek
-- View this message in context: http://textmate.1073791.n5.nabble.com/Call-Find-in-Project-window-in-a-bundl... Sent from the textmate users mailing list archive at Nabble.com.
Hi,
I've found a solution by using the code below.
Regards, Feek
START CODE ======
#!/bin/bash [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
function_name="$TM_CURRENT_WORD" project_dir="$TM_PROJECT_DIRECTORY" output=''
# find php-related files in project directory, result is a string files_string=`find "$project_dir" -type f | egrep '.(module|inc|php|engine|install)$'`
# place multi-line sting in a array, works for file names with spaces! files_array=() while read -r line; do files_array+=("$line") done <<< "$files_string"
# # Lookup for a function declaration inside the file content. # multi space allowed in function declaration # <file> <function> # function lookup_function { local line=`nl -b a "$1" | grep 'function\s+'"$2"'\s*(' | awk '{print $1}'` if [[ "$line" -gt 0 ]]; then mate "$1" -l "$line" exit 0 fi }
# Iterate the array with files, works for files with spaces! for (( i=0; i < ${#files_array[*]}; i++)); do file="${files_array[${i}]}" lookup_function "$file" "$function_name" done
# Nothing found echo 'NOTE: Function '${function_name}' was not found within the current project directory.'
END CODE ======
-- View this message in context: http://textmate.1073791.n5.nabble.com/Call-Find-in-Project-window-in-a-bundl... Sent from the textmate users mailing list archive at Nabble.com.
On 9 May 2016, at 21:34, feek wrote:
I've found a solution by using the code below.
Instead of using `mate` I recommend using `"$TM_MATE"`. This variable will be set for all commands called from within TextMate, so does not rely on the user having `mate` installed in a location in the user’s PATH.