all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Subject: dired-do-query-replace-regexp (was: Copyright notices)
Date: Thu, 04 Aug 2005 22:59:33 +0300	[thread overview]
Message-ID: <874qa5h3wu.fsf_-_@jurta.org> (raw)
In-Reply-To: <87irylk2gh.fsf@jurta.org> (Juri Linkov's message of "Thu, 04 Aug 2005 20:06:15 +0300")

> 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/

      reply	other threads:[~2005-08-04 19:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-29 13:54 Copyright notices Richard M. Stallman
2005-07-29 18:10 ` Thien-Thi Nguyen
2005-07-29 21:43 ` Nick Roberts
2005-07-30 15:16   ` Richard M. Stallman
2005-07-31  0:36     ` Nick Roberts
2005-07-31 15:20       ` Stefan Monnier
2005-08-01 14:19         ` Richard M. Stallman
2005-08-01  0:45       ` Richard M. Stallman
     [not found]         ` <17134.56687.951950.51407@farnswood.snap.net.nz>
2005-08-02 17:45           ` Richard M. Stallman
2005-08-04 17:06           ` Juri Linkov
2005-08-04 19:59             ` Juri Linkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874qa5h3wu.fsf_-_@jurta.org \
    --to=juri@jurta.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.