[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grep with matching lines syntax highlighted [snippet]

From: address@hidden
Subject: Re: Grep with matching lines syntax highlighted [snippet]
Date: 9 Dec 2006 22:37:07 -0800
User-agent: G2/1.0

Drew Adams írta:
> Inspired by what you've done, I've taken a different approach, in the latest
> grep+.el: I defined a
> command, bound in buffer *grep* to `;', that removes all lines that start
> with (possibly whitespace followed by) a comment. IOW, you use `M-x grep' as
> usual, then hit `;' to flush the commented lines.

But what about the case when it is a multiline comment (e.g. in C /*
... */) and one of the middle lines are matched, so you can't recognize
with a simple regexp it's a commented line? Why don't you apply some of
the original idea then?

If the regular expression doesn't match the line then you should check
if the file is already opened and if it is then check if the whole line
has font-lock-comment face. If it has the it can also be filtered.

If the line doesn't have comment face, but it doesn't have the
'fontified property either (stealth fontification) then you should
trigger the appropriate fontification function (if there's any for the
mode) for the region to find out if the line is a commented line.

It's not that complicated and it could be very useful. The most common
case (for me at least) is removing commented lines from grep output not
just any regexp, so I think this case warrants a special treatment for

reply via email to

[Prev in Thread] Current Thread [Next in Thread]