Textmate plugin available and a question

11 views
Skip to first unread message

Trevor Squires

unread,
May 27, 2008, 2:49:44 PM5/27/08
to ack dev/users
Hey,

a short while back I went looking for a TextMate plugin for ack but
the advertised link was dead so I based one off GrepInProject++
(another textmate plugin).

You can find it at:

http://github.com/protocool/ack-tmbundle/tree/master

It does nifty stuff like remember your last 10 searches, allows you to
choose word, literal or case insensitive search as well as configure
options like whether you want to show context lines, follow symlinks
and ignore .ackrc (you can define a .ackrc in your project directory
too).

It's still a work in progress (it doesn't give feedback in the results
window as quick as I'd like, working to improve that) and there's one
issue that's cropped up that I'd like to bounce around here...

Basically, --ignore-dir=xxx is great for ignoring .svn style
directories - where they can appear anywhere in your searched tree.
However, what I'd like to offer is the ability to ignore a *path*.

As an example: I'd like to ignore the path of vendor/rails. Using --
ignore-dir=rails will ignore it in any part of the searched tree, but
I just want to ignore the one in vendor - something like --ignore-
path=vendor/rails.

I can totally understand if that option is something beyond the scope
of vanilla 'ack' (which is meant to be invoked from anywhere) and I am
shipping a copy of ack-standalone with the bundle so I *could* patch
in the behavior in my private copy.

However, if this sort of feature would be welcomed I'd be happy to
submit a patch... so I'm throwing this out for comment.

Regards,
Trevor

Andy Lester

unread,
May 27, 2008, 2:52:59 PM5/27/08
to ack-...@googlegroups.com

On May 27, 2008, at 1:49 PM, Trevor Squires wrote:

> As an example: I'd like to ignore the path of vendor/rails. Using --
> ignore-dir=rails will ignore it in any part of the searched tree, but
> I just want to ignore the one in vendor - something like --ignore-
> path=vendor/rails.


I've thought about this before, and immediately ran into two concerns:

1) If you have --ignore-path=foo/bar/bat and you're in foo/bar, will
bat/ get ignored? There are pros and cons either way.

2) It would require some big changes to File::Next, I think.

But I'm open to a discussion with the group on #1.

xoxo,
Andy

--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance


Trevor Squires

unread,
May 27, 2008, 3:33:48 PM5/27/08
to ack dev/users
Well, my plan was to cheat a little because my textmate plugin always
has a known starting point - the TextMate project root.

All of my ack arguments are relative to the project root and I cd to
the TextMate project root before invoking ack. I also set
ACKRC=.ackrc so that users could put their --ignore-path=something/
relative in the 'project' .ackrc file.

For my plugin's users it would be the principle of least surprise -
you always --ignore-path relative to your project root and it just
works.

For vanilla 'ack' - the ambiguity you talk about in #1 is pretty
ugly. My gut tells me that the answer to your question is 'no, bat
does not get ignored' considering the following edge case:

foo/bar/bat
foo/bar/foo/bar/bat
foo/bar/foo/bar/wibble

cd foo/bar
ack --ignore-path=foo/bar/bat expression

On the command line my intentions are clear - ignore bat in cwd/foo/
bar but I'm not saying anything about ignoring bat in cwd so don't
ignore it.

However, the moment you put --ignore-path in your $HOME/.ackrc the
whole cwd anchor thing will bite you.

Beyond that I'm pretty unqualified to have much of an opinion on #1
because I'm relatively new to ack.

Regards,
Trevor
> Andy Lester => a...@petdance.com =>www.petdance.com=> AIM:petdance

Pedro Melo

unread,
May 28, 2008, 2:24:25 AM5/28/08
to ack-...@googlegroups.com
Hi,

On May 27, 2008, at 7:49 PM, Trevor Squires wrote:

> a short while back I went looking for a TextMate plugin for ack but
> the advertised link was dead so I based one off GrepInProject++
> (another textmate plugin).

That plugin was my own and the link was corrected last friday when I
was notified of the dead link.

but your command looks a lot better than mine. I'll test it today.

You should also announce it in the TextMate mailing list also.

Best regards,

Trevor Squires

unread,
Jun 3, 2008, 7:36:15 PM6/3/08
to ack dev/users
Hi Andy,

I went ahead and tweaked Ack.pm today to support --ignore-path=xxx but
it didn't require any changes to File::Next as you mentioned so either
I've come up with a simple way to support it ... or I've grossly
oversimplified things.

Here's the patch (without unit tests while I'm just soliciting advice/
feedback):

http://pastie.caboo.se/208327

Regards,
Trevor

On May 27, 11:52 am, Andy Lester <a...@petdance.com> wrote:
Reply all
Reply to author
Forward
0 new messages