]> git.eshelyaron.com Git - emacs.git/commitdiff
New variable 'dired-confirm-killing-deleted-buffers'
authorAlex Branham <branham@utexas.edu>
Fri, 8 Sep 2017 09:36:59 +0000 (12:36 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 8 Sep 2017 09:36:59 +0000 (12:36 +0300)
* lisp/dired-x.el (dired-clean-confirm-killing-deleted-buffers):
New variable.
* lisp/dired.el (dired-clean-up-after-deletion): Kill buffers
visiting deleted files without confirming if
dired-clean-confirm-killing-deleted-buffers is nil.  (Bug#28373)
* etc/NEWS: Document the change.

Copyright-paperwork-exempt: yes

etc/NEWS
lisp/dired-x.el
lisp/dired.el

index 7b06e56a21f179608c10bd150143b46d5ebb5d1c..3f7feba6ddafd8d6d6bcb252f748a03c4066beb5 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -604,6 +604,12 @@ this is controlled by the 'wdired-create-parent-directories' variable.
 *** 'W' is now bound to 'browse-url-of-dired-file', and is useful for
 viewing HTML files and the like.
 
+---
+*** New variable 'dired-clean-confirm-killing-deleted-buffers'
+controls whether Dired asks to kill buffers visiting deleted files and
+directories.  The default is t, so Dired asks for confirmation, to
+keep previous behavior.
+
 ---
 ** html2text is now marked obsolete.
 
index 1425278bdc9923980ec46118f939105bf9aa39cb..bfb5574da35418d32b8c852af35825b52179f4f2 100644 (file)
@@ -243,6 +243,12 @@ to nil: a pipe using `zcat' or `gunzip -c' will be used."
   :type 'boolean
   :group 'dired-x)
 
+(defcustom dired-clean-confirm-killing-deleted-buffers t
+  "If nil, don't ask whether to kill buffers visiting deleted files."
+  :version "26.1"
+  :type 'boolean
+  :group 'dired-x)
+
 ;;; KEY BINDINGS.
 
 (define-key dired-mode-map "\C-x\M-o" 'dired-omit-mode)
index 052f9a521436ae50d50dca2fed8b9cb496929336..c7e28a4e71e3f31e586fd98badb7f02cec48ce7a 100644 (file)
@@ -3180,12 +3180,15 @@ non-empty directories is allowed."
   (dired-clean-up-after-deletion file))
 
 (defvar dired-clean-up-buffers-too)
+(defvar dired-clean-confirm-killing-deleted-buffers)
 
 (defun dired-clean-up-after-deletion (fn)
   "Clean up after a deleted file or directory FN.
-Removes any expanded subdirectory of deleted directory.
-If `dired-x' is loaded and `dired-clean-up-buffers-too' is non-nil,
-also offers to kill buffers visiting deleted files and directories."
+Removes any expanded subdirectory of deleted directory.  If
+`dired-x' is loaded and `dired-clean-up-buffers-too' is non-nil,
+kill any buffers visiting those files, prompting for
+confirmation.  To disable the confirmation, see
+`dired-clean-confirm-killing-deleted-buffers'."
   (save-excursion (and (cdr dired-subdir-alist)
                       (dired-goto-subdir fn)
                       (dired-kill-subdir)))
@@ -3193,15 +3196,17 @@ also offers to kill buffers visiting deleted files and directories."
   (when (and (featurep 'dired-x) dired-clean-up-buffers-too)
     (let ((buf (get-file-buffer fn)))
       (and buf
-           (funcall #'y-or-n-p
-                    (format "Kill buffer of %s, too? "
-                            (file-name-nondirectory fn)))
+           (and dired-clean-confirm-killing-deleted-buffers
+                (funcall #'y-or-n-p
+                         (format "Kill buffer of %s, too? "
+                                 (file-name-nondirectory fn))))
            (kill-buffer buf)))
     (let ((buf-list (dired-buffers-for-dir (expand-file-name fn))))
       (and buf-list
-           (y-or-n-p (format "Kill Dired buffer%s of %s, too? "
-                             (dired-plural-s (length buf-list))
-                             (file-name-nondirectory fn)))
+           (and dired-clean-confirm-killing-deleted-buffers
+                (y-or-n-p (format "Kill Dired buffer%s of %s, too? "
+                                  (dired-plural-s (length buf-list))
+                                  (file-name-nondirectory fn))))
            (dolist (buf buf-list)
              (kill-buffer buf))))))