emacs-devel
[Top][All Lists]
Advanced

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

Re: Highlighting in grep buffer


From: Juri Linkov
Subject: Re: Highlighting in grep buffer
Date: Sun, 11 Apr 2004 01:29:12 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

>>   (defun grep-process-setup ()
>>     "Setup compilation variables and buffer for `grep'.
>>   Set up `compilation-exit-message-function' and run `grep-setup-hook'."
>> +   (setenv "GREP_OPTIONS" "--color=always")
>> +   (setenv "GREP_COLOR" "01;31")
>>     (set (make-local-variable 'compilation-exit-message-function)
>>          (lambda (status code msg)
>> +          (ansi-color-apply-on-region (point-min) (point-max))
>>            (if (eq status 'exit)
>>                (cond ((zerop code)
>>                       '("finished (matches found)\n" . "matched"))
>
> Sounds like a good idea.  The call to ansi-color-apply-on-region should
> probably be in the process filter so it's applied on-the-fly rather than at
> the end of the command, but that can be changed later on (I think it
> requires more changes).

Yes, calling the ansi-color-apply-on-region would be better from the
process filter, but there is a danger that boundaries of strings that
a process gives to the filter function will be inside an ANSI escape
sequence, which will screw up its fontification.

>> The matching positions returned by grep could be also used instead of
>> `highlight-regexp' to highlight substrings in visited source lines.
>
> How can you get `grep' to return matching positions?

Matching positions are explicitly marked by ANSI escape sequences, so
these positions can be found before translating ANSI escape sequences
into faces.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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