Including files without an extension in a type?

8 views
Skip to first unread message

travi...@gmail.com

unread,
Jun 25, 2009, 11:58:31 AM6/25/09
to ack dev/users
Hi. I'm a new user to ack, so it's very possible that I missed this in
the documentation, but how do you add files with a specific name (but
without a file extension) to a type?

I tried adding --type-add=mason=.mhtml,.mh,.md,autohandler,dhandler to
my .ackrc, but it still doesn't seem to be able to pick up the
autohandler or dhandler lines. These are actually mason files and it
would be invalid to add a file extension to them. I'm using App::Ack
version 1.88.

I'm sure that I'm missing something simple. If there is a better list
where I can direct my question, please let me know.

Thanks for the help,
Travis Beck

Mike Hostetler

unread,
Jun 25, 2009, 12:31:12 PM6/25/09
to ack-...@googlegroups.com
On Thu, Jun 25, 2009 at 10:58 AM, tra...@brontosaurus.net <travi...@gmail.com> wrote:

Hi. I'm a new user to ack, so it's very possible that I missed this in
the documentation, but how do you add files with a specific name (but
without a file extension) to a type?

Welcome.  Your life will become much easier with ack.


I tried adding --type-add=mason=.mhtml,.mh,.md,autohandler,dhandler to
my .ackrc, but it still doesn't seem to be able to pick up the
autohandler or dhandler lines. These are actually mason files and it
would be invalid to add a file extension to them. I'm using App::Ack
version 1.88.

I had problems with this, too. In your ~/.ackrc, you need to use type-set, not type-add.   This is how I set a --log type in my ~/.ackrc

--type-set=log=.log



I'm sure that I'm missing something simple. If there is a better list
where I can direct my question, please let me know.

This has been addressed multiple times -- maybe we should have better docs?

--
Mike Hostetler
http://mike.hostetlerhome.com/


Andy Lester

unread,
Jun 25, 2009, 12:35:09 PM6/25/09
to ack-...@googlegroups.com
> I had problems with this, too. In your ~/.ackrc, you need to use
> type-set, not type-add. This is how I set a --log type in my
> ~/.ackrc
>
> --type-set=log=.log

His problem is files that don't have an extension like "autohandler"
in Mason.

No, we don't have a way to address that yet.


> I'm sure that I'm missing something simple. If there is a better list
> where I can direct my question, please let me know.
>
> This has been addressed multiple times -- maybe we should have
> better docs?


Patches more than welcome. I'd love to have an ack FAQ, too.

xoxo,
Andy

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


Andy Lester

unread,
Jun 25, 2009, 12:42:31 PM6/25/09
to ack-...@googlegroups.com

On Jun 25, 2009, at 11:31 AM, Mike Hostetler wrote:

> I'm sure that I'm missing something simple. If there is a better list
> where I can direct my question, please let me know.
>
> This has been addressed multiple times -- maybe we should have
> better docs?


I just realized I have a start to the FAQ in ack-base in the tree.
Feed me some questions & answers and I'll plug 'em in if you don't
want to mess with formatting and submitting a patch and all.

Thanks,

Mike Hostetler

unread,
Jun 25, 2009, 1:37:56 PM6/25/09
to ack-...@googlegroups.com
On Thu, Jun 25, 2009 at 11:35 AM, Andy Lester <an...@petdance.com> wrote:

> I had problems with this, too. In your ~/.ackrc, you need to use
> type-set, not type-add.   This is how I set a --log type in my
> ~/.ackrc
>
> --type-set=log=.log

His problem is files that don't have an extension like "autohandler"
in Mason.

He could to "handler" (no .)  . That may  pick up files you don't want, though/

No, we don't have a way to address that yet.


> I'm sure that I'm missing something simple. If there is a better list
> where I can direct my question, please let me know.
>
> This has been addressed multiple times -- maybe we should have
> better docs?


Patches more than welcome.  I'd love to have an ack FAQ, too.

You keep saying that . .. :)

travis g beck

unread,
Jun 25, 2009, 2:52:50 PM6/25/09
to ack-...@googlegroups.com
On Thu, Jun 25, 2009 at 1:37 PM, Mike Hostetler <hoste...@gmail.com> wrote:
On Thu, Jun 25, 2009 at 11:35 AM, Andy Lester <an...@petdance.com> wrote:

> I had problems with this, too. In your ~/.ackrc, you need to use
> type-set, not type-add.   This is how I set a --log type in my
> ~/.ackrc
>
> --type-set=log=.log

His problem is files that don't have an extension like "autohandler"
in Mason.

He could to "handler" (no .)  . That may  pick up files you don't want, though/

I investigated this, and it looks like ack only matches types for files with a dot after the last directory separator. So I don't think that will work. It would be nice to note this in the docs though maybe :)



No, we don't have a way to address that yet.


> I'm sure that I'm missing something simple. If there is a better list
> where I can direct my question, please let me know.
>
> This has been addressed multiple times -- maybe we should have
> better docs?


Patches more than welcome.  I'd love to have an ack FAQ, too.

You keep saying that . .. :)


See attached patch. I just added the ability for ack to match the full string in %types against the file basename. This should make it possible to clean up the Makefile and Rakefile handling (or add Capfile as I've seen in other threads), but I didn't do that yet. It will also have an unfortunate side effect of adding all files whose names are file extensions to the list of types, which will only practically have an effect by, say, matching /usr/bin/zsh or the like, which is probably not what you want, but may be what users are already expecting.

Sorry, no tests or documentation in this patch. If you're into the approach, I can write that stuff too.

Travis
ack.patch

Ingmar Vanhassel

unread,
Jun 26, 2009, 1:35:41 AM6/26/09
to ack-users
Excerpts from travis g beck's message of Thu Jun 25 20:52:50 +0200 2009:

> See attached patch. I just added the ability for ack to match the full
> string in %types against the file basename.

Any reason to lowercase the basename? That may be appropriate for
makefiles, but it doesn't generalize.
Besides that, your approach is much better than what I did to add cmake
support (matching .cmake & CMakeLists.txt)

> Sorry, no tests or documentation in this patch. If you're into the approach,
> I can write that stuff too.

I think tests are pretty much considered mandatory. :)

--
Exherbo KDE, X.org maintainer

Reply all
Reply to author
Forward
0 new messages