[SVN] New Quick Open… (suggestion)

Allan Odgaard throw-away-1 at macromates.com
Fri Oct 14 18:10:12 UTC 2005


Currently the Quick Open… requires a selection (or input from a  
dialog) and it cannot handle partial paths, only single files, e.g.  
“sys/wait.h” won't work (which could otherwise limit the number of  
results).

I seem to recall Ruby's Find module being preferred because it was  
faster than the find shell command, but the shell command does make  
it easy to handle the partial paths.

So I propose the following replacement:

    dirs=("/usr/include"
       "/System/Library/Frameworks/AppKit.framework/Headers"
       "/System/Library/Frameworks/Foundation.framework/Headers"
       "/System/Library/Frameworks/IOKit.framework/Headers"
       "/System/Library/Frameworks/CoreAudio.framework/Headers"
       "/System/Library/Frameworks/Quartz.framework/Versions/A/ 
Frameworks/PDFKit.framework/Headers"
       "/System/Library/Frameworks/QuickTime.framework/Headers"
       "/System/Library/Frameworks/QTKit.framework/Headers"
       "/System/Library/Frameworks/Carbon.framework"
       "/System/Library/Frameworks/Kernel.framework"
       "/System/Library/Frameworks/ApplicationServices.framework"
    )

    if [[ -z "$TM_SELECTED_TEXT" && "$TM_CURRENT_LINE" = *\<*\> ]]; then
       TM_SELECTED_TEXT="$(perl <<<"$TM_CURRENT_LINE" -pe 's/[^<]*< 
([^>]*)>.*/$1/')"
    elif [[ -z "$TM_SELECTED_TEXT" ]]; then
       res=$(CocoaDialog inputbox --title "Open Header Quickly" --no- 
newline --informative-text "Header name?"  --text "foobar"  --button1  
"Open" --button2 "Cancel")
       [[ $(head -n1 <<<"$res") == "2" ]] && exit
       TM_SELECTED_TEXT=$(tail -n1 <<<"$res")
    fi

    for dir in "${dirs[@]}"; do
       find "$dir" -path "*/$TM_SELECTED_TEXT" -exec open -a TextMate  
'{}' \;
    done &>/dev/null &

The last part could perhaps be changed to:

    for dir in "${arr[@]}"; do
       find "$dir" -path "*/$TM_SELECTED_TEXT" -print0
    done|xargs -0 mate &>/dev/null &

Which would open the results as a project -- but would then require  
further actions to actually open one of the results (and mate should  
be moved to the bundle support dir).

Objections or comments (Chris)?




More information about the textmate-dev mailing list