[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7b50ed5: Ask if dir and subdir dired buffers be killed when delet
From: |
Tassilo Horn |
Subject: |
master 7b50ed5: Ask if dir and subdir dired buffers be killed when deleting dir |
Date: |
Fri, 4 Jun 2021 16:09:35 -0400 (EDT) |
branch: master
commit 7b50ed553faa6de6d51bf07d12d106ca61ab3ac4
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>
Ask if dir and subdir dired buffers be killed when deleting dir
Previously, when you've had dired buffers
~/foo/
~/foo/bar/
~/foo/bar/baz/
and then deleted ~/foo/, dired (with dired-clean-up-buffers-too set to
non-nil) would only ask to delete the dired buffer of ~/foo/. Now it
will offer to delete all three buffers.
* lisp/dired.el (dired-buffers-for-dir): Add optional argument SUBDIRS
which makes the function return also dired buffers showing a subdir of
DIR.
(dired-in-this-tree-p): Make obsolete in favor of file-in-directory-p
which actually does what the name suggest whereas dired-in-this-tree-p
is just string-matching on filenames which will fail with symlinks
filenames including ./ or ../.
---
lisp/dired.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/lisp/dired.el b/lisp/dired.el
index 1654843..bb428e2 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2820,10 +2820,12 @@ You can then feed the file name(s) to other commands
with \\[yank]."
;; Keeping Dired buffers in sync with the filesystem and with each other
-(defun dired-buffers-for-dir (dir &optional file)
+(defun dired-buffers-for-dir (dir &optional file subdirs)
"Return a list of buffers for DIR (top level or in-situ subdir).
If FILE is non-nil, include only those whose wildcard pattern (if any)
matches FILE.
+If SUBDIRS is non-nil, also include the dired buffers of
+directories below DIR.
The list is in reverse order of buffer creation, most recent last.
As a side effect, killed dired buffers for DIR are removed from
dired-buffers."
@@ -2835,19 +2837,20 @@ dired-buffers."
((null (buffer-name buf))
;; Buffer is killed - clean up:
(setq dired-buffers (delq elt dired-buffers)))
- ((dired-in-this-tree-p dir (car elt))
+ ((file-in-directory-p (car elt) dir)
(with-current-buffer buf
- (and (assoc dir dired-subdir-alist)
- (or (null file)
- (if (stringp dired-directory)
- (let ((wildcards (file-name-nondirectory
- dired-directory)))
- (or (zerop (length wildcards))
- (string-match-p (dired-glob-regexp wildcards)
- file)))
- (member (expand-file-name file dir)
- (cdr dired-directory))))
- (setq result (cons buf result)))))))
+ (when (and (or subdirs
+ (assoc dir dired-subdir-alist))
+ (or (null file)
+ (if (stringp dired-directory)
+ (let ((wildcards (file-name-nondirectory
+ dired-directory)))
+ (or (zerop (length wildcards))
+ (string-match-p (dired-glob-regexp wildcards)
+ file)))
+ (member (expand-file-name file dir)
+ (cdr dired-directory)))))
+ (setq result (cons buf result)))))))
result))
(defun dired-glob-regexp (pattern)
@@ -2912,6 +2915,7 @@ dired-buffers."
;;"Is FILE part of the directory tree starting at DIR?"
(let (case-fold-search)
(string-match-p (concat "^" (regexp-quote dir)) file)))
+(make-obsolete 'dired-in-this-tree-p 'file-in-directory-p "28.1")
(define-obsolete-function-alias 'dired-in-this-tree
'dired-in-this-tree-p "27.1")
@@ -3427,7 +3431,8 @@ confirmation. To disable the confirmation, see
(file-name-nondirectory fn))))
(not dired-clean-confirm-killing-deleted-buffers))
(kill-buffer buf)))
- (let ((buf-list (dired-buffers-for-dir (expand-file-name fn))))
+ (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)
+ nil 'subdirs)))
(and buf-list
(or (and dired-clean-confirm-killing-deleted-buffers
(y-or-n-p
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 7b50ed5: Ask if dir and subdir dired buffers be killed when deleting dir,
Tassilo Horn <=