; 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)
This commit is contained in:
Richard Hansen 2022-12-17 18:18:39 -05:00 committed by Eli Zaretskii
parent 38c6abe4d0
commit 823c49cea8

View file

@ -115,29 +115,11 @@ of BODY, which makes it easier to use `execute-kbd-macro' to
simulate user interaction. The window configuration is restored simulate user interaction. The window configuration is restored
before returning, even if BODY exits nonlocally. The return before returning, even if BODY exits nonlocally. The return
value is the last form in BODY." value is the last form in BODY."
(declare (debug ((":name" form) def-body)) (declare (debug ((":name" form) body)) (indent 1))
(indent 1)) `(ert-with-test-buffer (:name ,name)
(let ((ret (make-symbol "ert--with-test-buffer-selected-ret"))) (save-window-excursion
`(save-window-excursion (with-selected-window (display-buffer (current-buffer))
(let (,ret) ,@body))))
(ert-with-test-buffer (:name ,name)
(with-current-buffer-window (current-buffer)
`(display-buffer-below-selected
(body-function
. ,(lambda (window)
(select-window window t)
;; body-function is intended to initialize the
;; contents of a temporary read-only buffer, so
;; it is executed with some convenience
;; changes. Undo those changes so that the
;; test buffer behaves more like an ordinary
;; buffer while the body executes.
(let ((inhibit-modification-hooks nil)
(inhibit-read-only nil)
(buffer-read-only nil))
(setq ,ret (progn ,@body))))))
nil))
,ret))))
;;;###autoload ;;;###autoload
(defun ert-kill-all-test-buffers () (defun ert-kill-all-test-buffers ()