From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Highlighting in grep buffer Date: Sun, 11 Apr 2004 01:29:12 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87isg7cmcy.fsf@mail.jurta.org> References: <87hdvvhzgh.fsf@mail.jurta.org> <87isgafmte.fsf-monnier+emacs@alfajor.local> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1081651061 28517 80.91.224.253 (11 Apr 2004 02:37:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Apr 2004 02:37:41 +0000 (UTC) Cc: rms@gnu.org, drew.adams@oracle.com, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Apr 11 04:37:35 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BCUql-00038y-00 for ; Sun, 11 Apr 2004 04:37:35 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BCUql-0007j0-00 for ; Sun, 11 Apr 2004 04:37:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BCUqK-0008H2-TW for emacs-devel@quimby.gnus.org; Sat, 10 Apr 2004 22:37:08 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BCUny-0006zn-Pm for emacs-devel@gnu.org; Sat, 10 Apr 2004 22:34:42 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BCUnR-0006dg-F0 for emacs-devel@gnu.org; Sat, 10 Apr 2004 22:34:40 -0400 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BCUnQ-0006cX-W6; Sat, 10 Apr 2004 22:34:09 -0400 Original-Received: from mail.jurta.org (80-235-32-66-dsl.mus.estpak.ee [80.235.32.66]) by knife.dreamhost.com (Postfix) with ESMTP id 0056AE401F; Sat, 10 Apr 2004 19:34:06 -0700 (PDT) Original-To: Stefan Monnier User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21458 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21458 >> (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/