8

I have a buffer in read-only mode.

Killing the buffer and reopening it does not do the job while restarting emacs does.

How to exit the read-only mode without restarting emacs?

3 Answers 3

15

Calling read-only-mode toggles between read-only and edit mode for the current buffer.

You can call this via M-x read-only-mode or with C-x C-q.

1
9

To add a bit to @Juancho's answer, which is correct:

The default value of read-only-mode depends on the buffer. In particular, if it is visiting a file, and if the file itself is read-only, then the default value of read-only-mode will be on.

You can toggle such a buffer, as @Juancho said, to turn off read-only-mode. But if you try to save the buffer after changing it you'll be prompted to confirm, like this:

File foo.el is write-protected; try to save anyway? (yes or no)

And if you answer yes you may be presented with an error such as this:

Opening output file: Permission denied, /path/to/foo.el
2
  • I don't observe this problem with GNU Emacs 24.3.1
    – Viesturs
    Nov 15, 2019 at 22:49
  • 2
    Dunno what you mean by "this problem". But note that I said you may be presented with an error such as this." Whether you do or not depends...
    – Drew
    Nov 15, 2019 at 22:54
4

I like very much to click on the buffer-read-only indicator % in the mode line for that purpose. It is marked with a red ellipse in the following Figure.

enter image description here

It just feels natural to toggle the read only state where it is indicated.

Note that you can also toggle the buffer-modified-p flag on the right side of the buffer-read-only flag. This is sometimes handy when you just want to kill a modified buffer avoiding backup copies.

0

Your Answer

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

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