From: Stefan Monnier Date: Thu, 12 May 2011 15:10:17 +0000 (-0300) Subject: * lisp/progmodes/grep.el (grep-filter): Don't trip on partial lines. X-Git-Tag: emacs-pretest-24.0.90~104^2~618^2~294 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c89be45f2e6a1deed1204124fd2997002ed41a67;p=emacs.git * lisp/progmodes/grep.el (grep-filter): Don't trip on partial lines. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bac4931f4eb..5204622f641 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2011-05-12 Stefan Monnier + * progmodes/grep.el (grep-filter): Don't trip on partial lines. + * shell.el (shell-completion-vars): New function. (shell-mode): * simple.el (read-shell-command): Use it. diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 12295efc2d1..143220ad28a 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -476,17 +476,23 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." "Handle match highlighting escape sequences inserted by the grep process. This function is called from `compilation-filter-hook'." (save-excursion - (let ((end (point-marker))) - ;; Highlight grep matches and delete marking sequences. + (forward-line 0) + (let ((end (point))) (goto-char compilation-filter-start) - (while (re-search-forward "\033\\[01;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) - (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1) - (replace-match "" t t))))) + (forward-line 0) + ;; 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) + (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) + (while (re-search-forward "\033\\[[0-9;]*[mK]" end 1) + (replace-match "" t t)))))) (defun grep-probe (command args &optional func result) (let (process-file-side-effects)