From f7133be7ae4eda5b3688728f19cac39de7e862a3 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 13 Dec 2020 14:17:55 +0100 Subject: [PATCH] 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). --- lisp/dired.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index baf99da7b48..c68c4a52bd4 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -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))) -- 2.39.2