Issue 81 Patch - Global ackrc

11 views
Skip to first unread message

Shaun

unread,
Jun 11, 2009, 5:26:43 PM6/11/09
to ack dev/users
Patch for issue 81: (http://code.google.com/p/ack/issues/detail?id=81

On Linux look for .ackrc (by order of precedence):

Current Directory
Home directory
/usr/local/etc
/etc



Index: Ack.pm
===================================================================
--- Ack.pm (revision 962)
+++ Ack.pm (working copy)
@@ -154,7 +154,7 @@
my @dirs =
$is_windows
? ( $ENV{HOME}, $ENV{USERPROFILE} )
- : ( '~', $ENV{HOME} );
+ : ( '.' '~', $ENV{HOME}, '/usr/local/etc', '/etc');
for my $dir ( grep { defined } @dirs ) {
for my $file ( '.ackrc', '_ackrc' ) {
push( @files, bsd_glob( "$dir/$file", GLOB_TILDE ) );

Shaun

unread,
Jun 11, 2009, 7:48:23 PM6/11/09
to ack dev/users
Sorry I double-checked my post when I got home... it appears I must
have had a bad copy on my clipboard. It was missing a comma

Update.

Index: Ack.pm
===================================================================
--- Ack.pm (revision 962)
+++ Ack.pm (working copy)
@@ -154,7 +154,7 @@
my @dirs =
$is_windows
? ( $ENV{HOME}, $ENV{USERPROFILE} )
- : ( '~', $ENV{HOME} );
+ : ( '.', '~', $ENV{HOME}, '/usr/local/etc', '/etc');

Jan Dubois

unread,
Jun 11, 2009, 8:46:23 PM6/11/09
to ack-...@googlegroups.com
On Thu, 11 Jun 2009, Shaun wrote:
>
> --- Ack.pm (revision 962)
> +++ Ack.pm (working copy)
> @@ -154,7 +154,7 @@
> my @dirs =
> $is_windows
> ? ( $ENV{HOME}, $ENV{USERPROFILE} )
> - : ( '~', $ENV{HOME} );
> + : ( '.', '~', $ENV{HOME}, '/usr/local/etc', '/etc');
> for my $dir ( grep { defined } @dirs ) {
> for my $file ( '.ackrc', '_ackrc' ) {
> push( @files, bsd_glob( "$dir/$file", GLOB_TILDE ) );

There is no reason why '.' should be added only to the Unix branch and
not to the Windows one as well.

However, I disagree that looking for ./.ackrc is a desirable feature,
at least not the way it is currently implemented. I would consider it
a bug if ack worked differently depending on my current working directory,
especially if I specify an absolute path name for the search. And
I certainly don't want to `cd` into the directory first before being
able to search it with locally modified rules.

I _could_ see some value in a directory-specific .ackrc file if it would
only be applied to files found in that particular directory. That way
you could add additional extensions on a per-directory basis. This will
require a different implementation though, and I'm not convinced that it
is worth the effort.

Cheers,
-Jan

Shaun

unread,
Jun 11, 2009, 10:11:52 PM6/11/09
to ack dev/users
Jan,

Yeah I tend to agree. I fixed it how the issue was written expecting
feedback like yours. I'll leave it up to the maintainers and this
community to decide.

Thanks,

--
Shaun

Bill Ricker

unread,
Jun 12, 2009, 8:30:34 AM6/12/09
to ack-...@googlegroups.com
On Thu, Jun 11, 2009 at 8:46 PM, Jan Dubois <ja...@activestate.com> wrote:
>
> a bug if ack worked differently depending on my current working directory,

 since we don't integrate with exactly one IDE we don't know from
'current project' so CWD is the only workable proxy available.

I could argue that if there is no .ackrc in . that search should go up
.. chain before going to $HOME and $ACKROOT as if CWD is a subdir of a
project, behavior should be the same.

> especially if I specify an absolute path name for the search.  And

an absolute path has some extra information, and using an .ackrc there
would make sense, but the language(s) of interest may still be
indicated by ./.ackrc or personal preferences / prejudices still
belong in ~/.ackrc not in shared areas. We probably don't want to
merge three sets of options as if it was CSS , but there's an argument
for it. A user with firm prejudices but needs local tweaks can copy
~/.ackrc ./.ackrc and tweak as needed.

--
Bill
n1...@arrl.net bill....@gmail.com

Reply all
Reply to author
Forward
0 new messages