17

I've recently learned how to let ack support more filetypes (adding the following to .ackrc):

--type-add
latte=.latte

Unfortunately, that produces an info line on every ack search I use, even ones with 0 results.

$ ack --latte dump
ack: --type-add: Type "latte" does not exist, creating with ".latte" ...

Is there a way to make this a more permanent addition? (i.e. get rid of this info line) This looks to me like it's adding this new type on every ack call. Is it a problem with my installation of ack?

I'm on Mac OS X 10.5.8 with ack 1.92 (Running under Perl 5.10.1)

3 Answers3

18

Seems to me that the documentation claims you need --type-set instead:

--type-set
latte=.latte

Whereas --type-add is for, emphasis mine:

Files with the given EXTENSION(s) are recognized as being of (the existing) type TYPE.

Arjan
  • 31,511
0

Create or edit .ackrc in your $HOME directory and add --type-add=cpp:ext:inl.

This adds the file extension inl as a match for the existing type "cpp".

~/.ackrc:

# C++
--type-add=cpp:ext:inl

Usage:

ack --cpp Foo

In addition to match type ext for file extension, there is also is for exact filename match, match for regex match, and firstlinematch (also a regex, but matches against the first line of each file).

0

Hmmm... ack is basically a Perl script... which is quite easy to edit:

%mappings = (
    actionscript => [qw( as mxml )],
    ada         => [qw( ada adb ads )],
...
    latte       => [qw( latte )],
...
    yaml        => [qw( yaml yml )],
    xml         => [qw( xml dtd xslt ent )],
);

But still, is there another solution to this?