changeset 56304:31b76ccf08bf

(query-replace-interactive): Change type from boolean to choice. Add value `initial'. (query-replace-read-args): Handle value `initial' of query-replace-interactive.
author Juri Linkov <juri@jurta.org>
date Thu, 01 Jul 2004 09:58:44 +0000
parents d86ec00a8470
children dfe25471ec82
files lisp/replace.el
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/replace.el	Thu Jul 01 09:54:51 2004 +0000
+++ b/lisp/replace.el	Thu Jul 01 09:58:44 2004 +0000
@@ -38,8 +38,12 @@
 
 (defcustom query-replace-interactive nil
   "Non-nil means `query-replace' uses the last search string.
-That becomes the \"string to replace\"."
-  :type 'boolean
+That becomes the \"string to replace\".
+If value is `initial', the last search string is inserted into
+the minibuffer as an initial value for \"string to replace\"."
+  :type '(choice (const :tag "Off" nil)
+                 (const :tag "Initial content" initial)
+                 (other :tag "Use default value" t))
   :group 'matching)
 
 (defcustom query-replace-from-history-variable 'query-replace-history
@@ -70,16 +74,20 @@
   (unless noerror
     (barf-if-buffer-read-only))
   (let (from to)
-    (if query-replace-interactive
-	(setq from (car (if regexp-flag regexp-search-ring search-ring)))
+    (if (and query-replace-interactive
+             (not (eq query-replace-interactive 'initial)))
+        (setq from (car (if regexp-flag regexp-search-ring search-ring)))
       ;; The save-excursion here is in case the user marks and copies
       ;; a region in order to specify the minibuffer input.
       ;; That should not clobber the region for the query-replace itself.
       (save-excursion
-	(setq from (read-from-minibuffer (format "%s: " string)
-					 nil nil nil
-					 query-replace-from-history-variable
-					 nil t)))
+        (setq from (read-from-minibuffer
+                    (format "%s: " string)
+                    (if (eq query-replace-interactive 'initial)
+                        (car (if regexp-flag regexp-search-ring search-ring)))
+                    nil nil
+                    query-replace-from-history-variable
+                    nil t)))
       ;; Warn if user types \n or \t, but don't reject the input.
       (and regexp-flag
 	   (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from)
@@ -92,9 +100,10 @@
 	     (sit-for 2))))
 
     (save-excursion
-      (setq to (read-from-minibuffer (format "%s %s with: " string from)
-				     nil nil nil
-				     query-replace-to-history-variable from t)))
+      (setq to (read-from-minibuffer
+                (format "%s %s with: " string from)
+                nil nil nil
+                query-replace-to-history-variable from t)))
     (when (and regexp-flag
 	       (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))
       (let (pos list char)