From 2fa997c4869b1310601e1e08a33fd77ed655c2a4 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 18 Dec 2022 00:24:16 -0500 Subject: [PATCH] ; whitespace: Use the new `ert-with-buffer-selected' in tests Commit 286c48137f69fa96b80d197da90c69a42df604a3 added a new `ert-with-test-buffer-selected' macro. Use that macro in `whitespace-mode' tests to avoid code duplication. --- test/lisp/whitespace-tests.el | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el index e4a8a34801..9a9fb55e4f 100644 --- a/test/lisp/whitespace-tests.el +++ b/test/lisp/whitespace-tests.el @@ -42,13 +42,6 @@ whitespace-tests--with-test-buffer '(whitespace-mode 1)) ,@body))) -(defmacro whitespace--with-buffer-selected (buffer-or-name &rest body) - (declare (debug (form body)) (indent 1)) - `(save-window-excursion - (with-current-buffer (or ,buffer-or-name (current-buffer)) - (with-selected-window (display-buffer (current-buffer)) - ,@body)))) - (defun whitespace-tests--faceup (&rest lines) "Convenience wrapper around `faceup-test-font-lock-buffer'. Returns non-nil if the concatenated LINES match the current @@ -360,7 +353,7 @@ whitespace-tests--indirect-clone-breaks-base-markers (indirect (clone-indirect-buffer (buffer-name) nil))) (should (eq (marker-buffer whitespace-bob-marker) base)) (should (eq (marker-buffer whitespace-eob-marker) base)) - (whitespace--with-buffer-selected indirect + (ert-with-buffer-selected indirect ;; Mutate the indirect buffer to update its bob/eob markers. (execute-kbd-macro (kbd "z RET M-< a"))) ;; With Bug#59618, the above mutation would cause the base @@ -388,7 +381,7 @@ whitespace-tests--indirect-clone-markers ;; because the buffer should only be killed on success. (indirect (clone-indirect-buffer nil nil))) (whitespace-tests--check-markers base 2 4) - (whitespace--with-buffer-selected indirect + (ert-with-buffer-selected indirect (whitespace-tests--check-markers indirect 2 4) ;; Mutate the buffer to trigger `after-change-functions' and ;; thus `whitespace--update-bob-eob'. @@ -411,7 +404,7 @@ whitespace-tests--regular-clone-markers ;; the buffer should only be killed on success. (clone (clone-buffer))) (whitespace-tests--check-markers orig 2 4) - (whitespace--with-buffer-selected clone + (ert-with-buffer-selected clone (whitespace-tests--check-markers clone 2 4) (execute-kbd-macro (kbd "z RET M-< a")) (whitespace-tests--check-markers clone 1 8)) -- 2.39.0