* GREP_OPTIONS again
@ 2004-09-17 4:51 Stefan
2004-09-17 14:00 ` Miles Bader
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefan @ 2004-09-17 4:51 UTC (permalink / raw)
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),
Stefan
--- orig/lisp/progmodes/grep.el
+++ mod/lisp/progmodes/grep.el
@@ -1,7 +1,7 @@
;;; grep.el --- run compiler as inferior of Emacs, parse error messages
-;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001, 02, 2004
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+;; 2001, 2002, 2004 Free Software Foundation, Inc.
;; Author: Roland McGrath <roland@gnu.org>
;; Maintainer: FSF
@@ -258,15 +258,17 @@
.
(lambda () (- (match-end 5) (match-end 3) 8)))
nil nil
- (4 (list 'face nil 'invisible t 'intangible t))
- (5 (list 'face compilation-column-face))
- (6 (list 'face nil 'invisible t 'intangible t))
+ ;; Delete annotations with `replace-match' because it updates
+ ;; the match-data, whereas `delete-region' would render it obsolete.
+ (5 (progn (replace-match "" t t nil 6)
+ (replace-match "" t t nil 4)
+ (list 'face font-lock-function-name-face)))
;; highlight other matches on the same line
("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
nil nil
- (1 (list 'face nil 'invisible t 'intangible t))
- (2 (list 'face compilation-column-face) t)
- (3 (list 'face nil 'invisible t 'intangible t))))
+ (2 (progn (replace-match "" t t nil 3)
+ (replace-match "" t t nil 1)
+ (list 'face font-lock-function-name-face)))))
("^Binary file \\(.+\\) matches$" 1 nil nil 1))
"Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GREP_OPTIONS again
2004-09-17 4:51 GREP_OPTIONS again Stefan
@ 2004-09-17 14:00 ` Miles Bader
2004-09-17 23:23 ` Richard Stallman
2004-10-02 23:45 ` Juri Linkov
2 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2004-09-17 14:00 UTC (permalink / raw)
Cc: emacs-devel
On Fri, Sep 17, 2004 at 12:51:09AM -0400, Stefan wrote:
> 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.
How's this GREP_OPTIONS thing supposed to work anyway? I noticed that my
*grep* buffer's recently have all kinds of extraneous crap in them, which
seems to be escape sequences, so grep is apparently trying to highlight
things, and emacs isn't groking it.
[I think it's pretty moronic that grep has colors turned on by default in the
first place, but that's a flame for a different mailing list.]
-Miles
--
Run away! Run away!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GREP_OPTIONS again
2004-09-17 4:51 GREP_OPTIONS again Stefan
2004-09-17 14:00 ` Miles Bader
@ 2004-09-17 23:23 ` Richard Stallman
2004-10-02 23:45 ` Juri Linkov
2 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2004-09-17 23:23 UTC (permalink / raw)
Cc: emacs-devel
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.
I agree.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GREP_OPTIONS again
2004-09-17 4:51 GREP_OPTIONS again Stefan
2004-09-17 14:00 ` Miles Bader
2004-09-17 23:23 ` Richard Stallman
@ 2004-10-02 23:45 ` Juri Linkov
2 siblings, 0 replies; 4+ messages in thread
From: Juri Linkov @ 2004-10-02 23:45 UTC (permalink / raw)
Cc: emacs-devel
Stefan <monnier@iro.umontreal.ca> 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/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-10-02 23:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-17 4:51 GREP_OPTIONS again Stefan
2004-09-17 14:00 ` Miles Bader
2004-09-17 23:23 ` Richard Stallman
2004-10-02 23:45 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.