]> git.eshelyaron.com Git - emacs.git/commitdiff
ert-x: Improve realism of `ert-with-test-buffer-selected'
authorRichard Hansen <rhansen@rhansen.org>
Mon, 26 Sep 2022 21:07:52 +0000 (17:07 -0400)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 27 Sep 2022 11:43:53 +0000 (13:43 +0200)
* lisp/emacs-lisp/ert-x.el (ert-with-test-buffer-selected): Set
`inhibit-read-only' and `buffer-read-only' to nil when executing the
body to provide a more realistic test environment.

lisp/emacs-lisp/ert-x.el

index f00f1b33d7849364d6c71b2495fa9e796fb3e338..bfd796586da1e24af31844dbcdea9b7d354ecca0 100644 (file)
@@ -126,7 +126,15 @@ value is the last form in BODY."
                  (body-function
                   . ,(lambda (window)
                        (select-window window t)
-                       (let ((inhibit-modification-hooks nil))
+                       ;; 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))))