unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 9438@debbugs.gnu.org
Subject: bug#9438: grep regressions
Date: Mon, 05 Sep 2011 11:34:04 +0300	[thread overview]
Message-ID: <87vct8gmjj.fsf@mail.jurta.org> (raw)

grep used to navigate directly to the correct column and highlight the
match instantly with `next-error-highlight'.  But now grep.el doesn't do
that because escape sequences are processed earlier than font-locking.

One way to fix this regression is to find matches highligted by
`grep-filter' and take their column positions.

Unfortunately, I can't find a simpler way to fix it than this patch:

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2011-08-22 09:54:38 +0000
+++ lisp/progmodes/grep.el	2011-09-05 08:30:35 +0000
@@ -344,7 +344,27 @@ (defvar grep-last-buffer nil
 ;;;###autoload
 (defconst grep-regexp-alist
   '(("^\\(.+?\\)\\(:[ \t]*\\)\\([1-9][0-9]*\\)\\2"
-     1 3)
+     1 3
+     ;; Calculate column positions (col . end-col) of first grep match on a line
+     ((lambda ()
+	(when grep-highlight-matches
+	  (setq compilation-error-screen-columns nil)
+	  (save-excursion
+	    (let* ((beg (progn (goto-char (match-end 0)) (point)))
+		   (end (line-end-position))
+		   (mbeg (text-property-any beg end 'font-lock-face 'match)))
+	      (when mbeg
+		(- mbeg beg))))))
+      .
+      (lambda ()
+	(when grep-highlight-matches
+	  (save-excursion
+	    (let* ((beg (progn (goto-char (match-end 0)) (point)))
+		   (end (line-end-position))
+		   (mbeg (text-property-any beg end 'font-lock-face 'match))
+		   (mend (and mbeg (next-single-property-change mbeg 'font-lock-face nil end))))
+	      (when mend
+		(- mend beg))))))))
     ;; Rule to match column numbers is commented out since no known grep
     ;; produces them
     ;; ("^\\(.+?\\)\\(:[ \t]*\\)\\([0-9]+\\)\\2\\(?:\\([0-9]+\\)\\(?:-\\([0-9]+\\)\\)?\\2\\)?"
@@ -353,17 +373,6 @@ (defconst grep-regexp-alist
     ;; handle weird file names (with colons in them) as well as possible.
     ;; E.g. we use [1-9][0-9]* rather than [0-9]+ so as to accept ":034:" in
     ;; file names.
-    ("^\\(\\(.+?\\):\\([1-9][0-9]*\\):\\).*?\
-\\(\033\\[01;31m\\(?:\033\\[K\\)?\\)\\(.*?\\)\\(\033\\[[0-9]*m\\)"
-     2 3
-     ;; Calculate column positions (beg . end) of first grep match on a line
-     ((lambda ()
-	(setq compilation-error-screen-columns nil)
-        (- (match-beginning 4) (match-end 1)))
-      .
-      (lambda () (- (match-end 5) (match-end 1)
-               (- (match-end 4) (match-beginning 4)))))
-     nil 1)
     ("^Binary file \\(.+\\) matches$" 1 nil nil 0 1))
   "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
 





             reply	other threads:[~2011-09-05  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05  8:34 Juri Linkov [this message]
2011-09-07  1:22 ` bug#9438: grep regressions Stefan Monnier
2011-09-07 12:09   ` Juri Linkov
2011-09-08 20:18     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vct8gmjj.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=9438@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).