From f2301ecc237858a029def9afaabe0fdf91591ebc Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 16 Dec 2014 01:54:35 +0200 Subject: [PATCH] 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 --- lisp/ChangeLog | 5 +++++ lisp/replace.el | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5a0a62fef68..4f8631d5a7e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-12-15 Juri Linkov + + * replace.el (query-replace-read-from): Use query-replace-compile-replacement + only on the return value (bug#19383). + 2014-12-15 Juri Linkov * isearch.el (isearch-lazy-highlight-search): Extend the bound of 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") (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. -- 2.39.2