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
This commit is contained in:
Juri Linkov 2014-12-16 01:54:35 +02:00
parent 10ec0468df
commit f2301ecc23
2 changed files with 11 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2014-12-15 Juri Linkov <juri@linkov.net>
* replace.el (query-replace-read-from): Use query-replace-compile-replacement
only on the return value (bug#19383).
2014-12-15 Juri Linkov <juri@linkov.net>
* isearch.el (isearch-lazy-highlight-search): Extend the bound of

View file

@ -70,6 +70,8 @@ from Isearch by using a key sequence like `C-s C-s M-%'." "24.3")
(defcustom query-replace-from-to-separator
(propertize
(or (ignore-errors
;; Ignore errors when attempt to autoload char-displayable-p
;; fails while preparing to dump.
(if (char-displayable-p ?\u2192) " \u2192 " " -> "))
" -> ")
'face 'minibuffer-prompt)
@ -142,6 +144,8 @@ The return value can also be a pair (FROM . TO) indicating that the user
wants to replace FROM with TO."
(if query-replace-interactive
(car (if regexp-flag regexp-search-ring search-ring))
;; Reevaluating will check char-displayable-p that is
;; unavailable while preparing to dump.
(custom-reevaluate-setting 'query-replace-from-to-separator)
(let* ((history-add-new-input nil)
(separator
@ -179,8 +183,7 @@ wants to replace FROM with TO."
(cdar query-replace-defaults) regexp-flag))
(let* ((to (if (and (string-match separator from)
(get-text-property (match-beginning 0) 'separator from))
(query-replace-compile-replacement
(substring-no-properties from (match-end 0)) regexp-flag)))
(substring-no-properties from (match-end 0))))
(from (if to (substring-no-properties from 0 (match-beginning 0))
(substring-no-properties from))))
(add-to-history query-replace-from-history-variable from nil t)
@ -198,7 +201,7 @@ wants to replace FROM with TO."
from
(add-to-history query-replace-to-history-variable to nil t)
(add-to-history 'query-replace-defaults (cons from to) nil t)
(cons from to)))))))
(cons from (query-replace-compile-replacement to regexp-flag))))))))
(defun query-replace-compile-replacement (to regexp-flag)
"Maybe convert a regexp replacement TO to Lisp.