;;; dired.el --- directory-browsing commands
-;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 1997, 2000 Free Software Foundation, Inc.
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
;; Maintainer: FSF
(set-buffer old-buf)
buffer))
+(defvar dired-buffers nil
+ ;; Enlarged by dired-advertise
+ ;; Queried by function dired-buffers-for-dir. When this detects a
+ ;; killed buffer, it is removed from this list.
+ "Alist of expanded directories and their associated dired buffers.")
+
(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.
(define-key map "M" 'dired-do-chmod)
(define-key map "O" 'dired-do-chown)
(define-key map "P" 'dired-do-print)
- (define-key map "Q" 'dired-do-query-replace)
+ (define-key map "Q" 'dired-do-query-replace-regexp)
(define-key map "R" 'dired-do-rename)
(define-key map "S" 'dired-do-symlink)
(define-key map "X" 'dired-do-shell-command)
(define-key map "*\C-p" 'dired-prev-marked-file)
(define-key map "*t" 'dired-do-toggle)
;; Lower keys for commands not operating on all the marked files
+ (define-key map "a" 'dired-find-alternate-file)
(define-key map "d" 'dired-flag-file-deletion)
(define-key map "e" 'dired-find-file)
(define-key map "f" 'dired-find-file)
+ (define-key map "w" 'dired-show-file-type)
(define-key map "\C-m" 'dired-advertised-find-file)
(define-key map "g" 'revert-buffer)
(define-key map "h" 'describe-mode)
(cons "Operate" (make-sparse-keymap "Operate")))
(define-key map [menu-bar operate query-replace]
- '(menu-item "Query Replace in Files..." dired-do-query-replace
+ '(menu-item "Query Replace in Files..." dired-do-query-replace-regexp
:help "Replace regexp in marked files"))
(define-key map [menu-bar operate search]
'(menu-item "Search Files..." dired-do-search
(error "File is a symlink to a nonexistent target")
(error "File no longer exists; type `g' to update Dired buffer")))))
+(defun dired-find-alternate-file ()
+ "In dired, visit this file or directory instead of the dired buffer."
+ (interactive)
+ (set-buffer-modified-p nil)
+ (find-alternate-file (dired-get-filename)))
+
(defun dired-mouse-find-file-other-window (event)
"In dired, visit the file or directory name you click on."
(interactive "e")
(western (concat "\\(" month s dd "\\|" dd s month "\\)"
;; weiand: changed: year potentially unaligned
;;old s "\\(" HH:MM "\\|" s yyyy "\\|" yyyy s "\\)"))
- s "\\(" HH:MM "\\|" s "?" yyyy "\\|" yyyy s
-"\\)"))
+ s "\\(" HH:MM
+ "\\|" yyyy s s "?"
+ "\\|" s "?" yyyy
+ "\\)"))
(japanese (concat mm k s dd k s "\\(" s HH:MM "\\|" yyyy k "\\)")))
;; The "[0-9]" below requires the previous column to end in a digit.
;; This avoids recognizing `1 may 1997' as a date in the line:
\f
;; Keeping Dired buffers in sync with the filesystem and with each other
-(defvar dired-buffers nil
- ;; Enlarged by dired-advertise
- ;; Queried by function dired-buffers-for-dir. When this detects a
- ;; killed buffer, it is removed from this list.
- "Alist of expanded directories and their associated dired buffers.")
-
(defun dired-buffers-for-dir (dir &optional file)
;; Return a list of buffers that dired DIR (top level or in-situ subdir).
;; If FILE is non-nil, include only those whose wildcard pattern (if any)
(save-excursion
(let ((count 0)
(buffer-read-only nil)
- new-dir-name)
+ new-dir-name
+ (R-ftp-base-dir-regex
+ ;; Used to expand subdirectory names correctly in recursive
+ ;; ange-ftp listings.
+ (and (string-match "R" dired-actual-switches)
+ (string-match "\\`/.*:\\(/.*\\)" default-directory)
+ (concat "\\`" (match-string 1 default-directory)))))
(goto-char (point-min))
(setq dired-subdir-alist nil)
(while (and (re-search-forward dired-subdir-regexp nil t)
(save-excursion
(goto-char (match-beginning 1))
(setq new-dir-name
- (expand-file-name (buffer-substring (point) (match-end 1))))
+ (buffer-substring-no-properties (point) (match-end 1))
+ new-dir-name
+ (save-match-data
+ (if (and R-ftp-base-dir-regex
+ (not (string= new-dir-name default-directory))
+ (string-match R-ftp-base-dir-regex new-dir-name))
+ (concat default-directory
+ (substring new-dir-name (match-end 0)))
+ (expand-file-name new-dir-name))))
(delete-region (point) (match-end 1))
(insert new-dir-name))
(setq count (1+ count))
;; Point must be at beginning of line
;; Should be equivalent to (save-excursion (not (dired-move-to-filename)))
;; but is about 1.5..2.0 times as fast. (Actually that's not worth it)
- (or (looking-at "^$\\|^. *$\\|^. total\\|^. wildcard")
+ (or (looking-at "^$\\|^. *$\\|^. total\\|^. wildcard\\|^. used")
(and (looking-at dired-subdir-regexp)
(save-excursion (not (dired-move-to-filename))))))
;; `dired-sort-by-date-regexp' or `dired-sort-by-name-regexp' set the
;; minor mode accordingly, others appear literally in the mode line.
;; With optional second arg NO-REVERT, don't refresh the listing afterwards.
+ (dired-sort-R-check switches)
(setq dired-actual-switches switches)
(if (eq major-mode 'dired-mode) (dired-sort-set-modeline))
(or no-revert (revert-buffer)))
+
+(make-variable-buffer-local
+ (defvar dired-subdir-alist-pre-R nil
+ "Value of `dired-subdir-alist' before -R switch added."))
+
+(defun dired-sort-R-check (switches)
+ "Additional processing of -R in ls option string SWITCHES.
+Saves `dired-subdir-alist' when R is set and restores saved value
+minus any directories explicitly deleted when R is cleared.
+To be called first in body of `dired-sort-other', etc."
+ (cond
+ ((and (string-match "R" switches)
+ (not (string-match "R" dired-actual-switches)))
+ ;; Adding -R to ls switches -- save `dired-subdir-alist':
+ (setq dired-subdir-alist-pre-R dired-subdir-alist))
+ ((and (string-match "R" dired-actual-switches)
+ (not (string-match "R" switches)))
+ ;; Deleting -R from ls switches -- revert to pre-R subdirs
+ ;; that are still present:
+ (setq dired-subdir-alist
+ (if dired-subdir-alist-pre-R
+ (let (subdirs)
+ (while dired-subdir-alist-pre-R
+ (if (assoc (caar dired-subdir-alist-pre-R)
+ dired-subdir-alist)
+ ;; subdir still present...
+ (setq subdirs
+ (cons (car dired-subdir-alist-pre-R)
+ subdirs)))
+ (setq dired-subdir-alist-pre-R
+ (cdr dired-subdir-alist-pre-R)))
+ (reverse subdirs))
+ ;; No pre-R subdir alist, so revert to main directory
+ ;; listing:
+ (list (car (reverse dired-subdir-alist))))))))
\f
;; To make this file smaller, the less common commands
;; go in a separate file. But autoload them here
If there is already something hidden, make everything visible again.
Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
t)
+
+(autoload 'dired-show-file-type "dired-aux"
+ "Print the type of FILE, according to the `file' command.
+If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is
+true then the type of the file linked to by FILE is printed instead."
+ t)
\f
(if (eq system-type 'vax-vms)
(load "dired-vms"))