I'm using Vim + Ack.Vim and am flummoxed on how to ignore hits within Jquery files. I've got an .ackrc file defined (see below), but I'm stabbing in the dark.
--type-add=ruby=.haml,.rake,.rsel,.builder
--type-add=html=.html.erb,.html.haml
--type-add=js=.js.erb
--type-add=css=.sass
--type-set=cucumber=.feature
--type-add=jquery=jquery*.js
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc
--ignore-dir=coverage
--sort-files
--color
--follow
--group
--nojquery
How would seasoned ack + ack.vim users solve this issue?
Interesting problem! I can think of a few approaches:
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With