changeset 109333:a13166a76062

* lisp/dired.el (dired-buffers-for-dir): Handle list values of dired-directory (Bug#6636).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 17 Jul 2010 17:25:32 -0400
parents 507549811e3e
children 603e7bce46eb
files lisp/ChangeLog lisp/dired.el
diffstat 2 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Jul 17 11:59:19 2010 +0200
+++ b/lisp/ChangeLog	Sat Jul 17 17:25:32 2010 -0400
@@ -1,3 +1,8 @@
+2010-07-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* dired.el (dired-buffers-for-dir): Handle list values of
+	dired-directory (Bug#6636).
+
 2010-07-16  Reiner Steib  <Reiner.Steib@gmx.de>
 
 	* vc.el (vc-coding-system-inherit-eol): New defvar.
--- a/lisp/dired.el	Sat Jul 17 11:59:19 2010 +0200
+++ b/lisp/dired.el	Sat Jul 17 17:25:32 2010 -0400
@@ -2227,31 +2227,33 @@
 ;; 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)