]> git.eshelyaron.com Git - emacs.git/commitdiff
Make dired-toggle-read-only check whether the directory is writable
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 12 Dec 2020 11:32:15 +0000 (12:32 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 12 Dec 2020 11:32:30 +0000 (12:32 +0100)
* lisp/dired.el (dired-toggle-read-only): Check that the directory
is writable (bug#29412).

lisp/dired.el

index 30b9f5b8fa10853c08f15e3cf5ee4e35278980c7..6ad2497c9a93faa5ea96b47ba74dd16c7c6fd429 100644 (file)
@@ -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)))