> A good interface for mass-replacing is query-replace. You can just do > > M-x find-dired RET -name '*.el' RET t Q > > and use a function call like \,(copyright-fix-years \0) > in the replacement part.
BTW, currently `dired-do-query-replace-regexp' doesn't use query-replace history variables. It adds both from-string and to-string to the default history. The following patch allows it to use `query-replace-read-args' to read query-replace arguments. It also replaces too generic argument name `string' with `prompt'. Index: lisp/dired-aux.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v retrieving revision 1.135 diff -c -r1.135 dired-aux.el *** lisp/dired-aux.el 11 Jul 2005 04:24:46 -0000 1.135 --- lisp/dired-aux.el 4 Aug 2005 19:55:22 -0000 *************** *** 2208,2214 **** If you exit (\\[keyboard-quit], RET or q), you can resume the query replace with the command \\[tags-loop-continue]." (interactive ! "sQuery replace in marked files (regexp): \nsQuery replace %s by: \nP") (dolist (file (dired-get-marked-files nil nil 'dired-nondirectory-p)) (let ((buffer (get-file-buffer file))) (if (and buffer (with-current-buffer buffer --- 2210,2219 ---- If you exit (\\[keyboard-quit], RET or q), you can resume the query replace with the command \\[tags-loop-continue]." (interactive ! (let ((common ! (query-replace-read-args ! "Query replace regexp in marked files" t t))) ! (list (nth 0 common) (nth 1 common) (nth 2 common)))) (dolist (file (dired-get-marked-files nil nil 'dired-nondirectory-p)) (let ((buffer (get-file-buffer file))) (if (and buffer (with-current-buffer buffer Index: lisp/replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.220 diff -u -r1.220 replace.el --- lisp/replace.el 19 Jul 2005 11:41:20 -0000 1.220 +++ lisp/replace.el 4 Aug 2005 19:55:55 -0000 @@ -88,7 +88,7 @@ (defun query-replace-descr (string) (mapconcat 'isearch-text-char-description string "")) -(defun query-replace-read-from (string regexp-flag) +(defun query-replace-read-from (prompt regexp-flag) "Query and return the `from' argument of a query-replace operation. The return value can also be a pair (FROM . TO) indicating that the user wants to replace FROM with TO." @@ -107,10 +107,10 @@ query-replace-from-history-variable)))) (read-from-minibuffer (if (and lastto lastfrom) - (format "%s (default %s -> %s): " string + (format "%s (default %s -> %s): " prompt (query-replace-descr lastfrom) (query-replace-descr lastto)) - (format "%s: " string)) + (format "%s: " prompt)) nil nil nil query-replace-from-history-variable nil t t)))) @@ -173,22 +173,22 @@ to)) -(defun query-replace-read-to (from string regexp-flag) +(defun query-replace-read-to (from prompt regexp-flag) "Query and return the `to' argument of a query-replace operation." (query-replace-compile-replacement (save-excursion (read-from-minibuffer - (format "%s %s with: " string (query-replace-descr from)) + (format "%s %s with: " prompt (query-replace-descr from)) nil nil nil query-replace-to-history-variable from t t)) regexp-flag)) -(defun query-replace-read-args (string regexp-flag &optional noerror) +(defun query-replace-read-args (prompt regexp-flag &optional noerror) (unless noerror (barf-if-buffer-read-only)) - (let* ((from (query-replace-read-from string regexp-flag)) + (let* ((from (query-replace-read-from prompt regexp-flag)) (to (if (consp from) (prog1 (cdr from) (setq from (car from))) - (query-replace-read-to from string regexp-flag)))) + (query-replace-read-to from prompt regexp-flag)))) (list from to current-prefix-arg))) (defun query-replace (from-string to-string &optional delimited start end) -- Juri Linkov http://www.jurta.org/emacs/ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel