[TxMt] Updated Search in Project with ack

Pedro Melo melo at simplicidade.org
Mon Jun 2 10:17:50 UTC 2008


Hi,

On May 30, 2008, at 8:01 PM, Corey Jewett wrote:

> I tweaked Pedro's tmCommand a bit (diff below) to add support for  
> searching files/folders selected in the project drawer. The  
> drawback to this is that it now only searches the selected files/ 
> folders. If you want to search the whole project with this version  
> you must select the project folder before doing the search.

Yes, or de-select the file. But it is a welcome improvement, so I've  
updated my copy with it.

I've also moved the code to GitHub. See http://github.com/melo/search- 
in-project-with-ack-tmcommand

The latest version will always be there now. No more 404's :)

> I'm sure I've overlooked some edge case. This change was simple  
> enough I'm surprised the original GrepInProject didn't support it  
> so I must be overlooking something.

So far I didn't notice any edge cases.

Best regards,

>
> Corey
>
> --- Search in Project with ack.tmCommand.pedro	2008-05-30  
> 11:52:43.000000000 -0700
> +++ Search in Project with ack.tmCommand	2008-05-30  
> 11:52:23.000000000 -0700
> @@ -119,8 +119,11 @@
>    <table>
>  HTML
>
> -# TODO: Respect ENV['TM_SELECTED_FILES']
> -command = %{cd "#{directory}"; ack #{e_sh query}}
> +if ENV['TM_SELECTED_FILES']
> +	command = %{ack -H #{e_sh query} #{ENV['TM_SELECTED_FILES']}}
> +else
> +	command = %{cd "#{directory}"; ack #{e_sh query}}
> +end
>
>  IO.popen(command) do |pipe|
>
> @@ -133,7 +136,10 @@
>      line.gsub!(/^([^:]+):(\d+):(.*)$/) do
>
>        relative_path, line_number, content = $1, $2, $3.strip
> -      path = directory + '/' + relative_path
> +	
> +      relative_path.sub!(directory + "/", '') if ENV 
> ['TM_SELECTED_FILES']
> +
> +      path = directory + '/' + relative_path
>        url = "txmt://open/?url=file://#{path}&line=#{line_number}"
>        fname = "%s:%s" % [ellipsize_path(relative_path), line_number];
>        fname = ":%s" % [ line_number ] if (path == last_path);
>
> On May 26, 2008, at 04:49 , Pedro Melo wrote:
>
>> Hi,
>>
>> I've updated my Search in Project with ack command. The new  
>> version is here:
>>
>> http://www.simplicidade.org/notes/archives/2008/03/ 
>> search_in_proje.html
>>
>> Thanks to Daniel Hüsch for poiting out the 404 in the page.
>>
>> Best regards,
>> -- 
>> Pedro Melo
>> Blog: http://www.simplicidade.org/notes/
>> XMPP ID: melo at simplicidade.org
>> Use XMPP!
>>
>>
>>
>> _____________________________________________________________________ 
>> _
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you  
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate

-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo at simplicidade.org
Use XMPP!





More information about the textmate mailing list