1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

* lisp/progmodes/grep.el (grep-regexp-alist): Calculate column positions

based on text properties put by `grep-filter' instead of matching
escape sequences.
(grep-mode): Set buffer-local `compilation-error-screen-columns'
to the value of `grep-error-screen-columns'.

Fixes: debbugs:9438
This commit is contained in:
Juri Linkov 2011-09-07 15:00:52 +03:00
parent 249f792c82
commit 0527e251e5
2 changed files with 28 additions and 12 deletions

View file

@ -344,7 +344,24 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
;;;###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
(let* ((beg (match-end 0))
(end (save-excursion (goto-char beg) (line-end-position)))
(mbeg (text-property-any beg end 'font-lock-face 'match)))
(when mbeg
(- mbeg beg)))))
.
(lambda ()
(when grep-highlight-matches
(let* ((beg (match-end 0))
(end (save-excursion (goto-char beg) (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 +370,6 @@ Notice that using \\[next-error] or \\[compile-goto-error] modifies
;; 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'.")
@ -709,6 +715,8 @@ This function is called from `compilation-filter-hook'."
(set (make-local-variable 'compilation-process-setup-function)
'grep-process-setup)
(set (make-local-variable 'compilation-disable-input) t)
(set (make-local-variable 'compilation-error-screen-columns)
grep-error-screen-columns)
(add-hook 'compilation-filter-hook 'grep-filter nil t))