From 262a14396ddccb01d20882345608e1f203cbe65b Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 22 Aug 2011 12:54:38 +0300 Subject: [PATCH] * lisp/progmodes/grep.el (grep-process-setup): Use `buffer-modified-p' to check for empty output. Fixes: debbugs:9226 --- lisp/ChangeLog | 5 +++++ lisp/progmodes/grep.el | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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))) -- 2.39.2