summaryrefslogtreecommitdiff
path: root/lisp/progmodes/grep.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2011-09-07 15:00:52 +0300
committerJuri Linkov <juri@jurta.org>2011-09-07 15:00:52 +0300
commit0527e251e5abfd1d574d0a5bc3c9348f7ec5a8ba (patch)
tree96fce72d1fdc35c19d976cb3d51440a40102f031 /lisp/progmodes/grep.el
parent249f792c828e9ad1e04ebda32f0e68c060bbe2ec (diff)
downloademacs-0527e251e5abfd1d574d0a5bc3c9348f7ec5a8ba.tar.gz
* 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
Diffstat (limited to 'lisp/progmodes/grep.el')
-rw-r--r--lisp/progmodes/grep.el32
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index de46dc19169..b3f9758bacf 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -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))