Commit ccd7cd2c authored by Dmitry Gutov's avatar Dmitry Gutov

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
parent 7edb1f07
Pipeline #4403 failed with stage
in 62 minutes and 8 seconds
......@@ -2957,6 +2957,8 @@ with the command \\[tags-loop-continue]."
(declare-function xref--show-xrefs "xref")
(declare-function xref-query-replace-in-results "xref")
(declare-function project--files-in-directory "project")
(declare-function project--find-regexp-in-files "project")
(defun dired-do-find-regexp (regexp)
......@@ -2975,19 +2977,24 @@ REGEXP should use constructs supported by your local `grep' command."
(require 'xref)
(defvar grep-find-ignored-files)
(declare-function rgrep-find-ignored-directories "grep" (dir))
(let* ((files (dired-get-marked-files nil nil nil nil t))
(let* ((marks (dired-get-marked-files nil nil nil nil t))
(ignores (nconc (mapcar
(rgrep-find-ignored-directories default-directory))
(lambda ()
(let ((xrefs (mapcan
(lambda (file)
(xref-collect-matches regexp "*" file
(and (file-directory-p file)
(let (files xrefs)
(lambda (mark)
(if (file-directory-p mark)
(setq files (nconc
(project--files-in-directory mark ignores "*")
(push mark files)))
(nreverse marks))
(setq xrefs
(project--find-regexp-in-files regexp files))
(unless xrefs
(user-error "No matches for: %s" regexp))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment