Function: dired-mode

dired-mode is an autoloaded and byte-compiled function defined in dired.el.gz.

Signature

(dired-mode &optional DIRNAME SWITCHES)

Documentation

Mode for "editing" directory listings.

In Dired, you are "editing" a list of the files in a directory and
  (optionally) its subdirectories, in the format of ls -lR.
  Each directory is a page: use C-x [ and C-x ] to move pagewise.
"Editing" means that you can run shell commands on files, visit,
  compress, load or byte-compile them, change their file attributes
  and insert subdirectories into the same buffer. You can "mark"
  files for later commands or "flag" them for deletion, either file
  by file or all files matching certain criteria.
You can move using the usual cursor motion commands.The buffer is read-only. Digits are prefix arguments. Type d (dired-flag-file-deletion) to flag a file D for deletion. Type m (dired-mark) to Mark a file or subdirectory for later commands.
  Most commands operate on the marked files and use the current file
  if no files are marked. Use a numeric prefix argument to operate on
  the next ARG (or previous -ARG if ARG<0) files, or just 1
  to operate on the current file only. Prefix arguments override marks.
  Mark-using commands display a list of failures afterwards. Type ? (dired-summary)
  to see why something went wrong.
Type u (dired-unmark) to Unmark a file or all files of an inserted subdirectory. Type DEL (dired-unmark-backward) to back up one line and unmark or unflag. Type x (dired-do-flagged-delete) to delete (eXpunge) the files flagged D. Type RET (dired-find-file) to Find the current line's file
  (or dired it in another buffer, if it is a directory).
Type o (dired-find-file-other-window) to find file or Dired directory in Other window. Type i (dired-maybe-insert-subdir) to Insert a subdirectory in this buffer. Type R (dired-do-rename) to Rename a file or move the marked files to another directory. Type C (dired-do-copy) to Copy files. Type s (dired-sort-toggle-or-edit) to toggle Sorting by name/date or change the ls switches. Type g (revert-buffer) to read all currently expanded directories aGain.
  This retains all marks and hides subdirs again that were hidden before.
Use \SPC and \DEL to move down and up by lines.

If Dired ever gets confused, you can either type g (revert-buffer) to read the directories again, type l (dired-do-redisplay) to relist the file at point or the marked files or a subdirectory, or type M-x dired-build-subdir-alist (dired-build-subdir-alist) to parse the buffer again for the directory tree.

See the dired customization group for a list of user options.

This mode runs the following hooks:

  dired-before-readin-hook
  dired-after-readin-hook
  dired-mode-hook

Keybindings:
                    dired-undo
! dired-do-shell-command
# dired-flag-auto-save-files
$ dired-hide-subdir
% & dired-flag-garbage-files
% C dired-do-copy-regexp
% H dired-do-hardlink-regexp
% R dired-do-rename-regexp
% S dired-do-symlink-regexp
% Y dired-do-relsymlink-regexp
% d dired-flag-files-regexp
% g dired-mark-files-containing-regexp
% l dired-downcase
% m dired-mark-files-regexp
% r dired-do-rename-regexp
% u dired-upcase
& dired-do-async-shell-command
( dired-hide-details-mode(var)/dired-hide-details-mode(fun)
* ! dired-unmark-all-marks
* % dired-mark-files-regexp
* ( dired-mark-sexp
* * dired-mark-executables
* . dired-mark-extension
* / dired-mark-directories
* ? dired-unmark-all-files
* @ dired-mark-symlinks
* C-n dired-next-marked-file
* C-p dired-prev-marked-file
* DEL dired-unmark-backward
* N dired-number-of-marked-files
* O dired-mark-omitted
* c dired-change-marks
* m dired-mark
* s dired-mark-subdir-files
* t dired-toggle-marks
* u dired-unmark
+ dired-create-directory
- negative-argument
. dired-clean-directory
0 digit-argument
1 digit-argument
2 digit-argument
3 digit-argument
4 digit-argument
5 digit-argument
6 digit-argument
7 digit-argument
8 digit-argument
9 digit-argument
: d epa-dired-do-decrypt
: e epa-dired-do-encrypt
: s epa-dired-do-sign
: v epa-dired-do-verify
< beginning-of-buffer
< dired-prev-dirline
<follow-link> mouse-face
<mouse-2> dired-mouse-find-file-other-window
<normal-state> : evil-ex
<normal-state> ; d epa-dired-do-decrypt
<normal-state> ; e epa-dired-do-encrypt
<normal-state> ; s epa-dired-do-sign
<normal-state> ; v epa-dired-do-verify
<normal-state> J dired-goto-file
<normal-state> K dired-do-kill-lines
<normal-state> h evil-backward-char
<normal-state> j evil-next-line
<normal-state> k evil-previous-line
<normal-state> l evil-forward-char
<normal-state> r dired-do-redisplay
<override-state> normal
= dired-diff
> dired-next-dirline
> end-of-buffer
? describe-mode
? dired-summary
@ hycontrol-windows-grid
A dired-do-find-regexp
B dired-do-byte-compile
C dired-do-copy
C-M-d dired-tree-down
C-M-n dired-next-subdir
C-M-p dired-prev-subdir
C-M-u dired-tree-up
C-n dired-next-line
C-o dired-display-file
C-p dired-previous-line
C-t . image-dired-display-thumb
C-t C-t image-dired-dired-toggle-marked-thumbs
C-t a thumbs-dired-show
C-t c image-dired-dired-comment-files
C-t d image-dired-display-thumbs
C-t e image-dired-dired-edit-comment-and-tags
C-t f image-dired-mark-tagged-files
C-t i image-dired-dired-display-image
C-t j image-dired-jump-thumbnail-buffer
C-t m thumbs-dired-show-marked
C-t r image-dired-delete-tag
C-t t image-dired-tag-files
C-t w thumbs-dired-setroot
C-t x image-dired-dired-display-external
C-x C-q dired-toggle-read-only
C-x M-o dired-omit-mode(var)/dired-omit-mode(fun)
C-x u dired-undo
C-x v v dired-vc-next-action
D dired-do-delete
DEL dired-unmark-backward
DEL scroll-down-command
F dired-do-find-marked-files
G dired-do-chgrp
H dired-do-hardlink
I dired-do-info
L dired-do-load
M dired-do-chmod
M-! dired-smart-shell-command
M-$ dired-hide-all
M-( dired-mark-sexp
M-DEL dired-unmark-all-files
M-G dired-goto-subdir
M-s a C-M-s dired-do-isearch-regexp
M-s a C-s dired-do-isearch
M-s f C-M-s dired-isearch-filenames-regexp
M-s f C-s dired-isearch-filenames(var)/dired-isearch-filenames(fun)
M-{ dired-prev-marked-file
M-} dired-next-marked-file
N dired-do-man
O dired-do-chown
P dired-do-print
Q dired-do-find-regexp-and-replace
R dired-do-rename
RET dired-find-file
S dired-do-symlink
S-SPC dired-previous-line
S-SPC scroll-down-command
SPC dired-next-line
SPC scroll-up-command
SPC..~ undefined
T dired-do-touch
U dired-unmark-all-marks
V dired-do-run-mail
W browse-url-of-dired-file
X dired-do-shell-command
Y dired-do-relsymlink
Z dired-do-compress
^ dired-up-directory
a dired-find-alternate-file
c dired-do-compress-to
d dired-flag-file-deletion
g revert-buffer
g revert-buffer
h describe-mode
i dired-maybe-insert-subdir
j dired-goto-file
k dired-do-kill-lines
l dired-do-redisplay
m dired-mark
n dired-next-line
o dired-find-file-other-window
p dired-previous-line
q quit-window
s dired-sort-toggle-or-edit
t dired-toggle-marks
u dired-unmark
v dired-view-file
w dired-copy-filename-as-kill
x dired-do-flagged-delete
y dired-show-file-type
~ dired-flag-backup-files
€..\x3FFFFF dired-find-file

Probably introduced at or before Emacs version 19.29.

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
;; Autoload cookie needed by desktop.el
;;;###autoload
(defun dired-mode (&optional dirname switches)
  "Mode for \"editing\" directory listings.
In Dired, you are \"editing\" a list of the files in a directory and
  (optionally) its subdirectories, in the format of `ls -lR'.
  Each directory is a page: use \\[backward-page] and \\[forward-page] to move pagewise.
\"Editing\" means that you can run shell commands on files, visit,
  compress, load or byte-compile them, change their file attributes
  and insert subdirectories into the same buffer.  You can \"mark\"
  files for later commands or \"flag\" them for deletion, either file
  by file or all files matching certain criteria.
You can move using the usual cursor motion commands.\\<dired-mode-map>
The buffer is read-only.  Digits are prefix arguments.
Type \\[dired-flag-file-deletion] to flag a file `D' for deletion.
Type \\[dired-mark] to Mark a file or subdirectory for later commands.
  Most commands operate on the marked files and use the current file
  if no files are marked.  Use a numeric prefix argument to operate on
  the next ARG (or previous -ARG if ARG<0) files, or just `1'
  to operate on the current file only.  Prefix arguments override marks.
  Mark-using commands display a list of failures afterwards.  Type \\[dired-summary]
  to see why something went wrong.
Type \\[dired-unmark] to Unmark a file or all files of an inserted subdirectory.
Type \\[dired-unmark-backward] to back up one line and unmark or unflag.
Type \\[dired-do-flagged-delete] to delete (eXpunge) the files flagged `D'.
Type \\[dired-find-file] to Find the current line's file
  (or dired it in another buffer, if it is a directory).
Type \\[dired-find-file-other-window] to find file or Dired directory in Other window.
Type \\[dired-maybe-insert-subdir] to Insert a subdirectory in this buffer.
Type \\[dired-do-rename] to Rename a file or move the marked files to another directory.
Type \\[dired-do-copy] to Copy files.
Type \\[dired-sort-toggle-or-edit] to toggle Sorting by name/date or change the `ls' switches.
Type \\[revert-buffer] to read all currently expanded directories aGain.
  This retains all marks and hides subdirs again that were hidden before.
Use \\`SPC' and \\`DEL' to move down and up by lines.

If Dired ever gets confused, you can either type \\[revert-buffer] \
to read the
directories again, type \\[dired-do-redisplay] \
to relist the file at point or the marked files or a
subdirectory, or type \\[dired-build-subdir-alist] to parse the buffer
again for the directory tree.

See the `dired' customization group for a list of user options.

This mode runs the following hooks:

  `dired-before-readin-hook'
  `dired-after-readin-hook'
  `dired-mode-hook'

Keybindings:
\\{dired-mode-map}"
  ;; Not to be called interactively (e.g. dired-directory will be set
  ;; to default-directory, which is wrong with wildcards).
  (kill-all-local-variables)
  (use-local-map dired-mode-map)
  (dired-advertise)			; default-directory is already set
  (setq major-mode 'dired-mode
	mode-name "Dired"
	;; case-fold-search nil
	buffer-read-only t
	mode-line-buffer-identification
	(propertized-buffer-identification "%17b"))
  (add-to-invisibility-spec '(dired . t))
  ;; Ignore dired-hide-details-* value of invisible text property by default.
  (when (eq buffer-invisibility-spec t)
    (setq buffer-invisibility-spec (list t)))
  (setq-local revert-buffer-function #'dired-revert)
  (setq-local buffer-stale-function #'dired-buffer-stale-p)
  (setq-local buffer-auto-revert-by-notification t)
  (setq-local page-delimiter "\n\n")
  (setq dired-directory (or dirname default-directory))
  ;; list-buffers uses this to display the dir being edited in this buffer.
  (setq list-buffers-directory
	(expand-file-name (if (listp dired-directory)
			      (car dired-directory)
			    dired-directory)))
  (setq-local dired-actual-switches (or switches dired-listing-switches))
  (setq-local font-lock-defaults
              '(dired-font-lock-keywords t nil nil beginning-of-line))
  (setq-local desktop-save-buffer 'dired-desktop-buffer-misc-data)
  (setq-local grep-read-files-function #'dired-grep-read-files)
  (setq dired-switches-alist nil)
  (hack-dir-local-variables-non-file-buffer) ; before sorting
  (dired-sort-other dired-actual-switches t)
  (when (featurep 'dnd)
    (setq-local dnd-protocol-alist
                (append dired-dnd-protocol-alist dnd-protocol-alist)))
  (add-hook 'file-name-at-point-functions #'dired-file-name-at-point nil t)
  (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t)
  (add-hook 'context-menu-functions 'dired-context-menu 5 t)
  (run-mode-hooks 'dired-mode-hook))