How to modify write permission on current buffer in emacs?
Clash Royale CLAN TAG#URR8PPP
up vote
14
down vote
favorite
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!
permissions emacs
add a comment |
up vote
14
down vote
favorite
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!
permissions emacs
add a comment |
up vote
14
down vote
favorite
up vote
14
down vote
favorite
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!
permissions emacs
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!
permissions emacs
permissions emacs
asked Sep 10 '12 at 16:04
rahmu
10.1k1968110
10.1k1968110
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
13
down vote
accepted
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.
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
add a comment |
up vote
8
down vote
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.
2
Apparently, you've misseddired-jump
(normally bound toC-x C-j
). It runsdired
and jumps to the line for the file you're editing.
– cjm
Sep 10 '12 at 16:33
2
@cjm: It does not work for me unless I loaddired-x
.
– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload fordired-jump
about 20 years ago. I recommend it.
– cjm
Sep 10 '12 at 17:04
Annoyinglytoggle-read-only
has been replaced withread-only-mode
, although the binding is the same.
– Charlie Martin
Jul 19 at 21:47
add a comment |
up vote
0
down vote
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))
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
13
down vote
accepted
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.
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
add a comment |
up vote
13
down vote
accepted
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.
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
add a comment |
up vote
13
down vote
accepted
up vote
13
down vote
accepted
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.
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.
edited Nov 20 at 16:37
answered Sep 10 '12 at 22:45
Gilles
522k12610401570
522k12610401570
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
add a comment |
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
While C-x C-q still works, as of emacs 24.3 it now calls read-only-mode rather than toggle-read-only and toggle-read-only has been disabled.
– Paul Rubel
Nov 20 at 16:13
add a comment |
up vote
8
down vote
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.
2
Apparently, you've misseddired-jump
(normally bound toC-x C-j
). It runsdired
and jumps to the line for the file you're editing.
– cjm
Sep 10 '12 at 16:33
2
@cjm: It does not work for me unless I loaddired-x
.
– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload fordired-jump
about 20 years ago. I recommend it.
– cjm
Sep 10 '12 at 17:04
Annoyinglytoggle-read-only
has been replaced withread-only-mode
, although the binding is the same.
– Charlie Martin
Jul 19 at 21:47
add a comment |
up vote
8
down vote
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.
2
Apparently, you've misseddired-jump
(normally bound toC-x C-j
). It runsdired
and jumps to the line for the file you're editing.
– cjm
Sep 10 '12 at 16:33
2
@cjm: It does not work for me unless I loaddired-x
.
– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload fordired-jump
about 20 years ago. I recommend it.
– cjm
Sep 10 '12 at 17:04
Annoyinglytoggle-read-only
has been replaced withread-only-mode
, although the binding is the same.
– Charlie Martin
Jul 19 at 21:47
add a comment |
up vote
8
down vote
up vote
8
down vote
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.
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.
edited Jul 20 at 0:17
Jeff Schaller
36.4k952120
36.4k952120
answered Sep 10 '12 at 16:23
choroba
25.8k44470
25.8k44470
2
Apparently, you've misseddired-jump
(normally bound toC-x C-j
). It runsdired
and jumps to the line for the file you're editing.
– cjm
Sep 10 '12 at 16:33
2
@cjm: It does not work for me unless I loaddired-x
.
– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload fordired-jump
about 20 years ago. I recommend it.
– cjm
Sep 10 '12 at 17:04
Annoyinglytoggle-read-only
has been replaced withread-only-mode
, although the binding is the same.
– Charlie Martin
Jul 19 at 21:47
add a comment |
2
Apparently, you've misseddired-jump
(normally bound toC-x C-j
). It runsdired
and jumps to the line for the file you're editing.
– cjm
Sep 10 '12 at 16:33
2
@cjm: It does not work for me unless I loaddired-x
.
– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload fordired-jump
about 20 years ago. I recommend it.
– cjm
Sep 10 '12 at 17:04
Annoyinglytoggle-read-only
has been replaced withread-only-mode
, although the binding is the same.
– Charlie Martin
Jul 19 at 21:47
2
2
Apparently, you've missed
dired-jump
(normally bound to C-x C-j
). It runs dired
and jumps to the line for the file you're editing.– cjm
Sep 10 '12 at 16:33
Apparently, you've missed
dired-jump
(normally bound to C-x C-j
). It runs dired
and jumps to the line for the file you're editing.– cjm
Sep 10 '12 at 16:33
2
2
@cjm: It does not work for me unless I load
dired-x
.– choroba
Sep 10 '12 at 16:47
@cjm: It does not work for me unless I load
dired-x
.– choroba
Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload for
dired-jump
about 20 years ago. I recommend it.– cjm
Sep 10 '12 at 17:04
Sorry, I'd forgotten that I'd set up an autoload for
dired-jump
about 20 years ago. I recommend it.– cjm
Sep 10 '12 at 17:04
Annoyingly
toggle-read-only
has been replaced with read-only-mode
, although the binding is the same.– Charlie Martin
Jul 19 at 21:47
Annoyingly
toggle-read-only
has been replaced with read-only-mode
, although the binding is the same.– Charlie Martin
Jul 19 at 21:47
add a comment |
up vote
0
down vote
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))
add a comment |
up vote
0
down vote
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))
add a comment |
up vote
0
down vote
up vote
0
down vote
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))
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))
answered Jul 27 at 9:07
Talespin_Kit
16517
16517
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f47724%2fhow-to-modify-write-permission-on-current-buffer-in-emacs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown