From eb8e5828d3fb6917943b4f81a20a1584d3c784d9 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 26 Sep 2022 17:07:52 -0400 Subject: [PATCH 1/2] ert-x: Improve realism of `ert-with-test-buffer-selected' * 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index f00f1b33d7..bfd796586d 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -126,7 +126,15 @@ ert-with-test-buffer-selected (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)))) -- 2.37.3