From: Juri Linkov Date: Mon, 22 Aug 2011 09:54:38 +0000 (+0300) Subject: * lisp/progmodes/grep.el (grep-process-setup): Use `buffer-modified-p' X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~70^2~15^2~13 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=262a14396ddccb01d20882345608e1f203cbe65b;p=emacs.git * lisp/progmodes/grep.el (grep-process-setup): Use `buffer-modified-p' to check for empty output. Fixes: debbugs:9226 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e8a6cd73826..bfcbaa27b6f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-08-22 Juri Linkov + + * progmodes/grep.el (grep-process-setup): Use `buffer-modified-p' + to check for empty output (bug#9226). + 2011-08-22 Chong Yidong * progmodes/scheme.el (scheme-mode-syntax-table): Don't use diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 31100f3fac2..709f01444bf 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -463,9 +463,12 @@ Set up `compilation-exit-message-function' and run `grep-setup-hook'." (set (make-local-variable 'compilation-exit-message-function) (lambda (status code msg) (if (eq status 'exit) - (cond ((zerop code) + ;; This relies on the fact that `compilation-start' + ;; sets buffer-modified to nil before running the command, + ;; so the buffer is still unmodified if there is no output. + (cond ((and (zerop code) (buffer-modified-p)) '("finished (matches found)\n" . "matched")) - ((= code 1) + ((or (= code 1) (not (buffer-modified-p))) '("finished with no matches found\n" . "no match")) (t (cons msg code)))