Function: embark-dired-candidates

embark-dired-candidates is a byte-compiled function defined in embark.el.

Signature

(embark-dired-candidates)

Documentation

Return marked or all files shown in Dired buffer.

If any buffer is marked, return marked buffers; otherwise, return all buffers.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defun embark-dired-candidates ()
  "Return marked or all files shown in Dired buffer.
If any buffer is marked, return marked buffers; otherwise, return
all buffers."
  (when (derived-mode-p 'dired-mode)
    (cons 'file
          (or
           ;; dired-get-marked-files returns the file on the current
           ;; line if no marked files are found; and when the fourth
           ;; argument is non-nil, the "no marked files" case is
           ;; distinguished from the "single marked file" case by
           ;; returning (list t marked-file) in the latter
           (let ((marked (dired-get-marked-files t nil nil t)))
             (and (cdr marked)
                  (if (eq (car marked) t) (cdr marked) marked)))
           (save-excursion
             (goto-char (point-min))
             (let (files)
               (while (not (eobp))
                 (when-let* ((file (dired-get-filename t t)))
                   (push `(,file
                           ,(progn (dired-move-to-filename) (point))
                           . ,(progn (dired-move-to-end-of-filename t) (point)))
                         files))
                 (forward-line))
               (nreverse files)))))))