Function: dired-mark

dired-mark is an interactive and byte-compiled function defined in dired.el.gz.

Signature

(dired-mark ARG &optional INTERACTIVE)

Documentation

Mark the file at point in the Dired buffer.

If the region is active in Transient Mark mode, mark all files in the region if dired-mark-region is non-nil. Otherwise, with a prefix arg, mark files on the next ARG lines.

If on a subdir headerline, mark all its files except . and ...

Use M-x dired-unmark-all-files (dired-unmark-all-files) to remove all marks and M-x dired-unmark (dired-unmark) on a subdir to remove the marks in this subdir.

View in manual

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-mark (arg &optional interactive)
  "Mark the file at point in the Dired buffer.
If the region is active in Transient Mark mode, mark all files
in the region if `dired-mark-region' is non-nil.
Otherwise, with a prefix arg, mark files on the next ARG lines.

If on a subdir headerline, mark all its files except `.' and `..'.

Use \\[dired-unmark-all-files] to remove all marks
and \\[dired-unmark] on a subdir to remove the marks in
this subdir."
  (interactive (list current-prefix-arg t) dired-mode)
  (cond
   ;; Mark files in the active region.
   ((and interactive dired-mark-region
         (region-active-p)
         (> (region-end) (region-beginning)))
    (save-excursion
      (let ((beg (region-beginning))
	    (end (region-end)))
	(dired-mark-files-in-region
	 (progn (goto-char beg) (line-beginning-position))
	 (progn (goto-char end)
                (if (if (eq dired-mark-region 'line)
                        (not (bolp))
                      (get-text-property (1- (point)) 'dired-filename))
                    (line-end-position)
                  (line-beginning-position)))))))
   ;; Mark subdir files from the subdir headerline.
   ((dired-get-subdir)
    (save-excursion (dired-mark-subdir-files)))
   ;; Mark the current (or next ARG) files.
   (t
    (let ((inhibit-read-only t))
      (dired-repeat-over-lines
       (prefix-numeric-value arg)
       (lambda ()
         (when (or (not (looking-at-p dired-re-dot))
                   ;; Don't skip symlinks to ".", "..", etc.
                   (save-excursion
                     (re-search-forward
                      dired-permission-flags-regexp nil t)
                     (eq (char-after (match-beginning 1)) ?l))
                   (not (equal dired-marker-char dired-del-marker)))
           (delete-char 1)
           (insert dired-marker-char))))))))