From: Lars Ingebrigtsen Date: Sat, 12 Dec 2020 11:32:15 +0000 (+0100) Subject: Make dired-toggle-read-only check whether the directory is writable X-Git-Tag: emacs-28.0.90~4764 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f6cafe657402805f21a9651071f9768f92dacc76;p=emacs.git Make dired-toggle-read-only check whether the directory is writable * lisp/dired.el (dired-toggle-read-only): Check that the directory is writable (bug#29412). --- diff --git a/lisp/dired.el b/lisp/dired.el index 30b9f5b8fa1..6ad2497c9a9 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2419,6 +2419,8 @@ 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)) (if (derived-mode-p 'dired-mode) (wdired-change-to-wdired-mode) (read-only-mode 'toggle)))