Function: dired-readin

dired-readin is a byte-compiled function defined in dired.el.gz.

Signature

(dired-readin)

Documentation

Read in a new Dired buffer.

Differs from dired-insert-subdir in that it accepts wildcards, erases the buffer, and builds the subdir-alist anew
(including making it buffer-local and clearing it first).

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
;;; Read in a new dired buffer

(defun dired-readin ()
  "Read in a new Dired buffer.
Differs from `dired-insert-subdir' in that it accepts
wildcards, erases the buffer, and builds the subdir-alist anew
\(including making it buffer-local and clearing it first)."

  ;; default-directory and dired-actual-switches must be buffer-local
  ;; and initialized by now.
  (let ((dirname
	 (expand-file-name
	  (if (consp dired-directory)
	      (car dired-directory)
	    dired-directory))))
    (save-excursion
      ;; This hook which may want to modify dired-actual-switches
      ;; based on dired-directory, e.g. with ange-ftp to a SysV host
      ;; where ls won't understand -Al switches.
      (run-hooks 'dired-before-readin-hook)
      (if (consp buffer-undo-list)
	  (setq buffer-undo-list nil))
      (setq-local file-name-coding-system
                  (or coding-system-for-read file-name-coding-system))
      (widen)
      ;; We used to bind `inhibit-modification-hooks' to try and speed up
      ;; execution, in particular, to prevent the font-lock hook from running
      ;; until the directory is all read in.
      ;; It's not clear why font-lock would be a significant issue
      ;; here, but I used `combine-change-calls' which should provide the
      ;; same performance advantages without the problem of breaking
      ;; users of after/before-change-functions.
      (combine-change-calls (point-min) (point-max)
	(let ((inhibit-read-only t)
	      ;; Don't make undo entries for readin.
	      (buffer-undo-list t))
	  (erase-buffer)
	  (dired-readin-insert))
	(goto-char (point-min))
	;; Must first make alist buffer local and set it to nil because
	;; dired-build-subdir-alist will call dired-clear-alist first
	(setq-local dired-subdir-alist nil)
	(dired-build-subdir-alist))
      (let ((attributes (file-attributes dirname)))
	(if (eq (car attributes) t)
	    (set-visited-file-modtime (file-attribute-modification-time
                                       attributes))))
      (set-buffer-modified-p nil)
      ;; No need to narrow since the whole buffer contains just
      ;; dired-readin's output, nothing else.  The hook can
      ;; successfully use dired functions (e.g. dired-get-filename)
      ;; as the subdir-alist has been built in dired-readin.
      (run-hooks 'dired-after-readin-hook))))