Interesting problem! I can think of a few approaches:
- patch ack to allow filtering with filename patterns (best: ack needs this feature)
- modify ack.vim to ignore certain filename patterns (not sure how you'd do this)
- filter output of ack, with a wrapper script/program (brittle/annoying to munge ack's output)
- filter input filelist given to ack, with a wrapper script/program (doable)
- patch ack to ignore jQuery files (kludgy, but works)
I got the last one working. Ack is written in Perl, so it's pretty easy to read and modify. Look for Ack.pm on your system. I use Ubuntu 11.10 and installed ack-grep to get ack; my Ack.pm is found at /usr/share/perl5/App/Ack.pm
. If you installed the stand-alone version of ack, the file you'll edit is just called "ack". Look for the subroutine is_searchable()
. Here's what I see:
sub is_searchable {
my $filename = shift;
# If these are updated, update the --help message
return if $filename =~ /[.]bak$/;
return if $filename =~ /~$/;
return if $filename =~ m{^#.*#$}o;
return if $filename =~ m{^core\.\d+$}o;
return if $filename =~ m{[._].*\.swp$}o;
return 1;
}
Add another line right after above return 1;
:
return if $filename =~ /^jquery/;
Again, going back to my first suggestion (patch ack to allow filtering with filename patterns) Andy might take a patch for this.
By the way, you probably already figured this out, but your use of --type-add
doesn't appear to be valid syntax for the ack command line:
--type-add=jquery=jquery*.js
it just expects file extensions. Hope this helps!