Subject: RE: [External] : bug#78658: 30.1; [PATCH] Dired feature suggestion: dired-on-marked-files-in-all-buffers

From: Drew Adams <[email-masked]>
Date: Mon, 2 Jun 2025 16:23:34 +0000

> (defun diredp-marked-files-in-all-buffers ()
>   "Dired the files and directories marked in any Dired buffers.
> Like `diredp-marked-files', but for all Dired buffers."
>   (interactive)
>   (let ((files  (diredp-get-marked-files-in-all-buffers)))
>     (unless (directory-name-p common) (setq common  (diredp-parent-dir
> common)))
>     (let ((default-directory  (or common  default-directory)))
>       (dired (cons "MARKED-ANYWHERE"
>                    (if common
>                        (mapcar (lambda (file) (file-relative-name file common))
>                                files)
>                      files)))))))

Typo - somehow I omitted some lines.  Should have been this:

(defun diredp-marked-files-in-all-buffers ()
  "Dired the files and directories marked in any Dired buffers.
Like `diredp-marked-files', but for all Dired buffers."
  (interactive)
  (let ((files  (diredp-get-marked-files-in-all-buffers)))
    (unless files (user-error "No marked files in any Dired buffer"))
    (let ((common  (try-completion "" files)))
      (unless (directory-name-p common) (setq common  (diredp-parent-dir common)))
      (let ((default-directory  (or common  default-directory)))
        (dired (cons "MARKED-ANYWHERE"
                     (if common
                         (mapcar (lambda (file) (file-relative-name file common))
                                 files)
                       files)))))))

And it would be good to let users optionally name the resulting buffer:

(defun diredp-marked-files-in-all-buffers (&optional buffer-name)
  "Dired the files and directories marked in any Dired buffers.
Like `diredp-marked-files', but for all Dired buffers.
With a prefix argument you're prompted for the name of the resulting
Dired buffer.  Otherwise, the name is `MARKED-ANYWHERE'."
  (interactive (list (if current-prefix-arg
                         (read-string "Resulting Dired buffer name: ")
                       "MARKED-ANYWHERE")))
  (let ((files  (diredp-get-marked-files-in-all-buffers)))
    (unless files (user-error "No marked files in any Dired buffer"))
    (let ((common  (try-completion "" files)))
      (unless (directory-name-p common) (setq common  (diredp-parent-dir common)))
      (let ((default-directory  (or common  default-directory)))
        (dired (cons buffer-name
                     (if common
                         (mapcar (lambda (file) (file-relative-name file common))
                                 files)
                       files)))))))