From f6cafe657402805f21a9651071f9768f92dacc76 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 12 Dec 2020 12:32:15 +0100 Subject: [PATCH] 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). --- lisp/dired.el | 2 ++ 1 file changed, 2 insertions(+) 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))) -- 2.39.2