@@ -2870,12 +2870,10 @@ You can then feed the file name(s) to other commands with \\[yank]."
2870
2870
2871
2871
; ;; Keeping Dired buffers in sync with the filesystem and with each other
2872
2872
2873
- (defun dired-buffers-for-dir (dir &optional file subdirs )
2873
+ (defun dired-buffers-for-dir (dir &optional file )
2874
2874
" Return a list of buffers for DIR (top level or in-situ subdir).
2875
2875
If FILE is non-nil, include only those whose wildcard pattern (if any)
2876
2876
matches FILE.
2877
- If SUBDIRS is non-nil, also include the dired buffers of
2878
- directories below DIR.
2879
2877
The list is in reverse order of buffer creation, most recent last.
2880
2878
As a side effect, killed dired buffers for DIR are removed from
2881
2879
`dired-buffers' ."
@@ -2889,18 +2887,33 @@ As a side effect, killed dired buffers for DIR are removed from
2889
2887
(setq dired-buffers (delq elt dired-buffers)))
2890
2888
((dired-in-this-tree-p dir (car elt))
2891
2889
(with-current-buffer buf
2892
- (when (and (or subdirs
2893
- (assoc dir dired-subdir-alist))
2894
- (or (null file)
2895
- (if (stringp dired-directory )
2896
- (let ((wildcards (file-name-nondirectory
2897
- dired-directory )))
2898
- (or (zerop (length wildcards))
2899
- (string-match-p (dired-glob-regexp wildcards)
2900
- file)))
2901
- (member (expand-file-name file dir)
2902
- (cdr dired-directory )))))
2903
- (setq result (cons buf result)))))))
2890
+ (and (assoc dir dired-subdir-alist)
2891
+ (or (null file)
2892
+ (if (stringp dired-directory )
2893
+ (let ((wildcards (file-name-nondirectory
2894
+ dired-directory )))
2895
+ (or (zerop (length wildcards))
2896
+ (string-match-p (dired-glob-regexp wildcards)
2897
+ file)))
2898
+ (member (expand-file-name file dir)
2899
+ (cdr dired-directory ))))
2900
+ (setq result (cons buf result)))))))
2901
+ result))
2902
+
2903
+ (defun dired-buffers-for-dir-or-subdir (dir )
2904
+ " Return a list of buffers for DIR or a subdirectory thereof.
2905
+ As a side effect, killed dired buffers for DIR are removed from
2906
+ `dired-buffers' ."
2907
+ (setq dir (file-name-as-directory dir))
2908
+ (let (result buf)
2909
+ (dolist (elt dired-buffers)
2910
+ (setq buf (cdr elt))
2911
+ (cond
2912
+ ((null (buffer-name buf))
2913
+ ; ; Buffer is killed - clean up:
2914
+ (setq dired-buffers (delq elt dired-buffers)))
2915
+ ((dired-in-this-tree-p (car elt) dir)
2916
+ (setq result (cons buf result)))))
2904
2917
result))
2905
2918
2906
2919
(defun dired-glob-regexp (pattern )
@@ -3479,15 +3492,16 @@ confirmation. To disable the confirmation, see
3479
3492
(file-name-nondirectory fn))))
3480
3493
(not dired-clean-confirm-killing-deleted-buffers))
3481
3494
(kill-buffer buf)))
3482
- (let ((buf-list (dired-buffers-for-dir ( expand-file-name fn)
3483
- nil 'subdirs )))
3495
+ (let ((buf-list (dired-buffers-for-dir-or-subdir
3496
+ ( expand-file-name fn) )))
3484
3497
(and buf-list
3485
3498
(or (and dired-clean-confirm-killing-deleted-buffers
3486
3499
(y-or-n-p
3487
3500
(format
3488
- (ngettext " Kill Dired buffer of %s, too? "
3489
- " Kill Dired buffers of %s, too? "
3490
- (length buf-list))
3501
+ (ngettext
3502
+ " Kill Dired buffer of %s, too? "
3503
+ " Kill Dired buffers of %s and its sub-directories, too? "
3504
+ (length buf-list))
3491
3505
(file-name-nondirectory
3492
3506
; ; FN may end in a / if `dired-listing-switches'
3493
3507
; ; contains -p, so we need to strip that
0 commit comments