How to modify write permission on current buffer in emacs?
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.
To change the read-only status of a buffer, use C-xC-q (toggle read-only-mode
). To change file permissions, you can run dired
on the file's directory (C-xd), search for the file by C-s and use M to change its mode.
If the workflow requires to change the file permission of the buffer repeatedly, then having a custom function would help like the following.
This works only on unix machines(executes system command "chmod"
(defun chmod-plus-w ()
(interactive)
(shell-command-to-string (concat "chmod +w " (buffer-file-name (current-buffer))))
(revert-buffer))