[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9438: grep regressions
From: |
Juri Linkov |
Subject: |
bug#9438: grep regressions |
Date: |
Mon, 05 Sep 2011 11:34:04 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
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'.")
- bug#9438: grep regressions,
Juri Linkov <=