]> git.eshelyaron.com Git - emacs.git/commitdiff
Give better error message in dired-toggle-read-only on nonexisting dirs
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2022 14:09:38 +0000 (16:09 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 27 Apr 2022 14:09:38 +0000 (16:09 +0200)
* lisp/dired.el (dired-toggle-read-only): Refuse to edit
non-existent directories (bug#23276).

lisp/dired.el

index 2856c5d2435554d1ff238340ca218fa3c9b5a90d..89fbd52aa62bce313f70454f197dfe5c7409e371 100644 (file)
@@ -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? ")))