diff options
author | John Wiegley <johnw@newartisans.com> | 2016-01-18 22:59:51 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2016-01-18 22:59:51 -0800 |
commit | 1b76d9168336ede8976b980aeaed64ae2908501a (patch) | |
tree | 749e3c082a8575eee1888ba9e61e1aeaa70d0dbc /lisp/dired-aux.el | |
parent | bca49307c8ea3f96d6eede375a7f42091ae5d5af (diff) | |
parent | 2e5a89fad151f8efa97aea3f400823a95bee6289 (diff) | |
download | emacs-1b76d9168336ede8976b980aeaed64ae2908501a.tar.gz |
-
Diffstat (limited to 'lisp/dired-aux.el')
-rw-r--r-- | lisp/dired-aux.el | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index a678fca3ea3..ab10edeedbf 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2713,6 +2713,41 @@ with the command \\[tags-loop-continue]." (tags-query-replace from to delimited '(dired-get-marked-files nil nil 'dired-nondirectory-p))) +(declare-function xref--show-xrefs "xref") +(declare-function xref-query-replace "xref") + +;;;###autoload +(defun dired-do-find-regexp (regexp) + "Find all matches for REGEXP in all marked files, recursively." + (interactive "sSearch marked files (regexp): ") + (require 'grep) + (defvar grep-find-ignored-files) + (let* ((files (dired-get-marked-files)) + (ignores (nconc (mapcar + (lambda (s) (concat s "/")) + vc-directory-exclusion-list) + grep-find-ignored-files)) + (xrefs (cl-mapcan + (lambda (file) + (xref-collect-matches regexp "*" file + (and (file-directory-p file) + ignores))) + files))) + (unless xrefs + (user-error "No matches for: %s" regexp)) + (xref--show-xrefs xrefs nil t))) + +;;;###autoload +(defun dired-do-find-regexp-and-replace (from to) + "Replace matches of FROM with TO, in all marked files, recursively." + (interactive + (let ((common + (query-replace-read-args + "Query replace regexp in marked files" t t))) + (list (nth 0 common) (nth 1 common)))) + (with-current-buffer (dired-do-find-regexp from) + (xref-query-replace from to))) + (defun dired-nondirectory-p (file) (not (file-directory-p file))) |