From: Juri Linkov Date: Mon, 5 Sep 2011 08:20:02 +0000 (+0300) Subject: Grep related fixes. X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~1^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f62bd846552a090f3ba5e136d6d9cdb4c07ed7be;p=emacs.git Grep related fixes. * etc/grep.txt: Add `eval' to the Local Variables section that emulates `grep-filter'. * lisp/progmodes/grep.el (grep-filter): Avoid incomplete processing by keeping point where processing of grep matches begins, and continue to delete remaining escape sequences from the same point. (grep-filter): Make leading zero optional in "0?1;31m" because git-grep emits "\033[1;31m" escape sequences unlike expected "\033[01;31m" as GNU Grep does. (grep-process-setup): Replace obsolete "ml=" with newer "sl=". Fixes: debbugs:9408 --- diff --git a/etc/ChangeLog b/etc/ChangeLog index 24c0fd54422..0749862f676 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,8 @@ +2011-09-05 Juri Linkov + + * grep.txt: Add `eval' to the Local Variables section that + emulates `grep-filter'. + 2011-08-30 Paul Eggert * MACHINES: Remove obsolete info and update a bit (Bug#9404). diff --git a/etc/grep.txt b/etc/grep.txt index 9a3159f6b08..01ffa9f3ef8 100644 --- a/etc/grep.txt +++ b/etc/grep.txt @@ -103,5 +103,6 @@ COPYING PERMISSIONS: ;;; Local Variables: +;;; eval: (let ((inhibit-read-only t) (compilation-filter-start (point-min))) (save-excursion (goto-char (point-max)) (grep-filter) (set-buffer-modified-p nil))) ;;; buffer-read-only: t ;;; End: diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 59ecd1a3c12..d30010d6016 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2011-09-05 Juri Linkov + + * progmodes/grep.el (grep-filter): Avoid incomplete processing by + keeping point where processing of grep matches begins, and + continue to delete remaining escape sequences from the same point. + (grep-filter): Make leading zero optional in "0?1;31m" because + git-grep emits "\033[1;31m" escape sequences unlike expected + "\033[01;31m" as GNU Grep does (bug#9408). + (grep-process-setup): Replace obsolete "ml=" with newer "sl=". + 2011-09-05 Juri Linkov * subr.el (y-or-n-p): Capitalize "yes". diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 709f01444bf..eeebcc6648f 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -459,7 +459,7 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." ;; GREP_COLOR is used in GNU grep 2.5.1, but deprecated in later versions (setenv "GREP_COLOR" "01;31") ;; GREP_COLORS is used in GNU grep 2.5.2 and later versions - (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:ml=:cx=:ne")) + (setenv "GREP_COLORS" "mt=01;31:fn=:ln=:bn=:se=:sl=:cx=:ne")) (set (make-local-variable 'compilation-exit-message-function) (lambda (status code msg) (if (eq status 'exit) @@ -480,20 +480,21 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." This function is called from `compilation-filter-hook'." (save-excursion (forward-line 0) - (let ((end (point))) + (let ((end (point)) beg) (goto-char compilation-filter-start) (forward-line 0) + (setq beg (point)) ;; Only operate on whole lines so we don't get caught with part of an ;; escape sequence in one chunk and the rest in another. (when (< (point) end) (setq end (copy-marker end)) ;; Highlight grep matches and delete marking sequences. - (while (re-search-forward "\033\\[01;31m\\(.*?\\)\033\\[[0-9]*m" end 1) + (while (re-search-forward "\033\\[0?1;31m\\(.*?\\)\033\\[[0-9]*m" end 1) (replace-match (propertize (match-string 1) 'face nil 'font-lock-face grep-match-face) t t)) ;; Delete all remaining escape sequences - (goto-char compilation-filter-start) + (goto-char beg) (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1) (replace-match "" t t))))))