[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#9226: 23.3; [rgrep]; (matches found) ?
From: |
Juri Linkov |
Subject: |
bug#9226: 23.3; [rgrep]; (matches found) ? |
Date: |
Wed, 17 Aug 2011 19:50:00 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
> Sounds like an improvement to me.
This patch below fixes the case you reported and also the case of
"find | xargs grep" because it checks the value of buffer-modified
set in `compilation-start', whereas empty output doesn't change it.
It still relies on unreliable heuristics, but I carefully tested it with
all known test cases and it displays correct messages in all of them.
Running grep on the dir with a file containing "test", I get the following
results (command and exit status message):
grep -inH -e "test" *
Grep finished (matches found)
grep -inH -e "testx" *
Grep finished with no matches found
grepx -inH -e "test" *
Grep exited abnormally with code 127
find . -exec grep -i test {} \;
Grep finished (matches found)
find . -exec grep -i testx {} \;
Grep finished with no matches found
find . -name testx -exec grep -i testx {} \;
Grep finished with no matches found
find . -print0 | xargs -0 -e grep -i -nH -e test
Grep finished (matches found)
find . -print0 | xargs -0 -e grep -i -nH -e testx
Grep finished with no matches found
=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el 2011-08-10 20:31:17 +0000
+++ lisp/progmodes/grep.el 2011-08-17 16:47:24 +0000
@@ -463,9 +463,9 @@ (defun grep-process-setup ()
(set (make-local-variable 'compilation-exit-message-function)
(lambda (status code msg)
(if (eq status 'exit)
- (cond ((zerop code)
+ (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)))