;;; 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
;; 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
(format "%c [%d files]" dired-marker-char count)))))
(defun dired-pop-to-buffer (buf)
- ;; Pop up buffer BUF.
- (pop-to-buffer (get-buffer-create 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.
(when dired-shrink-to-fit
- (fit-window-to-buffer (get-buffer-window buf))))
+ ;; 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.