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: GREP_OPTIONS again Date: Sun, 03 Oct 2004 02:45:38 +0300 Organization: JURTA Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <87pt407k8h.fsf@mail.jurta.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1096761243 24003 80.91.229.6 (2 Oct 2004 23:54:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 2 Oct 2004 23:54:03 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 03 01:53:46 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CDthC-0004de-00 for ; Sun, 03 Oct 2004 01:53:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CDtni-0000cP-CH for ged-emacs-devel@m.gmane.org; Sat, 02 Oct 2004 20:00:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CDtnc-0000cA-Fi for emacs-devel@gnu.org; Sat, 02 Oct 2004 20:00:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CDtnc-0000by-2W for emacs-devel@gnu.org; Sat, 02 Oct 2004 20:00:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CDtnc-0000bv-0X for emacs-devel@gnu.org; Sat, 02 Oct 2004 20:00:24 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CDtgo-0007HE-5f for emacs-devel@gnu.org; Sat, 02 Oct 2004 19:53:22 -0400 Original-Received: from mail.jurta.org (80-235-37-197-dsl.mus.estpak.ee [80.235.37.197]) by spatula.dreamhost.com (Postfix) with ESMTP id DE66D17D02C; Sat, 2 Oct 2004 16:53:17 -0700 (PDT) Original-To: Stefan In-Reply-To: (Stefan's message of "Fri, 17 Sep 2004 00:51:09 -0400") 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.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:27808 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27808 Stefan writes: > I just bumped into a bad side-effect of the GREP_OPTIONS thingy: > I grepped for MM and then isearched for `MM (', knowing full well there had > to be a match but it didn't find anything. > > The problem was the invisible annotations added by grep because of > the --color. I guess we should just remove them rather than make > them invisible. > > The patch below is actually untested (for some reason my grep doesn't want > to add those annotations any more right now), This patch doesn't work correctly: it fontified the text 8 positions to the right (the length of deleted annotations) from the actual match. Either font-lock should be improved to cope with deleted matches or maybe its existing capabilities already allow to do that. I tried to use the PRE-MATCH-FORM parameter. Basically it works for the first match on a line, but I don't see how to use it for other matches on the same line - the current implementation doesn't allow that: ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)" 1 2 ((lambda () (setq compilation-error-screen-columns nil) (- (match-beginning 5) (match-end 3))) . (lambda () (- (match-end 5) (match-end 3)))) nil nil ;; Delete annotations with `replace-match' because it updates ;; the match-data, whereas `delete-region' would render it obsolete. (5 (list 'face compilation-column-face)) ((lambda (p)) ; faked `MATCHER' (progn (replace-match "" t t nil 6) (replace-match "" t t nil 4))) ;; highlight other matches on the same line ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)" nil nil (2 (list 'face compilation-column-face)) ;; ??? ;; ((lambda (p)) ; facked `MATCHER' ;; (progn ;; (replace-match "" t t nil 3) ;; (replace-match "" t t nil 1))) )) BTW, the documentation for font-lock is more complete in the docstring of `font-lock-keywords' than in the Emacs Lisp Reference Manual. Perhaps, it should be updated. -- Juri Linkov http://www.jurta.org/emacs/