aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov2014-12-16 01:54:35 +0200
committerJuri Linkov2014-12-16 01:54:35 +0200
commitf2301ecc237858a029def9afaabe0fdf91591ebc (patch)
tree9c9da791fbe90c04c003746570d285a7feabfc79 /lisp/replace.el
parent10ec0468dfbc0815a772cc46a031aca298af0985 (diff)
downloademacs-f2301ecc237858a029def9afaabe0fdf91591ebc.tar.gz
emacs-f2301ecc237858a029def9afaabe0fdf91591ebc.zip
Fix query-replace-regexp when using lisp expressions for replacement
* lisp/replace.el (query-replace-read-from): Use query-replace-compile-replacement only on the return value. Fixes: debbugs:19383
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 2c7ad19ea3b..fa6f11b262f 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -70,6 +70,8 @@ from Isearch by using a key sequence like `C-s C-s M-%'." "24.3")
70(defcustom query-replace-from-to-separator 70(defcustom query-replace-from-to-separator
71 (propertize 71 (propertize
72 (or (ignore-errors 72 (or (ignore-errors
73 ;; Ignore errors when attempt to autoload char-displayable-p
74 ;; fails while preparing to dump.
73 (if (char-displayable-p ?\u2192) " \u2192 " " -> ")) 75 (if (char-displayable-p ?\u2192) " \u2192 " " -> "))
74 " -> ") 76 " -> ")
75 'face 'minibuffer-prompt) 77 'face 'minibuffer-prompt)
@@ -142,6 +144,8 @@ The return value can also be a pair (FROM . TO) indicating that the user
142wants to replace FROM with TO." 144wants to replace FROM with TO."
143 (if query-replace-interactive 145 (if query-replace-interactive
144 (car (if regexp-flag regexp-search-ring search-ring)) 146 (car (if regexp-flag regexp-search-ring search-ring))
147 ;; Reevaluating will check char-displayable-p that is
148 ;; unavailable while preparing to dump.
145 (custom-reevaluate-setting 'query-replace-from-to-separator) 149 (custom-reevaluate-setting 'query-replace-from-to-separator)
146 (let* ((history-add-new-input nil) 150 (let* ((history-add-new-input nil)
147 (separator 151 (separator
@@ -179,8 +183,7 @@ wants to replace FROM with TO."
179 (cdar query-replace-defaults) regexp-flag)) 183 (cdar query-replace-defaults) regexp-flag))
180 (let* ((to (if (and (string-match separator from) 184 (let* ((to (if (and (string-match separator from)
181 (get-text-property (match-beginning 0) 'separator from)) 185 (get-text-property (match-beginning 0) 'separator from))
182 (query-replace-compile-replacement 186 (substring-no-properties from (match-end 0))))
183 (substring-no-properties from (match-end 0)) regexp-flag)))
184 (from (if to (substring-no-properties from 0 (match-beginning 0)) 187 (from (if to (substring-no-properties from 0 (match-beginning 0))
185 (substring-no-properties from)))) 188 (substring-no-properties from))))
186 (add-to-history query-replace-from-history-variable from nil t) 189 (add-to-history query-replace-from-history-variable from nil t)
@@ -198,7 +201,7 @@ wants to replace FROM with TO."
198 from 201 from
199 (add-to-history query-replace-to-history-variable to nil t) 202 (add-to-history query-replace-to-history-variable to nil t)
200 (add-to-history 'query-replace-defaults (cons from to) nil t) 203 (add-to-history 'query-replace-defaults (cons from to) nil t)
201 (cons from to))))))) 204 (cons from (query-replace-compile-replacement to regexp-flag))))))))
202 205
203(defun query-replace-compile-replacement (to regexp-flag) 206(defun query-replace-compile-replacement (to regexp-flag)
204 "Maybe convert a regexp replacement TO to Lisp. 207 "Maybe convert a regexp replacement TO to Lisp.