Subject: Re: bug#18132: Time for a smarter dired-guess-shell-alist-default? (dired-x.el)

From: Stefan Kangas <[email-masked]>
Date: Sat, 23 Oct 2021 06:56:59 -0700

Reuben Thomas <[email-masked]> writes:

> xdg-open uses the underlying desktop system's MIME infrastructure. For a
> GNU system, that would most typically be GNOME, and its "gio open" (or on
> older systems, gvfs-open) command.

I don't see that shooting away blindly to xdg-open is satisfactory; the
user should be able to a) know which command is being run before running
it and b) modify it on the fly.  Maybe I want to open PDF:s first with
one and then another PDF reader to see if it looks the same, just as I
would be able to from a graphical file manager.

Thus, the most important question to my mind is "how can we get the
default command for a file in the best way".

I think ideally we should get this from the system, optionally with
overrides and/or fallbacks from Emacs or the user.  I don't particularly
care if it comes from mailcap, from /usr/share/applications, but we
should preferably pick the "best" one.

Eli says that portability is a concern with mailcap, which is true but
also not something we can't work around.

You say that mailcap is the wrong tool for the job.  (Why?)

I claim that the `xdg-open' script does not seem to solve the problem.

Then I ask: what is the correct tool for the job of finding the command
to run?

Maybe we need try several different things?  I see that `xdg-open' tries
all kinds of different things ("gio open", "gvfs open", "open_generic",
etc.).  But our needs are different: we want the command as a string, we
don't just want to run it.

PS. For the sake of simplicity, I would suggest that we could first
    figure out what to do on GNU/Linux and then we'll see if we can get
    that solution to work elsewhere or if we need to get other things in
    place.