* lisp/dired-aux.el: Improve consistency of outline headings.
* lisp/dired-x.el: Improve consistency of outline headings.
* lisp/dired.el: Improve consistency of outline headings.
- Use three semicolons at beginning of headings because that already
is the dominant number of semicolons for headings in these files.
- Prefix each heading with a ^L instead of randomly omitting it in
front of some.
- Always prefix the line with the ^L with a completely empty line.
- Begin headings with a capital letter.
- Do not update complete headings.
- Do not end headings with a period.
- Remove a handful of section end markers.
- Address further inconsistencies.
;; sorting by Sebastian Kremer <sk@thp.uni-koeln.de>.
;; Finished up by rms in 1992.
+\f
;;; Code:
(require 'cl-lib)
Functions that operate recursively can store additional names
into this list; they also should call `dired-log' to log the errors.")
-;;; 15K
-;;;###begin dired-cmd.el
-;; Diffing and compressing
+\f
+;;; Diffing and compressing
(defconst dired-star-subst-regexp "\\(^\\|[ \t]\\)\\*\\([ \t]\\|$\\)")
(defconst dired-quark-subst-regexp "\\(^\\|[ \t]\\)\\?\\([ \t]\\|$\\)")
full-file-name
(file-attributes full-file-name))))
(directory-files dir)))
+
\f
;;; Change file attributes
'completing-read
(format prompt (dired-mark-prompt arg files))
collection nil nil initial nil default-value nil))
+
\f
-;;; Cleaning a directory: flagging some backups for deletion.
+;;; Cleaning a directory: flagging some backups for deletion
(defvar dired-file-version-alist)
(dired-map-dired-file-lines #'dired-trample-file-versions)
(message "Cleaning numerical backups...done")))
-;;; Subroutines of dired-clean-directory.
+\f
+;;; Subroutines of dired-clean-directory
(defun dired-map-dired-file-lines (fun)
;; Perform FUN with point at the end of each non-directory line.
(progn (beginning-of-line)
(delete-char 1)
(insert dired-del-marker)))))
+
\f
;;; Shell commands
(shell-command command)))
;; Return nil for sake of nconc in dired-bunch-files.
nil)
-\f
+\f
(defun dired-check-process (msg program &rest arguments)
"Display MSG while running PROGRAM, and check for output.
Remaining arguments are strings passed as command arguments to PROGRAM.
(unless (zerop res)
(pop-to-buffer out-buffer))
res))))
+
\f
-;; Commands that delete or redisplay part of the dired buffer.
+;;; Commands that delete or redisplay part of the dired buffer
(defun dired-kill-line (&optional arg)
"Kill the current line (not the files).
(message (or fmt "Killed %d line%s.") count (dired-plural-s count)))
count))))
-;;;###end dired-cmd.el
\f
-;;; 30K
-;;;###begin dired-cp.el
+;;; Compression
(defun dired-compress ()
;; Compress or uncompress the current file.
(interactive "P")
(dired-map-over-marks-check #'dired-compress arg 'compress t))
-;; Commands for Emacs Lisp files - load and byte compile
+\f
+;;; Commands for Emacs Lisp files - load and byte compile
(defun dired-byte-compile ()
;; Return nil for success, offending file name else.
(interactive)
(setq dired-switches-alist nil)
(revert-buffer))
+
\f
(defun dired-update-file-line (file)
;; Delete the current line, and insert an entry for FILE.
(line-beginning-position 2)))
(setq file (directory-file-name file))
(dired-add-entry file (if (eq ?\s marker) nil marker)))))
+
\f
;;; Copy, move/rename, making hard and symbolic links
(defvar overwrite-query)
(defvar overwrite-backup-query)
-;; The basic function for half a dozen variations on cp/mv/ln/ln -s.
+\f
+;;; The basic function for half a dozen variations on cp/mv/ln/ln -s
+
(defun dired-create-files (file-creator operation fn-list name-constructor
&optional marker-char)
"Create one or more new files from a list of existing files FN-LIST.
success-count)
operation success-count))))
(dired-move-to-filename))
+
\f
(defcustom dired-do-revert-buffer nil
"Automatically revert Dired buffers after `dired-do' operations.
dired-dirs)))
\f
-
;; We use this function in `dired-create-directory' and
;; `dired-create-empty-file'; the return value is the new entry
;; in the updated Dired buffer.
(interactive "P")
(dired-do-create-files 'move #'dired-rename-file
"Move" arg dired-keep-marker-rename "Rename"))
-;;;###end dired-cp.el
+
\f
-;;; 5K
-;;;###begin dired-re.el
+;;; Operate on files matched by regexp
+
(defvar rename-regexp-query)
(defun dired-do-create-files-regexp
#'make-symbolic-link
"SymLink" arg regexp newname whole-name dired-keep-marker-symlink))
+\f
+;;; Change case of file names
+
(defvar rename-non-directory-query)
(defun dired-create-files-non-directory
(interactive "P")
(dired-rename-non-directory #'downcase "Rename downcase" arg))
-;;;###end dired-re.el
\f
-;;; 13K
-;;;###begin dired-ins.el
+;;; Insert subdirectory
;;;###autoload
(defun dired-maybe-insert-subdir (dirname &optional
(setq result
(cons (substring str end) result)))
(nreverse result)))
+
\f
-;;; moving by subdirectories
+;;; Moving by subdirectories
;;;###autoload
(defun dired-prev-subdir (arg &optional no-error-if-not-found no-skip)
(if pos
(goto-char pos)
(error "At the bottom"))))
+
\f
-;;; hiding
+;;; Hiding
;;;###autoload
(defun dired-hide-subdir (arg)
(dired--hide start end))
(setq pos (cdr subdir))))))) ; prev dir gets current dir
-;;;###end dired-ins.el
-
\f
-;; Search only in file names in the Dired buffer.
+;;; Search only in file names in the Dired buffer
(defcustom dired-isearch-filenames nil
"Non-nil to Isearch in file names only.
(isearch-forward-regexp nil t))
\f
-;; Functions for searching in tags style among marked files.
+;;; Functions for searching in tags style among marked files
;;;###autoload
(defun dired-do-isearch ()
;; but maybe not if a dired-x function is being autoloaded.
(require 'dired)
-;;; User-defined variables.
+\f
+;;; User-defined variables
(defgroup dired-x nil
"Extended directory editing (dired-x)."
:type 'boolean
:group 'dired-x)
-;;; KEY BINDINGS.
+\f
+;;; Key bindings
+
(when (keymapp (lookup-key dired-mode-map "*"))
(define-key dired-mode-map "*(" 'dired-mark-sexp)
(define-key dired-mode-map "*O" 'dired-mark-omitted)
(define-key dired-mode-map "Y" 'dired-do-relsymlink)
(define-key dired-mode-map "V" 'dired-do-run-mail)
-;;; MENU BINDINGS
+\f
+;;; Menu bindings
(when-let ((menu (lookup-key dired-mode-map [menu-bar])))
(easy-menu-add-item menu '("Operate")
"Refresh"))
\f
-;; Install into appropriate hooks.
+;;; Install into appropriate hooks
(add-hook 'dired-mode-hook 'dired-extra-startup)
(add-hook 'dired-after-readin-hook 'dired-omit-expunge)
(dired-omit-startup))
\f
-;;; EXTENSION MARKING FUNCTIONS.
+;;; Extension marking functions
(defun dired--mark-suffix-interactive-spec ()
(let* ((default
(list ".dvi"))))
\f
-;;; OMITTING.
+;;; Omitting
;; Enhanced omitting of lines from directory listings.
;; Marked files are never omitted.
msg)))
\f
-;;; VIRTUAL DIRED MODE.
+;;; Virtual dired mode
;; For browsing `ls -lR' listings in a dired-like fashion.
(dired-virtual (dired-virtual-guess-dir)))
\f
-;;; SMART SHELL.
+;;; Smart shell
;; An Emacs buffer can have but one working directory, stored in the
;; buffer-local variable `default-directory'. A Dired buffer may have
(shell-command command output-buffer error-buffer)))
\f
-;;; GUESS SHELL COMMAND.
+;;; Guess shell command
;; Brief Description:
;;
(if (equal val "") default val))))
\f
-;;; RELATIVE SYMBOLIC LINKS.
+;;; Relative symbolic links
(declare-function make-symbolic-link "fileio.c")
"RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink))
\f
-;;; VISIT ALL MARKED FILES SIMULTANEOUSLY.
+;;; Visit all marked files simultaneously
;; Brief Description:
;;
(find-file file)))))
\f
-;;; MISCELLANEOUS COMMANDS.
+;;; Miscellaneous commands
;; Run man on files.
(dired-rmail)))))
\f
-;;; MISCELLANEOUS INTERNAL FUNCTIONS.
+;;; Miscellaneous internal functions
;; This should be a builtin
(defun dired-buffer-more-recently-used-p (buffer1 buffer2)
(memq buffer1 (buffer-list))
(not (memq buffer1 (memq buffer2 (buffer-list))))))
-\f
;; Needed if ls -lh is supported and also for GNU ls -ls.
(defun dired-x--string-to-number (str)
"Like `string-to-number' but recognize a trailing unit prefix.
(format "'%s file" predicate))))
\f
-;;; FIND FILE AT POINT.
+;;; Find file at point
(defcustom dired-x-hands-off-my-keys t
"Non-nil means don't remap `find-file' to `dired-x-find-file'.
(interactive (list (dired-x-read-filename-at-point "Find file: ")))
(find-file-other-window filename))
-;;; Internal functions.
+\f
+;;; Internal functions
;; Fixme: This should probably use `thing-at-point'. -- fx
(define-obsolete-function-alias 'dired-filename-at-point
(define-obsolete-function-alias 'read-filename-at-point
'dired-x-read-filename-at-point "24.1") ; is this even needed?
+
\f
-;;; BUG REPORTS
+;;; Epilog
(define-obsolete-function-alias 'dired-x-submit-report 'report-emacs-bug "24.1")
(declare-function dired-buffer-more-recently-used-p
"dired-x" (buffer1 buffer2))
+\f
;;; Customizable variables
(defgroup dired nil
(define-obsolete-variable-alias 'dired-free-space-args
'directory-free-space-args "27.1")
-;;; Hook variables
-
(defcustom dired-load-hook nil
"Run after loading Dired.
You can customize key bindings or load extensions with this."
:group 'dired
:version "28.1")
-;; Internal variables
+\f
+;;; Internal variables
(defvar dired-marker-char ?* ; the answer is 42
;; so that you can write things like
of the line.
Subexpression 2 must end right before the \\n.")
+\f
+;;; Faces
+
(defgroup dired-faces nil
"Faces used by Dired."
:group 'dired
(defvar dired-ignored-face 'dired-ignored
"Face name used for files suffixed with `completion-ignored-extensions'.")
+\f
+;;; Font-lock
+
(defvar dired-font-lock-keywords
(list
;;
"Additional expressions to highlight in Dired mode.")
(defvar dnd-protocol-alist)
+
\f
-;;; Macros must be defined before they are used, for the byte compiler.
+;;; Macros
+
+;; Macros must be defined before they are used, for the byte compiler.
(defmacro dired-mark-if (predicate msg)
"Mark files for PREDICATE, according to `dired-marker-char'.
(point-max)))
\f
-;; The dired command
+;;; The dired command
(defun dired-read-dir-and-switches (str)
;; For use in interactive.
found)))
\f
-;; Read in a new dired buffer
+;;; Read in a new dired buffer
(defun dired-readin ()
"Read in a new Dired buffer.
(put-text-property (+ (point) 4) (line-end-position)
'invisible 'dired-hide-details-link))))
(forward-line 1))))
+
\f
-;; Reverting a dired buffer
+;;; Reverting a dired buffer
(defun dired-revert (&optional _arg _noconfirm)
"Reread the Dired buffer.
(let ((handler (find-file-name-handler dir 'dired-uncache)))
(if handler
(funcall handler 'dired-uncache dir))))
+
\f
-;; dired mode key bindings and initialization
+;;; Dired mode key bindings and menus
(defvar dired-mode-map
;; This looks ugly when substitute-command-keys uses C-d instead d:
:help "Delete image tag from current or marked files"]))
\f
+;;; Dired mode
+
;; Dired mode is suitable only for specially formatted data.
(put 'dired-mode 'mode-class 'special)
(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)
(run-mode-hooks 'dired-mode-hook))
+
\f
-;; Idiosyncratic dired commands that don't deal with marks.
+;;; Idiosyncratic dired commands that don't deal with marks
(defun dired-summary ()
"Summarize basic Dired commands and show recent Dired errors."
(interactive)
(display-buffer (find-file-noselect (dired-get-file-for-visit))
t))
+
\f
-;;; Functions for extracting and manipulating file names in Dired buffers.
+;;; Functions for extracting and manipulating file names in Dired buffers
(defun dired-unhide-subdir ()
(with-silent-modifications
(if (string-match (concat "^" (regexp-quote dir)) file)
(substring file (match-end 0))
file))
+
\f
+;;; Mode to hide details
+
(define-minor-mode dired-hide-details-mode
"Toggle visibility of detailed information in current Dired buffer.
When this minor mode is enabled, details such as file ownership and
'add-to-invisibility-spec
'remove-from-invisibility-spec)
'dired-hide-details-link))
+
\f
;;; Functions to hide/unhide text
(progn (goto-char end) (line-end-position))
'(invisible))))
-;;; Functions for finding the file name in a dired buffer line.
+;;; Functions for finding the file name in a dired buffer line
(defvar dired-permission-flags-regexp
"\\([^ ]\\)[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)[-r][-w]\\([^ ]\\)"
(point)))))
\f
-;;; COPY NAMES OF MARKED FILES INTO KILL-RING.
+;;; Copy names of marked files into kill-ring
(defun dired-copy-filename-as-kill (&optional arg)
"Copy names of marked (or next ARG) files into the kill ring.
(message "%s" string))))
\f
-;; Keeping Dired buffers in sync with the filesystem and with each other
+;;; Keeping Dired buffers in sync with the filesystem and with each other
(defun dired-buffers-for-dir (dir &optional file subdirs)
"Return a list of buffers for DIR (top level or in-situ subdir).
;; Removing is also done as a side-effect in dired-buffer-for-dir.
(setq dired-buffers
(delq (assoc (expand-file-name dir) dired-buffers) dired-buffers)))
-\f
-;; Tree Dired
-;;; utility functions
+\f
+;;; Utility functions
(defun dired-in-this-tree-p (file dir)
;;"Is FILE part of the directory tree starting at DIR?"
(dired-goto-subdir dirname))
(if dired-trivial-filenames (dired-goto-next-nontrivial-file))
(run-hooks 'dired-initial-position-hook))
-\f
+
;; These are hooks which make tree dired work.
;; They are in this file because other parts of dired need to call them.
;; But they don't call the rest of tree dired unless there are subdirs loaded.
(if (or (null (cdr dired-subdir-alist)) (not (dired-next-subdir 1 t t)))
(point-max)
(point))))
+
\f
-;; Deleting files
+;;; Deleting files
(defcustom dired-recursive-deletes 'top
"Whether Dired deletes directories recursively.
(kill-buffer buf))))))
\f
-;; Confirmation
+;;; Confirmation
(defun dired-marker-regexp ()
(concat "^" (regexp-quote (char-to-string dired-marker-char))))
(let ((beg (point)))
(completion--insert-strings files)
(put-text-property beg (point) 'mouse-face nil)))
+
\f
-;; Commands to mark or flag file(s) at or near current line.
+;;; Commands to mark or flag file(s) at or near current line
(defun dired-repeat-over-lines (arg function)
;; This version skips non-file lines.
(list ?\s dired-marker-char)
(list dired-marker-char ?\s))))
(forward-line 1)))))
+
\f
-;;; Commands to mark or flag files based on their characteristics or names.
+;;; Commands to mark or flag files based on their characteristics or names
(defvar dired-regexp-history nil
"History list of regular expressions used in Dired commands.")
(message (if (= count 1) "1 mark removed"
"%d marks removed")
count))))
+
\f
-;; Logging failures operating on files, and showing the results.
+;;; Logging failures operating on files, and showing the results
(defvar dired-log-buffer "*Dired log*")
;; Log a summary describing a bunch of errors.
(dired-log (concat "\n" string "\n"))
(dired-log t))
+
\f
;;; Sorting
;; No pre-R subdir alist, so revert to main directory
;; listing:
(list (car (reverse dired-subdir-alist))))))))
-\f
-;;;; Drag and drop support
+\f
+;;; Drag and drop support
(defcustom dired-recursive-copies 'top
"Whether Dired copies directories recursively.
(let ((local-file (dnd-get-local-file-uri uri)))
(if local-file (dired-dnd-handle-local-file local-file action)
nil)))
-\f
-;;;; Desktop support
+\f
+;;; Desktop support
(eval-when-compile (require 'desktop))
(declare-function desktop-file-name "desktop" (filename dirname))
'(dired-mode . dired-restore-desktop-buffer))
\f
-;;;; Jump to Dired
+;;; Jump to Dired
(defvar archive-superior-buffer)
(defvar tar-superior-buffer)