From 30c4f35a6fc8a6507930923766c3126ac1c2063f Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Mon, 9 Sep 2019 08:21:18 +0200 Subject: 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. --- test/lisp/replace-tests.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index cd08a522e39..2a3f207e47b 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el @@ -463,7 +463,9 @@ Return the last evalled form in BODY." (should (replace-tests-with-undo input "theorem \\([0-9]+\\)" - "theorem \\\\ref{theo_\\1}" + '(replace-eval-replacement + replace-quote + (format "theorem \\\\ref{theo_%d}" (1+ (string-to-number (match-string 1))))) ((?\s . (1 2)) (?U . (3))) ?q (string= input (buffer-string))))) @@ -479,4 +481,18 @@ Return the last evalled form in BODY." ?q (string= expected (buffer-string)))))) +(ert-deftest query-replace-undo-bug37287 () + "Test for https://debbugs.gnu.org/37287 ." + (let ((input "foo-1\nfoo-2\nfoo-3") + (expected "foo-2\nfoo-2\nfoo-3")) + (should + (replace-tests-with-undo + input "\\([0-9]\\)" + '(replace-eval-replacement + replace-quote + (format "%d" (1+ (string-to-number (match-string 1))))) + ((?\s . (1 2 4)) (?U . (3))) + ?q + (string= expected (buffer-string)))))) + ;;; replace-tests.el ends here -- cgit v1.2.1