30.19 Other Dired Features
The command +
(dired-create-directory
) reads a directory’s name, and creates that directory. It signals an error if the directory already exists.
The command (dired-create-empty-file
) reads a file name, and creates that file. It signals an error if the file already exists.
The command M-s a C-s
(dired-do-isearch
) begins a multi-file incremental search on the marked files. If a search fails at the end of a file, typing C-s
advances to the next marked file and repeats the search; at the end of the last marked file, the search wraps around to the first marked file. The command M-s a M-C-s
(dired-do-isearch-regexp
) does the same with a regular expression search. See Repeat Isearch, for information about search repetition.
The command w
(dired-copy-filename-as-kill
) puts the names of the marked (or next n
) files into the kill ring, as if you had killed them with C-w
. The names are separated by a space.
With a zero prefix argument, this uses the absolute file name of each marked file. With just C-u
as the prefix argument, it uses file names relative to the Dired buffer’s default directory. (This can still contain slashes if in a subdirectory.) As a special case, if point is on a directory header line, w
gives you the absolute name of that directory. Any prefix argument or marked files are ignored in this case.
The main purpose of this command is so that you can yank the file names into arguments for other Emacs commands. It also displays what it added to the kill ring, so you can use it to display the list of currently marked files in the echo area.
If you have an HTML file in the file listing, it can be useful to view that file with a browser. The W
(browse-url-of-dired-file
) command will use the standard configured browser to view that file.
The command (
(dired-hide-details-mode
) toggles whether details, such as ownership or file permissions, are visible in the current Dired buffer. By default, it also hides the targets of symbolic links, and all lines other than the header line and file/directory listings. To change this, customize the options dired-hide-details-hide-symlink-targets
and dired-hide-details-hide-information-lines
, respectively.
If the directory you are visiting is under version control (see Version Control), then the normal VC diff and log commands will operate on the selected files.
The command M-x dired-compare-directories
is used to compare the current Dired buffer with another directory. It marks all the files that differ between the two directories. It puts these marks in all Dired buffers where these files are listed, which of course includes the current buffer.
The default comparison method (used if you type RET
at the prompt) is to compare just the file names—file names differ if they do not appear in the other directory. You can specify more stringent comparisons by entering a Lisp expression, which can refer to the variables size1
and size2
, the respective file sizes; mtime1
and mtime2
, the last modification times in seconds, as floating point numbers; and fa1
and fa2
, the respective file attribute lists (as returned by the function file-attributes
). This expression is evaluated for each pair of like-named files, and files differ if the expression’s value is non-nil
.
For instance, the sequence M-x dired-compare-directories RET (> mtime1 mtime2) RET
marks files newer in this directory than in the other, and marks files older in the other directory than in this one. It also marks files with no counterpart, in both directories, as always.
On the X Window System, Emacs supports the drag and drop protocol. You can drag a file object from another program, and drop it onto a Dired buffer; this either moves, copies, or creates a link to the file in that directory. Precisely which action is taken is determined by the originating program. Dragging files out of a Dired buffer is currently not supported.