Subject: 24.0.92; [PATCH] rgrep prunes too much

From: Wolfgang Jenkner <[email-masked]>
Date: Thu, 22 Dec 2011 06:00:07 +0100

In the shell, type:

$ rm -rf /tmp/foo/
$ mkdir -p /tmp/foo/usr.bin
$ echo xxx >/tmp/foo/bad.bin
$ echo xxx >/tmp/foo/usr.bin/good

Now, in emacs -Q, rgrep /tmp/foo for `xxx':

M-x r g r e p <return> x x x <return> <return> / t m p / f o o <return>

It will report "Grep finished with no matches found".

However, I expect it to find the match in /tmp/foo/usr.bin/good because
the way the defcustom of grep-find-ignored-files computes the default
value clearly shows that it is not meant to exclude directories.

(By the way, the FreeBSD base system source directory actually contains
a usr.bin sub-directory.)

See also bug#9414.  For a somewhat different proposal, Colin Fraizer's
message in bug#6665, but see Andreas Schwab's response.

2011-12-20  Wolfgang Jenkner  <[email-masked]>

	* lisp/progmodes/grep.el (rgrep): Tweak the find command line so
	that directories matching `grep-find-ignored-files' won't be
	pruned.

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2011-12-12 05:32:49 +0000
+++ lisp/progmodes/grep.el	2011-12-20 20:40:02 +0000
@@ -1018,7 +1018,8 @@
 				    (shell-quote-argument ")")
 				    " -prune -o "))
 		       (and grep-find-ignored-files
-			    (concat (shell-quote-argument "(")
+			    (concat (shell-quote-argument "!") " -type d "
+				    (shell-quote-argument "(")
 				    ;; we should use shell-quote-argument here
 				    " -name "
 				    (mapconcat