aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el29
1 files changed, 20 insertions, 9 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index c7fbcb5d99c..2c7ad19ea3b 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -67,11 +67,16 @@ That becomes the \"string to replace\".")
67to the minibuffer that reads the string to replace, or invoke replacements 67to the minibuffer that reads the string to replace, or invoke replacements
68from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") 68from Isearch by using a key sequence like `C-s C-s M-%'." "24.3")
69 69
70(defvar query-replace-from-to-separator 70(defcustom query-replace-from-to-separator
71 (propertize "\0" 71 (propertize
72 'display (propertize " \u2192 " 'face 'minibuffer-prompt) 72 (or (ignore-errors
73 'separator t) 73 (if (char-displayable-p ?\u2192) " \u2192 " " -> "))
74 "String that separates FROM and TO in the history of replacement pairs.") 74 " -> ")
75 'face 'minibuffer-prompt)
76 "String that separates FROM and TO in the history of replacement pairs."
77 :group 'matching
78 :type 'sexp
79 :version "25.1")
75 80
76(defcustom query-replace-from-history-variable 'query-replace-history 81(defcustom query-replace-from-history-variable 'query-replace-history
77 "History list to use for the FROM argument of `query-replace' commands. 82 "History list to use for the FROM argument of `query-replace' commands.
@@ -137,19 +142,25 @@ The return value can also be a pair (FROM . TO) indicating that the user
137wants to replace FROM with TO." 142wants to replace FROM with TO."
138 (if query-replace-interactive 143 (if query-replace-interactive
139 (car (if regexp-flag regexp-search-ring search-ring)) 144 (car (if regexp-flag regexp-search-ring search-ring))
145 (custom-reevaluate-setting 'query-replace-from-to-separator)
140 (let* ((history-add-new-input nil) 146 (let* ((history-add-new-input nil)
147 (separator
148 (when query-replace-from-to-separator
149 (propertize "\0"
150 'display query-replace-from-to-separator
151 'separator t)))
141 (query-replace-from-to-history 152 (query-replace-from-to-history
142 (append 153 (append
143 (when query-replace-from-to-separator 154 (when separator
144 (mapcar (lambda (from-to) 155 (mapcar (lambda (from-to)
145 (concat (query-replace-descr (car from-to)) 156 (concat (query-replace-descr (car from-to))
146 query-replace-from-to-separator 157 separator
147 (query-replace-descr (cdr from-to)))) 158 (query-replace-descr (cdr from-to))))
148 query-replace-defaults)) 159 query-replace-defaults))
149 (symbol-value query-replace-from-history-variable))) 160 (symbol-value query-replace-from-history-variable)))
150 (minibuffer-allow-text-properties t) ; separator uses text-properties 161 (minibuffer-allow-text-properties t) ; separator uses text-properties
151 (prompt 162 (prompt
152 (if (and query-replace-defaults query-replace-from-to-separator) 163 (if (and query-replace-defaults separator)
153 (format "%s (default %s): " prompt (car query-replace-from-to-history)) 164 (format "%s (default %s): " prompt (car query-replace-from-to-history))
154 (format "%s: " prompt))) 165 (format "%s: " prompt)))
155 (from 166 (from
@@ -166,7 +177,7 @@ wants to replace FROM with TO."
166 (cons (caar query-replace-defaults) 177 (cons (caar query-replace-defaults)
167 (query-replace-compile-replacement 178 (query-replace-compile-replacement
168 (cdar query-replace-defaults) regexp-flag)) 179 (cdar query-replace-defaults) regexp-flag))
169 (let* ((to (if (and (string-match query-replace-from-to-separator from) 180 (let* ((to (if (and (string-match separator from)
170 (get-text-property (match-beginning 0) 'separator from)) 181 (get-text-property (match-beginning 0) 'separator from))
171 (query-replace-compile-replacement 182 (query-replace-compile-replacement
172 (substring-no-properties from (match-end 0)) regexp-flag))) 183 (substring-no-properties from (match-end 0)) regexp-flag)))