summaryrefslogtreecommitdiff
path: root/lisp/dired.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-07-17 17:25:32 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-07-17 17:25:32 -0400
commitdad7c7162bddfad0aa60648042f9a7f0d1255ee5 (patch)
tree1d960f95d4e68c43b6d13b91344275d9f1557f20 /lisp/dired.el
parent499322cef9f248af58fb76334076feb80842d592 (diff)
downloademacs-dad7c7162bddfad0aa60648042f9a7f0d1255ee5.tar.gz
* lisp/dired.el (dired-buffers-for-dir): Handle list values of dired-directory (Bug#6636).
Diffstat (limited to 'lisp/dired.el')
-rw-r--r--lisp/dired.el38
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index c3d1435401e..4a23865dfca 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2227,31 +2227,33 @@ 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)
-;; Return a list of buffers that dired DIR (top level or in-situ subdir).
+;; 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.
;; 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.
(setq dir (file-name-as-directory dir))
- (let ((alist dired-buffers) result elt buf)
- (while alist
- (setq elt (car alist)
- buf (cdr elt))
- (if (buffer-name buf)
- (if (dired-in-this-tree dir (car elt))
- (with-current-buffer buf
- (and (assoc dir dired-subdir-alist)
- (or (null file)
- (let ((wildcards
- (file-name-nondirectory dired-directory)))
- (or (= 0 (length wildcards))
- (string-match (dired-glob-regexp wildcards)
- file))))
- (setq result (cons buf result)))))
- ;; else buffer is killed - clean up:
+ (let (result buf)
+ (dolist (elt dired-buffers)
+ (setq buf (cdr elt))
+ (cond
+ ((null (buffer-name buf))
+ ;; Buffer is killed - clean up:
(setq dired-buffers (delq elt dired-buffers)))
- (setq alist (cdr alist)))
+ ((dired-in-this-tree dir (car elt))
+ (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 (= 0 (length wildcards))
+ (string-match (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)