aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hansen2022-12-17 18:18:39 -0500
committerEli Zaretskii2022-12-24 09:12:12 +0200
commit823c49cea851158bc4db5ab133ecd9bf3d0791d7 (patch)
treefeaa94ac618b37db45b754abc8302752fe7877df
parent38c6abe4d0b6bc6b5dfc32ab7b9b5095adf82da0 (diff)
downloademacs-823c49cea851158bc4db5ab133ecd9bf3d0791d7.tar.gz
emacs-823c49cea851158bc4db5ab133ecd9bf3d0791d7.zip
; ert-x: Simplify `ert-with-test-buffer-selected'
* lisp/emacs-lisp/ert-x.el (ert-with-test-buffer-selected): Simplify using 'ert-with-test-buffer'. (Bug#60189)
-rw-r--r--lisp/emacs-lisp/ert-x.el28
1 files changed, 5 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 49f2a1d6965..5f1c5c26acd 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -115,29 +115,11 @@ of BODY, which makes it easier to use `execute-kbd-macro' to
115simulate user interaction. The window configuration is restored 115simulate user interaction. The window configuration is restored
116before returning, even if BODY exits nonlocally. The return 116before returning, even if BODY exits nonlocally. The return
117value is the last form in BODY." 117value is the last form in BODY."
118 (declare (debug ((":name" form) def-body)) 118 (declare (debug ((":name" form) body)) (indent 1))
119 (indent 1)) 119 `(ert-with-test-buffer (:name ,name)
120 (let ((ret (make-symbol "ert--with-test-buffer-selected-ret"))) 120 (save-window-excursion
121 `(save-window-excursion 121 (with-selected-window (display-buffer (current-buffer))
122 (let (,ret) 122 ,@body))))
123 (ert-with-test-buffer (:name ,name)
124 (with-current-buffer-window (current-buffer)
125 `(display-buffer-below-selected
126 (body-function
127 . ,(lambda (window)
128 (select-window window t)
129 ;; body-function is intended to initialize the
130 ;; contents of a temporary read-only buffer, so
131 ;; it is executed with some convenience
132 ;; changes. Undo those changes so that the
133 ;; test buffer behaves more like an ordinary
134 ;; buffer while the body executes.
135 (let ((inhibit-modification-hooks nil)
136 (inhibit-read-only nil)
137 (buffer-read-only nil))
138 (setq ,ret (progn ,@body))))))
139 nil))
140 ,ret))))
141 123
142;;;###autoload 124;;;###autoload
143(defun ert-kill-all-test-buffers () 125(defun ert-kill-all-test-buffers ()