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
Treat the current buffer as a Dired buffer showing directory DIRNAME.
Interactively, prompt for DIRNAME.
This command is rarely useful, but may be convenient if you want
to peruse and move around in the output you got from "ls
-lR" (or something similar), without having access to the actual
file system.
Most Dired commands that don't consult the file system will work as advertised, but commands that try to alter the file system will usually fail. (However, if the output is from the current system, most of those commands will work fine.)
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)
"Treat the current buffer as a Dired buffer showing directory DIRNAME.
Interactively, prompt for DIRNAME.
This command is rarely useful, but may be convenient if you want
to peruse and move around in the output you got from \"ls
-lR\" (or something similar), without having access to the actual
file system.
Most Dired commands that don't consult the file system will work
as advertised, but commands that try to alter the file system
will usually fail. (However, if the output is from the current
system, most of those commands will work fine.)
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 (connection-local-value dired-listing-switches)))
(setq mode-name "Virtual Dired"
revert-buffer-function 'dired-virtual-revert
dired-subdir-alist nil)
(dired-build-subdir-alist)
(goto-char (point-min))
(dired-initial-position dirname))