diff options
| author | Sam Steingold | 2017-02-10 14:53:02 -0500 |
|---|---|---|
| committer | Sam Steingold | 2017-02-10 14:53:02 -0500 |
| commit | 59e7efe7bdfb384017d34265df3e6c15837b972e (patch) | |
| tree | 5eea2c7315c86d974b851265e13f6b1e4ba6715c | |
| parent | abcba32c262e575b562ec0e481e55538536f969f (diff) | |
| download | emacs-59e7efe7bdfb384017d34265df3e6c15837b972e.tar.gz emacs-59e7efe7bdfb384017d34265df3e6c15837b972e.zip | |
Extract grep-find-ignored-directories processing from rgrep-default-command
(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'.
| -rw-r--r-- | lisp/progmodes/grep.el | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 22d4f2abd98..b3d8a51ceeb 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -1045,6 +1045,15 @@ to specify a command to run." | |||
| 1045 | (if (eq next-error-last-buffer (current-buffer)) | 1045 | (if (eq next-error-last-buffer (current-buffer)) |
| 1046 | (setq default-directory dir))))))) | 1046 | (setq default-directory dir))))))) |
| 1047 | 1047 | ||
| 1048 | (defun rgrep-find-ignored-directories (dir) | ||
| 1049 | "Return the list of ignored directories applicable to `dir'." | ||
| 1050 | (delq nil (mapcar | ||
| 1051 | (lambda (ignore) | ||
| 1052 | (cond ((stringp ignore) ignore) | ||
| 1053 | ((consp ignore) | ||
| 1054 | (and (funcall (car ignore) dir) (cdr ignore))))) | ||
| 1055 | grep-find-ignored-directories))) | ||
| 1056 | |||
| 1048 | (defun rgrep-default-command (regexp files dir) | 1057 | (defun rgrep-default-command (regexp files dir) |
| 1049 | "Compute the command for \\[rgrep] to use by default." | 1058 | "Compute the command for \\[rgrep] to use by default." |
| 1050 | (require 'find-dired) ; for `find-name-arg' | 1059 | (require 'find-dired) ; for `find-name-arg' |
| @@ -1066,20 +1075,9 @@ to specify a command to run." | |||
| 1066 | (shell-quote-argument "(") | 1075 | (shell-quote-argument "(") |
| 1067 | ;; we should use shell-quote-argument here | 1076 | ;; we should use shell-quote-argument here |
| 1068 | " -path " | 1077 | " -path " |
| 1069 | (mapconcat | 1078 | (mapconcat (lambda (d) (shell-quote-argument (concat "*/" d))) |
| 1070 | 'identity | 1079 | (rgrep-find-ignored-directories dir) |
| 1071 | (delq nil (mapcar | 1080 | " -o -path ") |
| 1072 | #'(lambda (ignore) | ||
| 1073 | (cond ((stringp ignore) | ||
| 1074 | (shell-quote-argument | ||
| 1075 | (concat "*/" ignore))) | ||
| 1076 | ((consp ignore) | ||
| 1077 | (and (funcall (car ignore) dir) | ||
| 1078 | (shell-quote-argument | ||
| 1079 | (concat "*/" | ||
| 1080 | (cdr ignore))))))) | ||
| 1081 | grep-find-ignored-directories)) | ||
| 1082 | " -o -path ") | ||
| 1083 | " " | 1081 | " " |
| 1084 | (shell-quote-argument ")") | 1082 | (shell-quote-argument ")") |
| 1085 | " -prune -o ")) | 1083 | " -prune -o ")) |