diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2019-09-09 08:21:18 +0200 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2019-09-09 08:21:18 +0200 |
commit | 30c4f35a6fc8a6507930923766c3126ac1c2063f (patch) | |
tree | 59127e9f50d95fa2b1767674ec99203a41738960 /lisp/replace.el | |
parent | c596be08f71e8118ddaa3e330997716de4c109ab (diff) | |
download | emacs-30c4f35a6fc8a6507930923766c3126ac1c2063f.tar.gz emacs-30c4f35a6fc8a6507930923766c3126ac1c2063f.tar.bz2 emacs-30c4f35a6fc8a6507930923766c3126ac1c2063f.zip |
query-replace-regexp undo: Update next-replacement after undo
* lisp/replace.el (perform-replace):
Rename the local binding to not shadow next-replacement.
Update next-replacement after undo (Bug#37287).
* test/lisp/replace-tests.el (query-replace-undo-bug37287): Add test.
(query-replace-undo-bug37073): Tweak this test.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r-- | lisp/replace.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 0ddebb12704..dd24d8ba923 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -2584,7 +2584,7 @@ It must return a string." (num-replacements 0) (nocasify t) ; Undo must preserve case (Bug#31073). search-string - next-replacement) + last-replacement) (while (and (< stack-idx stack-len) stack (or (null replaced) last-was-act-and-show)) @@ -2595,9 +2595,9 @@ It must return a string." ;; Bind swapped values ;; (search-string <--> replacement) search-string (nth (if replaced 4 3) elt) - next-replacement (nth (if replaced 3 4) elt) + last-replacement (nth (if replaced 3 4) elt) search-string-replaced search-string - next-replacement-replaced next-replacement + last-replacement-replaced last-replacement last-was-act-and-show nil) (when (and (= stack-idx stack-len) @@ -2619,16 +2619,18 @@ It must return a string." (match-data t (nth 2 elt))) noedit (replace-match-maybe-edit - next-replacement nocasify literal + last-replacement nocasify literal noedit real-match-data backward) replace-count (1- replace-count) real-match-data (save-excursion (goto-char (match-beginning 0)) (if regexp-flag - (looking-at next-replacement) - (looking-at (regexp-quote next-replacement))) + (looking-at last-replacement) + (looking-at (regexp-quote last-replacement))) (match-data t (nth 2 elt)))) + (when regexp-flag + (setq next-replacement (nth 4 elt))) ;; Set replaced nil to keep in loop (when (eq def 'undo-all) (setq replaced nil |