]> git.eshelyaron.com Git - emacs.git/commitdiff
Make dired-toggle-read-only query on read-only directories
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 13 Dec 2020 13:17:55 +0000 (14:17 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 13 Dec 2020 13:17:55 +0000 (14:17 +0100)
* lisp/dired.el (dired-toggle-read-only): Query instead of
erroring out immediately (bug#29412).

lisp/dired.el

index baf99da7b48203406e1bee1e0e027dae9e130f41..c68c4a52bd4052f80a5206cf59317da8642851c8 100644 (file)
@@ -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)))