]> code.delx.au - gnu-emacs/blobdiff - lisp/dired.el
* net/tramp.el (tramp-default-file-modes) New defun. Replace all
[gnu-emacs] / lisp / dired.el
index 5d0db7ecc1d30d31a4723223d21380e296192f83..087a05f3de42b4180e12a6969dcc9b896c2da559 100644 (file)
@@ -1,7 +1,8 @@
 ;;; 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
@@ -858,7 +859,11 @@ wildcards, erases the buffer, and builds the subdir-alist anew
 
   ;; 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))
@@ -1862,7 +1867,7 @@ Creates a buffer if necessary."
          (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."
@@ -1945,11 +1950,14 @@ Otherwise, an error occurs in these cases."
          ;; 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
@@ -2677,11 +2685,15 @@ name, or the marker and a count of marked files."
        (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.