]> git.eshelyaron.com Git - emacs.git/commitdiff
Extract grep-find-ignored-directories processing from rgrep-default-command
authorSam Steingold <sds@gnu.org>
Fri, 10 Feb 2017 19:53:02 +0000 (14:53 -0500)
committerSam Steingold <sds@gnu.org>
Fri, 10 Feb 2017 19:53:02 +0000 (14:53 -0500)
(rgrep-find-ignored-directories): Extract from `rgrep-default-command'.
Some Emacs packages use `grep-find-ignored-directories' to ignore some
directories, so will use this function instead of custom code.
(rgrep-default-command): Use `rgrep-find-ignored-directories'.

lisp/progmodes/grep.el

index 22d4f2abd98d6c4ca76315d528721494a7fd488b..b3d8a51ceeb741c3de481ff1acc3b1ae48e5b314 100644 (file)
@@ -1045,6 +1045,15 @@ to specify a command to run."
          (if (eq next-error-last-buffer (current-buffer))
              (setq default-directory dir)))))))
 
+(defun rgrep-find-ignored-directories (dir)
+  "Return the list of ignored directories applicable to `dir'."
+  (delq nil (mapcar
+             (lambda (ignore)
+               (cond ((stringp ignore) ignore)
+                     ((consp ignore)
+                      (and (funcall (car ignore) dir) (cdr ignore)))))
+             grep-find-ignored-directories)))
+
 (defun rgrep-default-command (regexp files dir)
   "Compute the command for \\[rgrep] to use by default."
   (require 'find-dired)      ; for `find-name-arg'
@@ -1066,20 +1075,9 @@ to specify a command to run."
                  (shell-quote-argument "(")
                  ;; we should use shell-quote-argument here
                  " -path "
-                 (mapconcat
-                  'identity
-                  (delq nil (mapcar
-                             #'(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 ")
+                 (mapconcat (lambda (d) (shell-quote-argument (concat "*/" d)))
+                            (rgrep-find-ignored-directories dir)
+                            " -o -path ")
                  " "
                  (shell-quote-argument ")")
                  " -prune -o "))