1

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")
(read-only-mode)
(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.

4

C-hv inhibit-read-only

e.g.:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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