Ignore (TAGS|tags) files

704 views
Skip to first unread message

excepttheweasel

unread,
Jan 30, 2012, 10:18:36 PM1/30/12
to ack dev/users
When using Ack with vim and exuberant ctags or other tags files, you
tend to get a couple of extra results that aren't useful.

Reading the documentation of Ack I can't figure out a way to tell it
to ignore TAGS or tags files.

They typically don't have an extension. Is this possible? Would it be
possible to add a:

--[no]tags TAGS tags

filetype ignore?

Andy Lester

unread,
Feb 7, 2012, 11:53:11 AM2/7/12
to ack-...@googlegroups.com

On Jan 30, 2012, at 9:18 PM, excepttheweasel wrote:

Reading the documentation of Ack I can't figure out a way to tell it
to ignore TAGS or tags files.

ack should not be looking at your TAGS or tags files, because they are not file types that ack recognizes.

I suspect you are using the -a flag which tells ack to search all files, regardless of type.  If so, then ack is doing exactly what you're telling it to do.

xoxo,
Andy

Jonathan Rogers

unread,
Apr 4, 2013, 5:02:45 PM4/4/13
to ack-...@googlegroups.com


On Tuesday, February 7, 2012 11:53:11 AM UTC-5, Andy Lester wrote:

On Jan 30, 2012, at 9:18 PM, excepttheweasel wrote:

Reading the documentation of Ack I can't figure out a way to tell it
to ignore TAGS or tags files.

ack should not be looking at your TAGS or tags files, because they are not file types that ack recognizes.

I suspect you are using the -a flag which tells ack to search all files, regardless of type.  If so, then ack is doing exactly what you're telling it to do.


For me, ack finds text in my TAGS file when I call it with --text, so apparently ack considers it a text file.

Andy Lester

unread,
Apr 4, 2013, 5:05:13 PM4/4/13
to ack-...@googlegroups.com

On Apr 4, 2013, at 4:02 PM, Jonathan Rogers <jonatha...@gmail.com> wrote:

For me, ack finds text in my TAGS file when I call it with --text, so apparently ack considers it a text file.



Yes, but --text is a special case.  It's not a type like "perl" or "xml".

xoa

Jonathan Rogers

unread,
Apr 4, 2013, 5:04:46 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
>
> On Apr 4, 2013, at 4:02 PM, Jonathan Rogers <jonatha...@gmail.com
> <mailto:jonatha...@gmail.com>> wrote:
>
>> For me, ack finds text in my TAGS file when I call it with --text, so
>> apparently ack considers it a text file.
>>
>>
>
> Yes, but --text is a special case. It's not a type like "perl" or "xml".

So, how does one tell ack to search text files except for TAGS?

--
Jonathan Rogers

Andy Lester

unread,
Apr 4, 2013, 5:06:45 PM4/4/13
to ack-...@googlegroups.com

On Apr 4, 2013, at 4:04 PM, Jonathan Rogers <jonatha...@gmail.com> wrote:

So, how does one tell ack to search text files except for TAGS?

You can't in ack 1.x.  You can in ack 2.0.

Jonathan Rogers

unread,
Apr 4, 2013, 5:21:43 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
>
> On Apr 4, 2013, at 4:04 PM, Jonathan Rogers <jonatha...@gmail.com
> <mailto:jonatha...@gmail.com>> wrote:
>
>> So, how does one tell ack to search text files except for TAGS?
>
> You can't in ack 1.x. You can in ack 2.0.

OK. I hadn't tried ack 2 since it requires newer libraries than what
were on my system. However, I now have it installed and am getting the
desired behavior after simply removing "--text" from my existing
~/.ackrc. Thanks.

--
Jonathan Rogers

Andy Lester

unread,
Apr 4, 2013, 5:24:53 PM4/4/13
to ack-...@googlegroups.com
On Apr 4, 2013, at 4:21 PM, Jonathan Rogers <jonatha...@gmail.com> wrote:

OK. I hadn't tried ack 2 since it requires newer libraries than what
were on my system.

What libraries were those?


However, I now have it installed and am getting the
desired behavior after simply removing "--text" from my existing
~/.ackrc. Thanks.

I'm not sure what your desired behavior is, because ack2 should search TAGS and every other text file by default.

Jonathan Rogers

unread,
Apr 4, 2013, 5:44:51 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
>
> On Apr 4, 2013, at 4:21 PM, Jonathan Rogers <jonatha...@gmail.com
> <mailto:jonatha...@gmail.com>> wrote:
>
>> OK. I hadn't tried ack 2 since it requires newer libraries than what
>> were on my system.
>
> What libraries were those?

The Perl File::Next package from both EPEL and Ubuntu 12.10 was at
version 1.06 so I installed 1.12 from tarball.

>
>
>> However, I now have it installed and am getting the
>> desired behavior after simply removing "--text" from my existing
>> ~/.ackrc. Thanks.
>
> I'm not sure what your desired behavior is, because ack2 should search
> TAGS and every other text file by default.

The desired behavior is to search in a number of source file types and
general text files but not TAGS. That is exactly what ack 2.00b06 seems
to be doing with the ~/.ackrc I've attached.

--
Jonathan Rogers

.ackrc

Andy Lester

unread,
Apr 4, 2013, 5:53:35 PM4/4/13
to ack-...@googlegroups.com

On Apr 4, 2013, at 4:44 PM, Jonathan Rogers <jonatha...@gmail.com> wrote:

The desired behavior is to search in a number of source file types and
general text files but not TAGS. That is exactly what ack 2.00b06 seems
to be doing with the ~/.ackrc I've attached.

--type-set=template=.html,.translate,.template,.cheetah,.tmpl,.ghtml
--python
--template
--sql
--tex
--shell
--make
--cc
--el
--php
--js
--css
--java
--xml
--cpp
--type-set=groovy=.groovy
--groovy
--type-set=conf=.conf
--conf


What you have done is specified "These are the only file types that I want to search".  You are explicitly whitelisting types to search.  If you didn't, then TAGS would indeed get searched.

Jonathan Rogers

unread,
Apr 4, 2013, 6:03:12 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
>
> On Apr 4, 2013, at 4:44 PM, Jonathan Rogers <jonatha...@gmail.com
There must be something I still don't understand since the README says
that unlike ack 1, ack 2 always searches text files. I had to remove the
"--text" line from my ~/.ackrc before ack 2 would accept it. Even
without the "--text" option, ack 2 still searches a file called
"system-arch.txt" which the file command says is "ASCII English text".
However, it does not search a file called "crontab.office-server" which
file also says is "ASCII English text".

--
Jonathan Rogers

Andy Lester

unread,
Apr 4, 2013, 6:06:38 PM4/4/13
to ack-...@googlegroups.com
There must be something I still don't understand since the README says
that unlike ack 1, ack 2 always searches text files.

Then we need to clarify.

* If you don't specify a filetype, then it will search text files by default.
* If you specify a filetype, then it will only search those files that match that filetype.
* If you specify a no-filetype (--noperl) then it will search only known file types, except for Perl.

xoa

Jonathan Rogers

unread,
Apr 4, 2013, 6:09:03 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
>> There must be something I still don't understand since the README says
>> that unlike ack 1, ack 2 always searches text files.
>
> Then we need to clarify.
>
> * If you don't specify a filetype, then it will search text files by
> default.
> * If you specify a filetype, then it will only search those files that
> match that filetype.
> * If you specify a no-filetype (--noperl) then it will search only
> known file types, except for Perl.
>

This still doesn't explain why ack is searching a text file when I have
specified several file types, none of which describes the file in
question. It also doesn't explain how one would specify text as one of
several types to search.

--
Jonathan Rogers

Jonathan Rogers

unread,
Apr 4, 2013, 6:24:28 PM4/4/13
to ack-...@googlegroups.com
OK, it seems that the text file ack is searching when I specified
several types falls under ack's "shell" type. I have no idea why this is
the case, since it has none of the shell script characteristics I'm
aware of. It is simply several paragraphs of English prose with no
special punctuation, no shebang and its name ends with ".txt".

I'm also guessing that there's no way to regain the behavior that
"--text" invoked in ack 1. However, that may not be useful anyway, since
what I want to is to search text files except TAGS. I guess I just need
to figure out how to define a type by file name pattern for the text
files I want ack to find.

--
Jonathan Rogers

Tony Duckles

unread,
Apr 4, 2013, 6:28:29 PM4/4/13
to ack-...@googlegroups.com
For ack2, use "ack2 --help-types" to see what patterns the various file-types match.  For example, "shell" matches:
"--[no]shell        .sh .bash .csh .tcsh .ksh .zsh first line matches (?^i:(?:ba|t?c|k|z)?sh\b)"

FYI, if you want to see what filetype ack2 thinks a file is, use "ack2 --show-types -f"



--
Jonathan Rogers

--
You received this message because you are subscribed to the Google Groups "ack dev/users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ack-users+...@googlegroups.com.
To post to this group, send email to ack-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ack-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Jonathan Rogers

unread,
Apr 4, 2013, 6:38:51 PM4/4/13
to ack-...@googlegroups.com
Tony Duckles wrote:
> For ack2, use "ack2 --help-types" to see what patterns the various
> file-types match. For example, "shell" matches:
> "--[no]shell .sh .bash .csh .tcsh .ksh .zsh first line matches
> (?^i:(?:ba|t?c|k|z)?sh\b)"
>
> FYI, if you want to see what filetype ack2 thinks a file is, use "ack2
> --show-types -f"

I'm guessing ack thinks the file in question is a shell script because
it has the sequence "sh " on the first line, though after a lot of other
English words. Thanks. Now if I could just figure out how to define a
type by general file name pattern rather than just suffix.

--
Jonathan Rogers

Andy Lester

unread,
Apr 4, 2013, 6:52:26 PM4/4/13
to ack-...@googlegroups.com
I believe the README has a big section on that.  There are many ways of specifying types now.  It could be that one of the default rules is wrong.

In fact, would you please make a ticket in the ack2 queue showing the behavior, including what command line you used, and the fiel that is misidentfied.

You should be able to do

ack -f --shell

And get only shell files, and if you get anything else, then that is a problem.

Sent from my Verizon Wireless 4G LTE DROID

Jonathan Rogers

unread,
Apr 4, 2013, 7:07:16 PM4/4/13
to ack-...@googlegroups.com
Andy Lester wrote:
> I believe the README has a big section on that. There are many ways
> of specifying types now. It could be that one of the default rules is
> wrong.

I had read the README, which doesn't describe how to define types.
However, the man page does so I was able to define a type by file name
regular expression.

>
> In fact, would you please make a ticket in the ack2 queue showing the
> behavior, including what command line you used, and the fiel that is
> misidentfied.
>
> You should be able to do
>
> ack -f --shell
>
> And get only shell files, and if you get anything else, then that is a
> problem.

Yes, that is exactly what I did and was quite surprised that it found a
file which is definitely not a text file. Digging deeper, I found that
--shell produces many false positives, including HTML and JPEG files. I
can't share the internal company document that was the first false
positive I noticed but I did find that a file containing nothing more
than "English" (which appeared on the first line of the document) will
be considered a shell script by ack. I will make a ticket.

--
Jonathan Rogers

Fernando Marcheselli

unread,
Jul 26, 2013, 1:21:46 PM7/26/13
to ack-...@googlegroups.com
I have a similar issue with ack2 searching tags

I explicitly ignore tags with this:

--ignore-file=is:tags
Reply all
Reply to author
Forward
0 new messages