google / codesearch

Fast, indexed regexp search over large file trees
http://swtch.com/~rsc/regexp/regexp4.html
BSD 3-Clause "New" or "Revised" License
3.66k stars 375 forks source link

csearch: Add flag (-g) for grouping output by file (a'la ack --group, or git grep --heading) [PATCH] #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The goal is so that the output is more palatable to the human eyes, compare:

$ csearch Aqyadaya
/home/nazri/perl5/perlbrew/perls/perl-5.14.2/man/man3/Text::SimpleTable.3:\&    
$t1\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);
/home/nazri/perl5/perlbrew/perls/perl-5.14.2/man/man3/Text::SimpleTable.3:\&    
$t2\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);
/home/nazri/perl5/perlbrew/perls/perl-5.14.2/man/man3/Text::SimpleTable.3:\&    
$t3\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);

$ csearch -g Aqyadaya
/home/nazri/perl5/perlbrew/perls/perl-5.14.2/man/man3/Text::SimpleTable.3
\&    $t1\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);
\&    $t2\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);
\&    $t3\->row(\*(Aqfoobarbaz\*(Aq, \*(Aqyadayadayada\*(Aq);

Original issue reported on code.google.com by ayieh...@gmail.com on 20 Apr 2012 at 1:46

Attachments:

GoogleCodeExporter commented 9 years ago
The patch is buggy :) - in some cases it shows the filename even when there's 
no match. Attached patch should fix this.

Original comment by ayieh...@gmail.com on 20 Apr 2012 at 1:57

Attachments:

GoogleCodeExporter commented 9 years ago
This looks great!  Russ Cox should be releasing a new version soon -- hopefully 
your patch will make it in.

Original comment by dgryski on 20 Apr 2012 at 12:19

GoogleCodeExporter commented 9 years ago
The patch blindly adds an empty line after the matches. I'm not sure if others 
are ok with this behavior. Me I prefer the empty line as it shows the grouping 
better.

Original comment by ayieh...@gmail.com on 23 Apr 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Seeing as you're already changing the output format based on a flag, I don't 
think the extra blank line is necessarily a problem.   If this behaviour 
matches what ack and grep do, then it's probably fine: we're at least matching 
what other similar tools emit.

Original comment by dgryski on 23 Apr 2012 at 10:55