aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov2004-07-01 10:01:32 +0000
committerJuri Linkov2004-07-01 10:01:32 +0000
commit0ec4febda2d72e79bd90ab25bada4f8b34f4ab54 (patch)
tree1a946ca27eba29a6a9e095011067a6ce82007495 /lisp/replace.el
parent74820eb5215e5e21f084c70e7770e0a04c1f6033 (diff)
downloademacs-0ec4febda2d72e79bd90ab25bada4f8b34f4ab54.tar.gz
emacs-0ec4febda2d72e79bd90ab25bada4f8b34f4ab54.zip
(query-replace-interactive): Change type from boolean
to choice. Add value `initial'. (query-replace-read-args): Handle value `initial' of query-replace-interactive.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el31
1 files changed, 20 insertions, 11 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index c2305cdecc6..cac4470c9cd 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -38,8 +38,12 @@
38 38
39(defcustom query-replace-interactive nil 39(defcustom query-replace-interactive nil
40 "Non-nil means `query-replace' uses the last search string. 40 "Non-nil means `query-replace' uses the last search string.
41That becomes the \"string to replace\"." 41That becomes the \"string to replace\".
42 :type 'boolean 42If value is `initial', the last search string is inserted into
43the minibuffer as an initial value for \"string to replace\"."
44 :type '(choice (const :tag "Off" nil)
45 (const :tag "Initial content" initial)
46 (other :tag "Use default value" t))
43 :group 'matching) 47 :group 'matching)
44 48
45(defcustom query-replace-from-history-variable 'query-replace-history 49(defcustom query-replace-from-history-variable 'query-replace-history
@@ -70,16 +74,20 @@ strings or patterns."
70 (unless noerror 74 (unless noerror
71 (barf-if-buffer-read-only)) 75 (barf-if-buffer-read-only))
72 (let (from to) 76 (let (from to)
73 (if query-replace-interactive 77 (if (and query-replace-interactive
74 (setq from (car (if regexp-flag regexp-search-ring search-ring))) 78 (not (eq query-replace-interactive 'initial)))
79 (setq from (car (if regexp-flag regexp-search-ring search-ring)))
75 ;; The save-excursion here is in case the user marks and copies 80 ;; The save-excursion here is in case the user marks and copies
76 ;; a region in order to specify the minibuffer input. 81 ;; a region in order to specify the minibuffer input.
77 ;; That should not clobber the region for the query-replace itself. 82 ;; That should not clobber the region for the query-replace itself.
78 (save-excursion 83 (save-excursion
79 (setq from (read-from-minibuffer (format "%s: " string) 84 (setq from (read-from-minibuffer
80 nil nil nil 85 (format "%s: " string)
81 query-replace-from-history-variable 86 (if (eq query-replace-interactive 'initial)
82 nil t))) 87 (car (if regexp-flag regexp-search-ring search-ring)))
88 nil nil
89 query-replace-from-history-variable
90 nil t)))
83 ;; Warn if user types \n or \t, but don't reject the input. 91 ;; Warn if user types \n or \t, but don't reject the input.
84 (and regexp-flag 92 (and regexp-flag
85 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) 93 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from)
@@ -92,9 +100,10 @@ strings or patterns."
92 (sit-for 2)))) 100 (sit-for 2))))
93 101
94 (save-excursion 102 (save-excursion
95 (setq to (read-from-minibuffer (format "%s %s with: " string from) 103 (setq to (read-from-minibuffer
96 nil nil nil 104 (format "%s %s with: " string from)
97 query-replace-to-history-variable from t))) 105 nil nil nil
106 query-replace-to-history-variable from t)))
98 (when (and regexp-flag 107 (when (and regexp-flag
99 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)) 108 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))
100 (let (pos list char) 109 (let (pos list char)