Fuco1 / dired-hacks

Collection of useful dired additions
GNU General Public License v3.0
877 stars 77 forks source link

dired-open: support for opening multiple files at once #187

Open FrostyX opened 3 years ago

FrostyX commented 3 years ago

In GUI file managers (e.g. nautilus, dolphin) it is common to select multiple files of the same type and open them at once. It is useful when for example opening multiple papers in pdf, playing a whole music album the old-school way, queueing multiple videos in vlc, etc.

I am suggesting implementing a function called dired-open-marked that would unsurprisingly open all marked files with dired-open preconfigured command for their filetype. It wouldn't call the external command n times for each file but only once and pass all files as cmd line arguments.

I would like to write such feature myself but first, I wanted some ack whether it is something we want to have in this repository (or at all if it is a bad idea).

What do you think?

gvoysey commented 2 years ago

I have been using https://github.com/xenodium/dwim-shell-command for this.

Fuco1 commented 7 months ago

@FrostyX It seems like a great addition for this package. If you are still interested in implementing this, I will try to assist where possible.

FrostyX commented 7 months ago

I started working on this and the biggest problem is that xdg-open doesn't accept multiple parameters. So I came up with something like:

(defun dired-open-xdg ()
  "Try to run `xdg-open' to open the file under point."
  (interactive)
  (when (executable-find "xdg-open")
    (let ((files (or (dired-get-marked-files)
                     (ignore-errors (dired-get-file-for-visit)))))
      (dolist (file files)
        (call-process-shell-command
         (concat "xdg-open '" (file-truename file) "' &"))))))

It kinda works but not as well as I would like. Do you understand what file managers like nautilus or dolphin do, when you select multiple files and press enter?

Fuco1 commented 7 months ago

Not really, my linux environment is really weird :D I use Xmonad as window manager on top of some form of xfce but nothing like a normal desktop environment. But there must be something "simple" to use :/