diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2019-08-19 17:32:09 +0200 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2019-08-19 17:32:09 +0200 |
commit | beb1d22260af2e03d80d34fcc1db212785a9d903 (patch) | |
tree | 04e6f0becdd395cba0f221bed564f2e5defe44fb /lisp | |
parent | 190565b2396d80178fc5f6757117540e3a1ae9e1 (diff) | |
download | emacs-beb1d22260af2e03d80d34fcc1db212785a9d903.tar.gz |
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')
-rw-r--r-- | lisp/replace.el | 7 |
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." (setq real-match-data (save-excursion (goto-char (match-beginning 0)) - (looking-at search-string) + ;; We must quote the string (Bug#37073) + (looking-at (regexp-quote search-string)) (match-data t (nth 2 elt))) noedit (replace-match-maybe-edit @@ -2624,7 +2625,9 @@ It must return a string." real-match-data (save-excursion (goto-char (match-beginning 0)) - (looking-at next-replacement) + (if regexp-flag + (looking-at next-replacement) + (looking-at (regexp-quote next-replacement))) (match-data t (nth 2 elt)))) ;; Set replaced nil to keep in loop (when (eq def 'undo-all) |