How do I change read/write mode for a file using Emacs?

M-x read-only-mode

in very old versions of Emacs, the command was:

M-x toggle-read-only

On my Windows box, that amounts to Alt-x to bring up the meta prompt and typing “read-only-mode” to call the correct elisp function.

If you are using the default keyboard bindings,

C-x C-q

(which you read aloud as “Control-X Control-Q”) will have the same effect. Remember, however, given that emacs is essentially infinitely re-configurable, your mileage may vary.

Following up from the commentary: you should note that the writeable status of the buffer does not change the writeable permission of the file. If you try to write out to a read only file, you’ll see a confirmation message. However, if you own the file, you can write out your changes without changing the permissions on the file.

This is very convenient if you’d like to make a quick change to a file without having to go through the multiple steps of add write permission, write out changes, remove write permission. I tend to forget that last step, leaving potentially critical files open for accidental changes later on.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)