From 82fa112e8a6ca5a6b6d160e25134c6c4ab9a0bd7 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 27 Apr 2022 16:09:38 +0200 Subject: [PATCH] Give better error message in dired-toggle-read-only on nonexisting dirs * lisp/dired.el (dired-toggle-read-only): Refuse to edit non-existent directories (bug#23276). --- lisp/dired.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/dired.el b/lisp/dired.el index 2856c5d2435..89fbd52aa62 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2533,6 +2533,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-exists-p default-directory) + (user-error "The current directory no longer exists")) (when (and (not (file-writable-p default-directory)) (not (y-or-n-p "Directory isn't writable; edit anyway? "))) -- 2.39.2