Function: dired-virtual
dired-virtual is an interactive and byte-compiled function defined in
dired-x.el.gz.
Signature
(dired-virtual DIRNAME &optional SWITCHES)
Documentation
Put this Dired buffer into Virtual Dired mode.
In Virtual Dired mode, all commands that do not actually consult the filesystem will work.
This is useful if you want to peruse and move around in an ls -lR
output file, for example one you got from an ftp server. With
ange-ftp, you can even Dired a directory containing an ls-lR file,
visit that file and turn on Virtual Dired mode. But don't try to save
this file, as dired-virtual indents the listing and thus changes the
buffer.
If you have saved a Dired buffer in a file you can use M-x dired-virtual (dired-virtual) to
resume it in a later session.
Type g (revert-buffer) in the Virtual Dired buffer and answer y to convert
the virtual to a real Dired buffer again. You don't have to do this, though:
you can relist single subdirs using l (dired-do-redisplay).
Key Bindings
Aliases
Source Code
;; Defined in /usr/src/emacs/lisp/dired-x.el.gz
(defun dired-virtual (dirname &optional switches)
"Put this Dired buffer into Virtual Dired mode.
In Virtual Dired mode, all commands that do not actually consult the
filesystem will work.
This is useful if you want to peruse and move around in an ls -lR
output file, for example one you got from an ftp server. With
ange-ftp, you can even Dired a directory containing an ls-lR file,
visit that file and turn on Virtual Dired mode. But don't try to save
this file, as `dired-virtual' indents the listing and thus changes the
buffer.
If you have saved a Dired buffer in a file you can use \\[dired-virtual] to
resume it in a later session.
Type \\<dired-mode-map>\\[revert-buffer] \
in the Virtual Dired buffer and answer `y' to convert
the virtual to a real Dired buffer again. You don't have to do this, though:
you can relist single subdirs using \\[dired-do-redisplay]."
;; DIRNAME is the top level directory of the buffer. It will become
;; its `default-directory'. If nil, the old value of
;; default-directory is used.
;; Optional SWITCHES are the ls switches to use.
;; Shell wildcards will be used if there already is a `wildcard'
;; line in the buffer (thus it is a saved Dired buffer), but there
;; is no other way to get wildcards. Insert a `wildcard' line by
;; hand if you want them.
(interactive
(list (read-directory-name "Virtual Dired directory: "
nil (dired-virtual-guess-dir))))
(goto-char (point-min))
(or (looking-at-p " ")
;; if not already indented, do it now:
(indent-region (point-min) (point-max) 2))
(or dirname (setq dirname default-directory))
(setq dirname (expand-file-name (file-name-as-directory dirname)))
(setq default-directory dirname) ; contains no wildcards
(let ((wildcard (save-excursion
(goto-char (point-min))
(forward-line 1)
(and (looking-at "^ wildcard ")
(buffer-substring (match-end 0)
(line-end-position))))))
(if wildcard
(setq dirname (expand-file-name wildcard default-directory))))
;; If raw ls listing (not a saved old dired buffer), give it a
;; decent subdir headerline:
(goto-char (point-min))
(or (looking-at-p dired-subdir-regexp)
(insert " "
(directory-file-name (file-name-directory default-directory))
":\n"))
(dired-mode dirname (or switches dired-listing-switches))
(setq mode-name "Virtual Dired"
revert-buffer-function 'dired-virtual-revert)
(setq-local dired-subdir-alist nil)
(dired-build-subdir-alist)
(goto-char (point-min))
(dired-initial-position dirname))