aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el40
1 files changed, 23 insertions, 17 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index a825040a979..b96c883982e 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -79,15 +79,14 @@ That becomes the \"string to replace\".")
79to the minibuffer that reads the string to replace, or invoke replacements 79to the minibuffer that reads the string to replace, or invoke replacements
80from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") 80from Isearch by using a key sequence like `C-s C-s M-%'." "24.3")
81 81
82(defcustom query-replace-from-to-separator 82(defcustom query-replace-from-to-separator " → "
83 (propertize (if (char-displayable-p ?→) " → " " -> ") 83 "String that separates FROM and TO in the history of replacement pairs.
84 'face 'minibuffer-prompt) 84When nil, the pair will not be added to the history (same behavior
85 "String that separates FROM and TO in the history of replacement pairs." 85as in emacs 24.5)."
86 ;; Avoids error when attempt to autoload char-displayable-p fails
87 ;; while preparing to dump, also stops customize-rogue listing this.
88 :initialize 'custom-initialize-delay
89 :group 'matching 86 :group 'matching
90 :type '(choice string (sexp :tag "Display specification")) 87 :type '(choice
88 (const :tag "Disabled" nil)
89 string)
91 :version "25.1") 90 :version "25.1")
92 91
93(defcustom query-replace-from-history-variable 'query-replace-history 92(defcustom query-replace-from-history-variable 'query-replace-history
@@ -165,14 +164,18 @@ The return value can also be a pair (FROM . TO) indicating that the user
165wants to replace FROM with TO." 164wants to replace FROM with TO."
166 (if query-replace-interactive 165 (if query-replace-interactive
167 (car (if regexp-flag regexp-search-ring search-ring)) 166 (car (if regexp-flag regexp-search-ring search-ring))
168 ;; Reevaluating will check char-displayable-p that is
169 ;; unavailable while preparing to dump.
170 (custom-reevaluate-setting 'query-replace-from-to-separator)
171 (let* ((history-add-new-input nil) 167 (let* ((history-add-new-input nil)
172 (separator 168 (separator
173 (when query-replace-from-to-separator 169 (when query-replace-from-to-separator
174 (propertize "\0" 170 (propertize "\0"
175 'display query-replace-from-to-separator 171 'display
172 (propertize
173 (if (char-displayable-p
174 (string-to-char (replace-regexp-in-string
175 " " "" query-replace-from-to-separator)))
176 query-replace-from-to-separator
177 " -> ")
178 'face 'minibuffer-prompt)
176 'separator t))) 179 'separator t)))
177 (minibuffer-history 180 (minibuffer-history
178 (append 181 (append
@@ -185,9 +188,13 @@ wants to replace FROM with TO."
185 (symbol-value query-replace-from-history-variable))) 188 (symbol-value query-replace-from-history-variable)))
186 (minibuffer-allow-text-properties t) ; separator uses text-properties 189 (minibuffer-allow-text-properties t) ; separator uses text-properties
187 (prompt 190 (prompt
188 (if (and query-replace-defaults separator) 191 (cond ((and query-replace-defaults separator)
189 (format "%s (default %s): " prompt (car minibuffer-history)) 192 (format "%s (default %s): " prompt (car minibuffer-history)))
190 (format "%s: " prompt))) 193 (query-replace-defaults
194 (format "%s (default %s -> %s): " prompt
195 (query-replace-descr (caar query-replace-defaults))
196 (query-replace-descr (cdar query-replace-defaults))))
197 (t (format "%s: " prompt))))
191 (from 198 (from
192 ;; The save-excursion here is in case the user marks and copies 199 ;; The save-excursion here is in case the user marks and copies
193 ;; a region in order to specify the minibuffer input. 200 ;; a region in order to specify the minibuffer input.
@@ -200,8 +207,7 @@ wants to replace FROM with TO."
200 (if regexp-flag 207 (if regexp-flag
201 (read-regexp prompt nil 'minibuffer-history) 208 (read-regexp prompt nil 'minibuffer-history)
202 (read-from-minibuffer 209 (read-from-minibuffer
203 prompt nil nil nil nil 210 prompt nil nil nil nil (car search-ring) t)))))
204 (car (if regexp-flag regexp-search-ring search-ring)) t)))))
205 (to)) 211 (to))
206 (if (and (zerop (length from)) query-replace-defaults) 212 (if (and (zerop (length from)) query-replace-defaults)
207 (cons (caar query-replace-defaults) 213 (cons (caar query-replace-defaults)