diff options
author | Juri Linkov <juri@jurta.org> | 2008-07-24 00:09:01 +0000 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2008-07-24 00:09:01 +0000 |
commit | 67c18958a50592d2ed96487d3c92d13814a5f852 (patch) | |
tree | 64ed27b34cc5d0dbc3547f0793f8e31a660368de /lisp/filesets.el | |
parent | 1fbb8c2e7d23e83a5492e73e0208abf47bf5c95e (diff) | |
download | emacs-67c18958a50592d2ed96487d3c92d13814a5f852.tar.gz |
(filesets-commands): Add commands for "Isearch" and
"Isearch (regexp)". Replace `query-replace' and `query-replace-regexp'
with `perform-replace' using `filesets-cmd-query-replace-regexp-getargs'.
(filesets-run-cmd): Call `fn' only once if it is `multi-isearch-files'
or `multi-isearch-files-regexp'.
(filesets-cmd-query-replace-getargs): Call standard function
`query-replace-read-args' to read `query-replace' arguments.
Add `multi-query-replace-map'.
(filesets-cmd-query-replace-regexp-getargs)
(filesets-cmd-isearch-getargs): New functions.
Diffstat (limited to 'lisp/filesets.el')
-rw-r--r-- | lisp/filesets.el | 103 |
1 files changed, 57 insertions, 46 deletions
diff --git a/lisp/filesets.el b/lisp/filesets.el index 064cfbfb0e1..a8d70df36d5 100644 --- a/lisp/filesets.el +++ b/lisp/filesets.el @@ -565,12 +565,18 @@ including directory trees to the menu can take a lot of memory." :group 'filesets) (defcustom filesets-commands - `(("Query Replace" - query-replace + `(("Isearch" + multi-isearch-files + (filesets-cmd-isearch-getargs)) + ("Isearch (regexp)" + multi-isearch-files-regexp + (filesets-cmd-isearch-getargs)) + ("Query Replace" + perform-replace (filesets-cmd-query-replace-getargs)) ("Query Replace (regexp)" - query-replace-regexp - (filesets-cmd-query-replace-getargs)) + perform-replace + (filesets-cmd-query-replace-regexp-getargs)) ("Grep <<selection>>" "grep" ("-n " filesets-get-quoted-selection " " "<<file-name>>")) @@ -1623,38 +1629,40 @@ Replace <file-name> or <<file-name>> with filename." (when files (let ((fn (filesets-cmd-get-fn cmd-name)) (args (filesets-cmd-get-args cmd-name))) - (dolist (this files nil) - (save-excursion - (save-restriction - (let ((buffer (filesets-find-file this))) - (when buffer - (goto-char (point-min)) - (let () - (cond - ((stringp fn) - (let* ((args - (let ((txt "")) - (dolist (this args txt) - (setq txt - (concat txt - (filesets-run-cmd--repl-fn - this - (lambda (this) - (if (equal txt "") "" " ") - (format "%s" this)))))))) - (cmd (concat fn " " args))) - (filesets-cmd-show-result - cmd (shell-command-to-string cmd)))) - ((symbolp fn) - (let ((args - (let ((argl nil)) - (dolist (this args argl) - (setq argl - (append argl - (filesets-run-cmd--repl-fn - this - 'list))))))) - (apply fn args)))))))))))))))) + (if (memq fn '(multi-isearch-files multi-isearch-files-regexp)) + (apply fn args) + (dolist (this files nil) + (save-excursion + (save-restriction + (let ((buffer (filesets-find-file this))) + (when buffer + (goto-char (point-min)) + (let () + (cond + ((stringp fn) + (let* ((args + (let ((txt "")) + (dolist (this args txt) + (setq txt + (concat txt + (filesets-run-cmd--repl-fn + this + (lambda (this) + (if (equal txt "") "" " ") + (format "%s" this)))))))) + (cmd (concat fn " " args))) + (filesets-cmd-show-result + cmd (shell-command-to-string cmd)))) + ((symbolp fn) + (let ((args + (let ((argl nil)) + (dolist (this args argl) + (setq argl + (append argl + (filesets-run-cmd--repl-fn + this + 'list))))))) + (apply fn args))))))))))))))))) (defun filesets-get-cmd-menu () "Create filesets command menu." @@ -1668,16 +1676,19 @@ Replace <file-name> or <<file-name>> with filename." ;;; sample commands (defun filesets-cmd-query-replace-getargs () "Get arguments for `query-replace' and `query-replace-regexp'." - (let* ((from-string (read-string "Filesets query replace: " - "" - 'query-replace-history)) - (to-string (read-string - (format "Filesets query replace %s with: " from-string) - "" - 'query-replace-history)) - (delimited (y-or-n-p - "Filesets query replace: respect word boundaries? "))) - (list from-string to-string delimited))) + (let ((common (query-replace-read-args "Filesets query replace" nil t))) + (list (nth 0 common) (nth 1 common) t nil (nth 2 common) nil + multi-query-replace-map))) + +(defun filesets-cmd-query-replace-regexp-getargs () + "Get arguments for `query-replace' and `query-replace-regexp'." + (let ((common (query-replace-read-args "Filesets query replace" t t))) + (list (nth 0 common) (nth 1 common) t t (nth 2 common) nil + multi-query-replace-map))) + +(defun filesets-cmd-isearch-getargs () + "Get arguments for `multi-isearch-files' and `multi-isearch-files-regexp'." + (list files)) (defun filesets-cmd-shell-command-getargs () "Get arguments for `filesets-cmd-shell-command'." |