summaryrefslogtreecommitdiff
path: root/lisp/progmodes/grep.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2011-08-22 12:54:38 +0300
committerJuri Linkov <juri@jurta.org>2011-08-22 12:54:38 +0300
commit262a14396ddccb01d20882345608e1f203cbe65b (patch)
tree26090e596f6905dfe70f3d1d0d6b15cee40c38cf /lisp/progmodes/grep.el
parentf13f86fbf2a9bce1abc974a4b2f457183e963d3b (diff)
downloademacs-262a14396ddccb01d20882345608e1f203cbe65b.tar.gz
* lisp/progmodes/grep.el (grep-process-setup): Use `buffer-modified-p'
to check for empty output. Fixes: debbugs:9226
Diffstat (limited to 'lisp/progmodes/grep.el')
-rw-r--r--lisp/progmodes/grep.el7
1 files changed, 5 insertions, 2 deletions
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)))