diff options
| author | Glenn Morris <rgm@gnu.org> | 2019-08-20 09:04:53 -0700 |
|---|---|---|
| committer | Glenn Morris <rgm@gnu.org> | 2019-08-20 09:04:53 -0700 |
| commit | af103ef3c9d6df07475e2b3a2f846246d7fd2a8b (patch) | |
| tree | a7e0a0cb7db56b68b8b3a0c3c29a6b90d61edff7 /test/lisp/replace-tests.el | |
| parent | 989c85e799b7c3a425d3d03f98ecd55d5cf76022 (diff) | |
| parent | 615cff42580a3521c1a4ea7c3ec467eb8259e1c7 (diff) | |
| download | emacs-af103ef3c9d6df07475e2b3a2f846246d7fd2a8b.tar.gz | |
Merge from origin/emacs-26
615cff4 (origin/emacs-26) Fix process filter documentation (Bug#13400)
beb1d22 Fix query-replace-regexp undo feature
# Conflicts:
# test/lisp/replace-tests.el
Diffstat (limited to 'test/lisp/replace-tests.el')
| -rw-r--r-- | test/lisp/replace-tests.el | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index c908d4e2a71..f7bf2d93658 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el @@ -411,6 +411,9 @@ Each element has the format: (defvar replace-tests-bind-read-string nil "A string to bind `read-string' and avoid the prompt.") +(defvar replace-tests-perform-replace-regexp-flag t + "Value for regexp-flag argument passed to `perform-replace' in undo tests.") + (defmacro replace-tests-with-undo (input from to char-nums def-chr &rest body) "Helper to test `query-replace' undo feature. INPUT is a string to insert in a temporary buffer. @@ -463,7 +466,7 @@ Return the last evalled form in BODY." ((symbol-function 'replace-highlight) (lambda (&rest _args) (string-match "[A-Z ]" "ForestGreen")))) - (perform-replace ,from ,to t t nil)) + (perform-replace ,from ,to t replace-tests-perform-replace-regexp-flag nil)) ,@body)))) (defun replace-tests--query-replace-undo (&optional comma) @@ -505,4 +508,26 @@ Return the last evalled form in BODY." input "a" "B" ((?\s . (1 2 3)) (?E . (4)) (?U . (5))) ?q (string= input (buffer-string)))))) +(ert-deftest query-replace-undo-bug37073 () + "Test for https://debbugs.gnu.org/37073 ." + (let ((input "theorem 1\ntheorem 2\ntheorem 3")) + (should + (replace-tests-with-undo + input "theorem \\([0-9]+\\)" + "theorem \\\\ref{theo_\\1}" + ((?\s . (1 2)) (?U . (3))) + ?q + (string= input (buffer-string))))) + ;; Now run a test with regexp-flag arg in `perform-replace' set to nil + (let ((input " ^theorem$ 1\n ^theorem$ 2\n ^theorem$ 3") + (replace-tests-perform-replace-regexp-flag nil) + (expected " theo 1\n ^theorem$ 2\n ^theorem$ 3")) + (should + (replace-tests-with-undo + input "^theorem$" + "theo" + ((?\s . (1 2 4)) (?U . (3))) + ?q + (string= expected (buffer-string)))))) + ;;; replace-tests.el ends here |
