changeset 12996:59cb17f969d2

(dired-internal-noselect): New arg MODE. If it's non-nil, switch to that nil. (dired-find-buffer-nocreate): New arg MODE.
author Richard M. Stallman <rms@gnu.org>
date Sun, 03 Sep 1995 17:34:56 +0000
parents a3620c5ffad7
children 938dc2491820
files lisp/dired.el
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired.el	Sun Sep 03 17:32:58 1995 +0000
+++ b/lisp/dired.el	Sun Sep 03 17:34:56 1995 +0000
@@ -392,7 +392,7 @@
     (dired-internal-noselect dir-or-list switches)))
 
 ;; Separate function from dired-noselect for the sake of dired-vms.el.
-(defun dired-internal-noselect (dir-or-list &optional switches)
+(defun dired-internal-noselect (dir-or-list &optional switches mode)
   ;; If there is an existing dired buffer for DIRNAME, just leave
   ;; buffer as it is (don't even call dired-revert).
   ;; This saves time especially for deep trees or with ange-ftp.
@@ -402,8 +402,13 @@
   ;; revert the buffer.
   ;; A pity we can't possibly do "Directory has changed - refresh? "
   ;; like find-file does.
+  ;; Optional argument MODE is passed to dired-find-buffer-nocreate,
+  ;; see there.
   (let* ((dirname (if (consp dir-or-list) (car dir-or-list) dir-or-list))
-	 (buffer (dired-find-buffer-nocreate dir-or-list))
+	 ;; The following line used to use dir-or-list.
+	 ;; That never found an existing buffer, in the case
+	 ;; where it is a list.
+	 (buffer (dired-find-buffer-nocreate dirname mode))
 	 ;; note that buffer already is in dired-mode, if found
 	 (new-buffer-p (not buffer))
 	 (old-buf (current-buffer)))
@@ -435,6 +440,7 @@
 	      (file-name-directory dirname)))
       (or switches (setq switches dired-listing-switches))
       (dired-mode dirname switches)
+      (if mode (funcall mode))
       ;; default-directory and dired-actual-switches are set now
       ;; (buffer-local), so we can call dired-readin:
       (let ((failed t))
@@ -454,16 +460,18 @@
     (set-buffer old-buf)
     buffer))
 
-;; This differs from dired-buffers-for-dir in that it does not consider
-;; subdirs of default-directory and searches for the first match only
-(defun dired-find-buffer-nocreate (dirname)
+(defun dired-find-buffer-nocreate (dirname &optional mode)
+  ;; This differs from dired-buffers-for-dir in that it does not consider
+  ;; subdirs of default-directory and searches for the first match only.
+  ;; Also, the major mode must be MODE.
   (let (found (blist dired-buffers))    ; was (buffer-list)
+    (or mode (setq mode 'dired-mode))
     (while blist
       (if (null (buffer-name (cdr (car blist))))
 	  (setq blist (cdr blist))
 	(save-excursion
 	  (set-buffer (cdr (car blist)))
-	  (if (and (eq major-mode 'dired-mode)
+	  (if (and (eq major-mode mode)
 		   (equal dired-directory dirname))
 	      (setq found (cdr (car blist))
 		    blist nil)