diff options
| author | Richard Hansen | 2022-12-17 18:18:39 -0500 |
|---|---|---|
| committer | Eli Zaretskii | 2022-12-24 09:12:12 +0200 |
| commit | 823c49cea851158bc4db5ab133ecd9bf3d0791d7 (patch) | |
| tree | feaa94ac618b37db45b754abc8302752fe7877df | |
| parent | 38c6abe4d0b6bc6b5dfc32ab7b9b5095adf82da0 (diff) | |
| download | emacs-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.el | 28 |
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 | |||
| 115 | simulate user interaction. The window configuration is restored | 115 | simulate user interaction. The window configuration is restored |
| 116 | before returning, even if BODY exits nonlocally. The return | 116 | before returning, even if BODY exits nonlocally. The return |
| 117 | value is the last form in BODY." | 117 | value 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 () |