;;; dired.el --- directory-browsing commands
;; Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995, 1996, 1997, 2000,
-;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;; Free Software Foundation, Inc.
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
;; Maintainer: FSF
;;;###autoload
(defcustom dired-listing-switches "-al"
- "*Switches passed to `ls' for Dired. MUST contain the `l' option.
+ "Switches passed to `ls' for Dired. MUST contain the `l' option.
May contain all other options that don't contradict `-l';
may contain even `F', `b', `i' and `s'. See also the variable
`dired-ls-F-marks-symlinks' concerning the `F' switch.
;;;###autoload
(defcustom dired-ls-F-marks-symlinks nil
- "*Informs Dired about how `ls -lF' marks symbolic links.
+ "Informs Dired about how `ls -lF' marks symbolic links.
Set this to t if `ls' (or whatever program is specified by
`insert-directory-program') with `-lF' marks the symbolic link
itself with a trailing @ (usually the case under Ultrix).
;;;###autoload
(defcustom dired-trivial-filenames "^\\.\\.?$\\|^#"
- "*Regexp of files to skip when finding first file of a directory.
+ "Regexp of files to skip when finding first file of a directory.
A value of nil means move to the subdir line.
A value of t means move to first file."
:type '(choice (const :tag "Move to subdir" nil)
;;;###autoload
(defcustom dired-keep-marker-rename t
;; Use t as default so that moved files "take their markers with them".
- "*Controls marking of renamed files.
+ "Controls marking of renamed files.
If t, files keep their previous marks when they are renamed.
If a character, renamed files (whether previously marked or not)
are afterward marked with that character."
;;;###autoload
(defcustom dired-keep-marker-copy ?C
- "*Controls marking of copied files.
+ "Controls marking of copied files.
If t, copied files are marked if and as the corresponding original files were.
If a character, copied files are unconditionally marked with that character."
:type '(choice (const :tag "Keep" t)
;;;###autoload
(defcustom dired-keep-marker-hardlink ?H
- "*Controls marking of newly made hard links.
+ "Controls marking of newly made hard links.
If t, they are marked if and as the files linked to were marked.
If a character, new links are unconditionally marked with that character."
:type '(choice (const :tag "Keep" t)
;;;###autoload
(defcustom dired-keep-marker-symlink ?Y
- "*Controls marking of newly made symbolic links.
+ "Controls marking of newly made symbolic links.
If t, they are marked if and as the files linked to were marked.
If a character, new links are unconditionally marked with that character."
:type '(choice (const :tag "Keep" t)
;;;###autoload
(defcustom dired-dwim-target nil
- "*If non-nil, Dired tries to guess a default target directory.
+ "If non-nil, Dired tries to guess a default target directory.
This means: if there is a dired buffer displayed in the next window,
use its current subdir, instead of the current subdir of this dired buffer.
;;;###autoload
(defcustom dired-copy-preserve-time t
- "*If non-nil, Dired preserves the last-modified time in a file copy.
+ "If non-nil, Dired preserves the last-modified time in a file copy.
\(This works on only some systems.)"
:type 'boolean
:group 'dired)
;; Explicitly put the default face on file names ending in a colon to
;; avoid fontifying them as directory header.
(list (concat dired-re-maybe-mark dired-re-inode-size dired-re-perms ".*:$")
- '(".+" (dired-move-to-filename) nil (0 default)))
+ '(".+" (dired-move-to-filename) nil (0 'default)))
;;
;; Directory headers.
(list dired-subdir-regexp '(1 dired-header-face))
;; default-directory and dired-actual-switches must be buffer-local
;; and initialized by now.
- (let (dirname)
+ (let (dirname
+ ;; This makes readin much much faster.
+ ;; In particular, it prevents the font lock hook from running
+ ;; until the directory is all read in.
+ (inhibit-modification-hooks t))
(if (consp dired-directory)
(setq dirname (car dired-directory))
(setq dirname dired-directory))
(error "File is a symlink to a nonexistent target")
(error "File no longer exists; type `g' to update dired buffer")))))
-;; Force `f' rather than `e' in the mode doc:
+;; Force C-m keybinding rather than `f' or `e' in the mode doc:
(defalias 'dired-advertised-find-file 'dired-find-file)
(defun dired-find-file ()
"In Dired, visit the file or directory named on this line."
;; Get rid of the mouse-face property that file names have.
(set-text-properties 0 (length file) nil file)
;; Unquote names quoted by ls or by dired-insert-directory.
- (while (string-match
- "\\(?:[^\\]\\|\\`\\)\\(\\\\[0-7][0-7][0-7]\\)" file)
- (setq file (replace-match
- (read (concat "\"" (match-string 1 file) "\""))
- nil t file 1)))
+ ;; This code was written using `read' to unquote, because
+ ;; it's faster than substituting \007 (4 chars) -> ^G (1
+ ;; char) etc. in a lisp loop. Unfortunately, this decision
+ ;; has necessitated hacks such as dealing with filenames
+ ;; with quotation marks in their names.
+ (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file)
+ (setq file (replace-match "\\\"" nil t file 1)))
+ (setq file (read (concat "\"" file "\"")))
;; The above `read' will return a unibyte string if FILE
;; contains eight-bit-control/graphic characters.
(if (and enable-multibyte-characters
;; Deleting files
(defcustom dired-recursive-deletes 'top
- "*Decide whether recursive deletes are allowed.
+ "Decide whether recursive deletes are allowed.
A value of nil means no recursive deletes.
`always' means delete recursively without asking. This is DANGEROUS!
`top' means ask for each directory at top level, but delete its subdirectories
(format "%c [%d files]" dired-marker-char count)))))
(defun dired-pop-to-buffer (buf)
- ;; Pop up buffer BUF.
+ "Pop up buffer BUF in a way suitable for Dired."
+ ;; Don't split window horizontally. (Bug#1806)
+ (let (split-width-threshold)
+ (pop-to-buffer (get-buffer-create buf)))
;; If dired-shrink-to-fit is t, make its window fit its contents.
- (if (not dired-shrink-to-fit)
- (pop-to-buffer (get-buffer-create buf))
- ;; let window shrink to fit:
- (let ((window (selected-window))
- target-lines w2)
- (cond ;; if split-height-threshold is enabled, use the largest window
- ((and (> (window-height (setq w2 (get-largest-window)))
- split-height-threshold)
- (window-full-width-p w2))
- (setq window w2))
- ;; if the least-recently-used window is big enough, use it
- ((and (> (window-height (setq w2 (get-lru-window)))
- (* 2 window-min-height))
- (window-full-width-p w2))
- (setq window w2)))
- (save-excursion
- (set-buffer buf)
- (goto-char (point-max))
- (skip-chars-backward "\n\r\t ")
- (setq target-lines (count-lines (point-min) (point)))
- ;; Don't forget to count the last line.
- (if (not (bolp))
- (setq target-lines (1+ target-lines))))
- (if (<= (window-height window) (* 2 window-min-height))
- ;; At this point, every window on the frame is too small to split.
- (setq w2 (display-buffer buf))
- (setq w2 (split-window window
- (max window-min-height
- (- (window-height window)
- (1+ (max window-min-height target-lines)))))))
- (set-window-buffer w2 buf)
- (if (< (1- (window-height w2)) target-lines)
- (progn
- (select-window w2)
- (enlarge-window (- target-lines (1- (window-height w2))))))
- (set-window-start w2 1)
- )))
+ (when dired-shrink-to-fit
+ ;; Try to not delete window when we want to display less than
+ ;; `window-min-height' lines.
+ (fit-window-to-buffer (get-buffer-window buf) nil 1)))
(defcustom dired-no-confirm nil
"A list of symbols for commands Dired should not confirm.
;;;; Drag and drop support
(defcustom dired-recursive-copies 'top
- "*Decide whether recursive copies are allowed.
+ "Decide whether recursive copies are allowed.
A value of nil means no recursive copies.
`always' means copy recursively without asking.
`top' means ask for each directory at top level.