(This whole message is rich text, all fixed with Courier New with some bolding. If you don't have it fixed width it will be bad.)
The big change in ack 3 that we're discussing now is -w. Although -w promises "word" matching, it's basically just slapping \b and \b around the regex. That causes problems that we'll discuss elsewhen.
We also have a big problem with how things get highlighted. The first match group gets highlighted, which is wrong. It should match the entire match, effectively $&.
In order to test these things, we're going to need a way to easily set up test cases that verify correct behavior. I want to add an --underline flag that will make testing of highlighting easier, and will make a handy feature for when ack results go to a file.
I'm stealing the idea from the clang compiler, which does this with error messages:
op.c:13249:21: warning: variable 'is_deref' may be uninitialized when used here [-Wconditional-uninitialized]
if (is_deref) {
^~~~~~~~
I'm not seeing this in grep, so it looks like it will be new territory. I also see --underline and --color being mutually exclusive.
Similarly, whereas right now ack 2 does this (which is bad behavior) (the bold would be highlighted on screen).
$ ack 'calculate_(foo|bar|bat)'
and ack 2 SHOULD do this:
$ ack 'calculate_(foo|bar|bat)'
I want ack3 to also be able to do this:
$ ack 'calculate_(foo|bar|bat)' --underline
^^^^^^^^^^^^^
^^^^^^^^^^^^^
^^^^^^^^^^^^^
And with the newly worked-out -w flag in ack3, it should do this:
$ ack 'calculate_(foo|bar|bat)' --underline
^^^^^^^^^^^^^
$ ack 'calculate_(foo|bar|bat)'
The two big uses cases I see for --underline are for dumping lots of ack hits into a file for later perusal, and for our testing purposes.
Comments on this plan?