Function: embark-export-dired

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

Signature

(embark-export-dired FILES)

Documentation

Create a Dired buffer listing FILES.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(defun embark-export-dired (files)
  "Create a Dired buffer listing FILES."
  (setq files (mapcar #'directory-file-name
                      (cl-remove-if-not #'file-exists-p files)))
  (when (dired-check-switches dired-listing-switches "A" "almost-all")
    (setq files (cl-remove-if
                 (lambda (path)
                   (let ((file (file-name-nondirectory path)))
                     (or (string= file ".") (string= file ".."))))
                 files)))
  (cl-letf* ((dir (or (file-name-directory (try-completion "" files)) ""))
             ;; Prevent reusing existing Dired buffer.
             ((symbol-function 'dired-find-buffer-nocreate) #'ignore)
             (buf (dired-noselect
                   (cons (expand-file-name dir)
                         (mapcar (lambda (file) (string-remove-prefix dir file))
                                 files)))))
    (with-current-buffer buf
      ;; Unadvertise to prevent the new buffer from being reused.
      (dired-unadvertise default-directory)
      (rename-buffer (format "*Embark Export Dired %s*" default-directory)))
    (pop-to-buffer buf)))