diff options
Diffstat (limited to 'lisp/progmodes/grep.el')
-rw-r--r-- | lisp/progmodes/grep.el | 7 |
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))) |