changeset 103787:fb68f473a020

(rgrep): Allow grep-find-ignored-directories to be a cons cell (test . ignored-directory) to selectively ignore some directories depending on the location of the search.
author Sam Steingold <sds@gnu.org>
date Wed, 08 Jul 2009 14:23:57 +0000
parents 02ba23495867
children b4588e2be166
files lisp/ChangeLog lisp/progmodes/grep.el
diffstat 2 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Jul 08 12:59:47 2009 +0000
+++ b/lisp/ChangeLog	Wed Jul 08 14:23:57 2009 +0000
@@ -1,3 +1,9 @@
+2009-07-08  Sam Steingold  <sds@gnu.org>
+
+	* progmodes/grep.el (rgrep): Allow grep-find-ignored-directories
+	to be a cons cell (test . ignored-directory) to selectively ignore
+	some directories depending on the location of the search.
+
 2009-07-08  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp.el (tramp-set-file-uid-gid): Handle the case the
--- a/lisp/progmodes/grep.el	Wed Jul 08 12:59:47 2009 +0000
+++ b/lisp/progmodes/grep.el	Wed Jul 08 14:23:57 2009 +0000
@@ -194,7 +194,9 @@
 
 (defcustom grep-find-ignored-directories
   vc-directory-exclusion-list
-  "*List of names of sub-directories which `rgrep' shall not recurse into."
+  "*List of names of sub-directories which `rgrep' shall not recurse into.
+If an element is a cons cell, the car is called on the search directory
+to determine whether cdr should not be recursed into."
   :type '(repeat string)
   :group 'grep)
 
@@ -891,11 +893,18 @@
 			    (concat (shell-quote-argument "(")
 				    ;; we should use shell-quote-argument here
 				    " -path "
-				    (mapconcat #'(lambda (dir)
-						   (shell-quote-argument
-						    (concat "*/" dir)))
-					       grep-find-ignored-directories
-					       " -o -path ")
+				    (mapconcat
+                                     #'(lambda (ignore)
+                                         (cond ((stringp ignore)
+                                                (shell-quote-argument
+                                                 (concat "*/" ignore)))
+                                               ((consp ignore)
+                                                (and (funcall (car ignore) dir)
+                                                     (shell-quote-argument
+                                                      (concat "*/"
+                                                              (cdr ignore)))))))
+                                     grep-find-ignored-directories
+                                     " -o -path ")
 				    " "
 				    (shell-quote-argument ")")
 				    " -prune -o ")))))