Is it possible to change the write permissions on a file from inside emacs, without killing/re-opening the buffer?
Sometimes I forget to modify the permissions on a file before opening it. I can modify the permissions from inside emacs (M-! chmod u+w filename
) but this doesn't update the buffer which remains write protected and refuses to modify the file.
Is there a way to update permissions inside the buffer? Bonus point if I can assign this to a shortcut!
Best Answer
After changing the file mode, and before doing any edit, run
M-x revert-buffer
to reload the file. If the file is now writable, the buffer will no longer be read-only.Alternatively, type
C-x C-q
(read-only-mode
). This makes the buffer no longer read-only. You can edit and even save, but you'll get a confirmation prompt asking whether you want to overwrite the read-only file.