ack 1.96: Highlighting submatches only?

41 views
Skip to first unread message

Raffaele Ricciardi

unread,
Aug 5, 2012, 7:45:08 AM8/5/12
to ack-...@googlegroups.com
Hello there,

I'm trying to search for a pattern (mostly) outside line comments in Emacs Lisp,
where line comments start with a ; (semicolon). I'm running Ack like this:

ack --elisp --match "^[^;]*(pattern)"

So far, so good.  However, Ack highlights the whole match, whilst I'd like only
the submatch I'm looking for - eg "(pattern)" to be highlighted.  I can't find
any option to do so.  Is it possible?

Thank you.  

Andrew Black

unread,
Aug 5, 2012, 10:44:21 AM8/5/12
to ack-...@googlegroups.com
Hi Raffaele
I know of know such option but...

If you are on Perl 5.10 or later you can use the \K metacharacter
    ack "^[^;].*\Kwant"
    2:this is wanted

My inital suggestion was to use a lookbehind but that doesn't work because it would have to be variable length.



--
You received this message because you are subscribed to the Google Groups "ack dev/users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ack-users/-/oFc767WdL7sJ.
To post to this group, send email to ack-...@googlegroups.com.
To unsubscribe from this group, send email to ack-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ack-users?hl=en.

Raffaele Ricciardi

unread,
Aug 6, 2012, 4:18:35 AM8/6/12
to ack-...@googlegroups.com, andrew...@googlemail.com
Solved.  Thank you.


On Sunday, August 5, 2012 3:44:21 PM UTC+1, Andrew Black wrote:
Hi Raffaele
I know of know such option but...

If you are on Perl 5.10 or later you can use the \K metacharacter
    ack "^[^;].*\Kwant"
    2:this is wanted

My inital suggestion was to use a lookbehind but that doesn't work because it would have to be variable length.

On 5 August 2012 12:45, Raffaele Ricciardi wrote:
Hello there,

I'm trying to search for a pattern (mostly) outside line comments in Emacs Lisp,
where line comments start with a ; (semicolon). I'm running Ack like this:

ack --elisp --match "^[^;]*(pattern)"

So far, so good.  However, Ack highlights the whole match, whilst I'd like only
the submatch I'm looking for - eg "(pattern)" to be highlighted.  I can't find
any option to do so.  Is it possible?

Thank you.  


--
You received this message because you are subscribed to the Google Groups "ack dev/users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ack-users/-/oFc767WdL7sJ.
To post to this group, send email to ack-...@googlegroups.com.
To unsubscribe from this group, send email to ack-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages