[TxMt] Updated Search in Project with ack

Corey Jewett ml at syntheticplayground.com
Fri May 30 19:01:18 UTC 2008


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.

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.

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




More information about the textmate mailing list