Is there a standard function to create an Emacs buffer in which we cannot type anything in (i.e. cannot be edited) but any running Elisp code can make changes to the buffer

The following code does not work.

(get-buffer-create "foo")
(set-buffer "foo")
(insert "Hello world")

Here, not only does the foo buffer becomes unwritable by me (by typing), even the insert function cannot write anything to it.

This can be useful for printing text to a buffer while some Elisp code is running, but cannot be accidentally edited if I have the buffer currently active.

1 Answer 1


C-hv inhibit-read-only


(let ((inhibit-read-only t))
  (insert "Hello world"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.