Commit 0527e251 authored by Juri Linkov's avatar Juri Linkov

* 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
parent 249f792c
2011-09-07 Juri Linkov <juri@jurta.org>
* 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' (bug#9438).
2011-09-07 Juri Linkov <juri@jurta.org>
* simple.el (next-error-highlight, next-error-highlight-no-select):
......
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment