1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

Make dired-toggle-read-only query on read-only directories

* lisp/dired.el (dired-toggle-read-only): Query instead of
erroring out immediately (bug#29412).
This commit is contained in:
Lars Ingebrigtsen 2020-12-13 14:17:55 +01:00
parent 1c115e404e
commit f7133be7ae

View File

@ -2419,8 +2419,10 @@ If the current buffer can be edited with Wdired, (i.e. the major
mode is `dired-mode'), call `wdired-change-to-wdired-mode'.
Otherwise, toggle `read-only-mode'."
(interactive)
(unless (file-writable-p default-directory)
(user-error "Directory %s isn't writeable" default-directory))
(when (and (not (file-writable-p default-directory))
(not (y-or-n-p
"Directory isn't writable; edit anyway? ")))
(user-error "Directory %s isn't writable" default-directory))
(if (derived-mode-p 'dired-mode)
(wdired-change-to-wdired-mode)
(read-only-mode 'toggle)))