aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorTino Calancha2019-08-19 17:32:09 +0200
committerTino Calancha2019-08-19 17:32:09 +0200
commitbeb1d22260af2e03d80d34fcc1db212785a9d903 (patch)
tree04e6f0becdd395cba0f221bed564f2e5defe44fb /lisp/replace.el
parent190565b2396d80178fc5f6757117540e3a1ae9e1 (diff)
downloademacs-beb1d22260af2e03d80d34fcc1db212785a9d903.tar.gz
emacs-beb1d22260af2e03d80d34fcc1db212785a9d903.zip
Fix query-replace-regexp undo feature
Ensure that non-regexp strings used with `looking-at' are quoted. * lisp/replace.el (perform-replace): Quote regexp (Bug#37073). * test/lisp/replace-tests.el (replace-tests-perform-replace-regexp-flag): New variable. (replace-tests-with-undo): Use it. (query-replace-undo-bug37073): Add tests.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 08feb8eae7e..0ddebb12704 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2614,7 +2614,8 @@ It must return a string."
2614 (setq real-match-data 2614 (setq real-match-data
2615 (save-excursion 2615 (save-excursion
2616 (goto-char (match-beginning 0)) 2616 (goto-char (match-beginning 0))
2617 (looking-at search-string) 2617 ;; We must quote the string (Bug#37073)
2618 (looking-at (regexp-quote search-string))
2618 (match-data t (nth 2 elt))) 2619 (match-data t (nth 2 elt)))
2619 noedit 2620 noedit
2620 (replace-match-maybe-edit 2621 (replace-match-maybe-edit
@@ -2624,7 +2625,9 @@ It must return a string."
2624 real-match-data 2625 real-match-data
2625 (save-excursion 2626 (save-excursion
2626 (goto-char (match-beginning 0)) 2627 (goto-char (match-beginning 0))
2627 (looking-at next-replacement) 2628 (if regexp-flag
2629 (looking-at next-replacement)
2630 (looking-at (regexp-quote next-replacement)))
2628 (match-data t (nth 2 elt)))) 2631 (match-data t (nth 2 elt))))
2629 ;; Set replaced nil to keep in loop 2632 ;; Set replaced nil to keep in loop
2630 (when (eq def 'undo-all) 2633 (when (eq def 'undo-all)