aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2019-12-26 17:39:48 +0200
committerDmitry Gutov2019-12-26 17:39:48 +0200
commitccd7cd2c51c8a3755b084f93ae3a66a3df8a42f0 (patch)
treee15002d812d5469fc0aad5b8486ba37496bf82b8
parent7edb1f0773ddeade0f82630ab7697a3eb0f3bc4b (diff)
downloademacs-ccd7cd2c51c8a3755b084f93ae3a66a3df8a42f0.tar.gz
emacs-ccd7cd2c51c8a3755b084f93ae3a66a3df8a42f0.zip
Speed up dired-do-find-regexp
* lisp/dired-aux.el (dired-do-find-regexp): Speed up (bug#36857). Previously, 'find' was called for every marked file (for plain files and directories both). Now 'find' is only called for directories.
-rw-r--r--lisp/dired-aux.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index fb1ad6266d6..ce967b0735f 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -2957,6 +2957,8 @@ with the command \\[tags-loop-continue]."
2957 2957
2958(declare-function xref--show-xrefs "xref") 2958(declare-function xref--show-xrefs "xref")
2959(declare-function xref-query-replace-in-results "xref") 2959(declare-function xref-query-replace-in-results "xref")
2960(declare-function project--files-in-directory "project")
2961(declare-function project--find-regexp-in-files "project")
2960 2962
2961;;;###autoload 2963;;;###autoload
2962(defun dired-do-find-regexp (regexp) 2964(defun dired-do-find-regexp (regexp)
@@ -2975,19 +2977,24 @@ REGEXP should use constructs supported by your local `grep' command."
2975 (require 'xref) 2977 (require 'xref)
2976 (defvar grep-find-ignored-files) 2978 (defvar grep-find-ignored-files)
2977 (declare-function rgrep-find-ignored-directories "grep" (dir)) 2979 (declare-function rgrep-find-ignored-directories "grep" (dir))
2978 (let* ((files (dired-get-marked-files nil nil nil nil t)) 2980 (let* ((marks (dired-get-marked-files nil nil nil nil t))
2979 (ignores (nconc (mapcar 2981 (ignores (nconc (mapcar
2980 #'file-name-as-directory 2982 #'file-name-as-directory
2981 (rgrep-find-ignored-directories default-directory)) 2983 (rgrep-find-ignored-directories default-directory))
2982 grep-find-ignored-files)) 2984 grep-find-ignored-files))
2983 (fetcher 2985 (fetcher
2984 (lambda () 2986 (lambda ()
2985 (let ((xrefs (mapcan 2987 (let (files xrefs)
2986 (lambda (file) 2988 (mapc
2987 (xref-collect-matches regexp "*" file 2989 (lambda (mark)
2988 (and (file-directory-p file) 2990 (if (file-directory-p mark)
2989 ignores))) 2991 (setq files (nconc
2990 files))) 2992 (project--files-in-directory mark ignores "*")
2993 files))
2994 (push mark files)))
2995 (nreverse marks))
2996 (setq xrefs
2997 (project--find-regexp-in-files regexp files))
2991 (unless xrefs 2998 (unless xrefs
2992 (user-error "No matches for: %s" regexp)) 2999 (user-error "No matches for: %s" regexp))
2993 xrefs)))) 3000 xrefs))))