unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Updating dired-guess-shell-alist-default
@ 2020-07-07  8:50 Philip K.
  2020-07-07 14:19 ` Eli Zaretskii
  2020-07-09 16:21 ` Philip K.
  0 siblings, 2 replies; 25+ messages in thread
From: Philip K. @ 2020-07-07  8:50 UTC (permalink / raw)
  To: emacs-devel


Hi,

I wonder if anyone else shares my point of view: while useful,
dired-do-shell-command seems somewhat outdated. Certain file formats
haven't changed much, and their handling is still ok (.patch, .tar.*,
.sig) but especially image, video files and documents suggest tools
that don't seem to be installed by default on most systems (xloadimage,
xpdf, ...).

Of course this can be mitigated by using dired-guess-shell-alist-user,
but I think that this shouldn't be necessary. I usually just map all
images, videos and documents to xdg-open, and changing the values to
something like this wouldn't be bad a bad idea, if you ask me
(especially because xdg-open doesn't block).

So if not xdg-open (at least on GNU/Linux and other XDG-compliant
systems), should the default value be changed to something that makes
dired-do-shell-command more useful, out of the box?

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07  8:50 Updating dired-guess-shell-alist-default Philip K.
@ 2020-07-07 14:19 ` Eli Zaretskii
  2020-07-07 16:10   ` Philip K.
  2020-07-09 16:21 ` Philip K.
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-07 14:19 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Date: Tue, 07 Jul 2020 10:50:31 +0200
> 
> I wonder if anyone else shares my point of view: while useful,
> dired-do-shell-command seems somewhat outdated. Certain file formats
> haven't changed much, and their handling is still ok (.patch, .tar.*,
> .sig) but especially image, video files and documents suggest tools
> that don't seem to be installed by default on most systems (xloadimage,
> xpdf, ...).
> 
> Of course this can be mitigated by using dired-guess-shell-alist-user,
> but I think that this shouldn't be necessary. I usually just map all
> images, videos and documents to xdg-open, and changing the values to
> something like this wouldn't be bad a bad idea, if you ask me
> (especially because xdg-open doesn't block).
> 
> So if not xdg-open (at least on GNU/Linux and other XDG-compliant
> systems), should the default value be changed to something that makes
> dired-do-shell-command more useful, out of the box?

Can you show a concrete proposal, like which file type would you
suggest to handle by what command?

Thanks.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 14:19 ` Eli Zaretskii
@ 2020-07-07 16:10   ` Philip K.
  2020-07-07 18:37     ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-07 16:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Philip K." <philip@warpmail.net>
>> Date: Tue, 07 Jul 2020 10:50:31 +0200
>> 
>> I wonder if anyone else shares my point of view: while useful,
>> dired-do-shell-command seems somewhat outdated. Certain file formats
>> haven't changed much, and their handling is still ok (.patch, .tar.*,
>> .sig) but especially image, video files and documents suggest tools
>> that don't seem to be installed by default on most systems (xloadimage,
>> xpdf, ...).
>> 
>> Of course this can be mitigated by using dired-guess-shell-alist-user,
>> but I think that this shouldn't be necessary. I usually just map all
>> images, videos and documents to xdg-open, and changing the values to
>> something like this wouldn't be bad a bad idea, if you ask me
>> (especially because xdg-open doesn't block).
>> 
>> So if not xdg-open (at least on GNU/Linux and other XDG-compliant
>> systems), should the default value be changed to something that makes
>> dired-do-shell-command more useful, out of the box?
>
> Can you show a concrete proposal, like which file type would you
> suggest to handle by what command?

I think it doesn't make sense to duplicate the functionalities that
already exist in modern desktop environments, so I'd propose remapping
most media files to "xdg-open", if available, which should be the case
on GNU/Linux, *BSD and similar operating system. AFAIK macOS has "open",
but I don't know if windows has an equivalent for that kind of a
system.

I imagine a option like "dired-guess-fallback" with a default value
based on the system one is running would make sense from a user
perspective.

It seems like a good compromise, because xdg-open usually does what
regular users want, even if it's configured outside of Emacs, while
power-users can be expected to customise dired-guess-shell-alist-user.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 16:10   ` Philip K.
@ 2020-07-07 18:37     ` Eli Zaretskii
  2020-07-07 19:05       ` Philip K.
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-07 18:37 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Cc: emacs-devel@gnu.org
> Date: Tue, 07 Jul 2020 18:10:24 +0200
> 
> > Can you show a concrete proposal, like which file type would you
> > suggest to handle by what command?
> 
> I think it doesn't make sense to duplicate the functionalities that
> already exist in modern desktop environments, so I'd propose remapping
> most media files to "xdg-open", if available, which should be the case
> on GNU/Linux, *BSD and similar operating system. AFAIK macOS has "open",
> but I don't know if windows has an equivalent for that kind of a
> system.

So you suggest to use xdg-open if it's available, and otherwise do
what? leave the current associations intact? or something else?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 18:37     ` Eli Zaretskii
@ 2020-07-07 19:05       ` Philip K.
  2020-07-07 19:24         ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-07 19:05 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> I think it doesn't make sense to duplicate the functionalities that
>> already exist in modern desktop environments, so I'd propose remapping
>> most media files to "xdg-open", if available, which should be the case
>> on GNU/Linux, *BSD and similar operating system. AFAIK macOS has "open",
>> but I don't know if windows has an equivalent for that kind of a
>> system.
>
> So you suggest to use xdg-open if it's available, and otherwise do
> what? leave the current associations intact? or something else?

That's what I wanted to discuss, if I had a concrete suggestion I would
have submitted a patch.

All in all, I think that xdg-open and similar commands are more
practical than for example xpdf, xloadimage, etc. Systems with xpdf,
xloadimage, etc. but without xdg-open are probably an extreme minority,
but nobody can say for sure -- and changes shouldn't come at their
expense.

I was thinking about improving the guessing system to support multiple
programs and check their existence. Assuming the structure of
dired-guess-shell-alist-default may be changed, it would seem like a
good compromise.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:05       ` Philip K.
@ 2020-07-07 19:24         ` Eli Zaretskii
  2020-07-07 19:48           ` Stefan Monnier
                             ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-07 19:24 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Cc: emacs-devel@gnu.org
> Date: Tue, 07 Jul 2020 21:05:28 +0200
> 
> > So you suggest to use xdg-open if it's available, and otherwise do
> > what? leave the current associations intact? or something else?
> 
> That's what I wanted to discuss, if I had a concrete suggestion I would
> have submitted a patch.
> 
> All in all, I think that xdg-open and similar commands are more
> practical than for example xpdf, xloadimage, etc. Systems with xpdf,
> xloadimage, etc. but without xdg-open are probably an extreme minority,
> but nobody can say for sure -- and changes shouldn't come at their
> expense.

Does xdg-open invoke different programs than what we have now in
dired-guess-shell-alist-default?  Is there a way to know what it
invokes for each file type?

I mean, you said our current database is "not modern", so that
probably means xdg-open invokes other programs, and I think it would
be good to know the differences, so we have something tangible to talk
about.

> I was thinking about improving the guessing system to support multiple
> programs and check their existence. Assuming the structure of
> dired-guess-shell-alist-default may be changed, it would seem like a
> good compromise.

Yes, possibly.  But before we discuss these details, I think it would
be good to define the outcome we are after.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:24         ` Eli Zaretskii
@ 2020-07-07 19:48           ` Stefan Monnier
  2020-07-08  2:25             ` Eli Zaretskii
  2020-07-07 19:52           ` Yuri Khan
  2020-07-07 20:38           ` Philip K.
  2 siblings, 1 reply; 25+ messages in thread
From: Stefan Monnier @ 2020-07-07 19:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Philip K., emacs-devel

> So you suggest to use xdg-open if it's available, and otherwise do
> what? leave the current associations intact? or something else?

Actually, that might be a good&simple solution, yes.

> Does xdg-open invoke different programs than what we have now in
> dired-guess-shell-alist-default?

It all depends on the system you have (and the tools that are
installed), but yes, xpdf and xloadimage seem rather outdated (they
still exist but are much less popular than they once were).

> Is there a way to know what it invokes for each file type?

Do you mean for use to know statistically what it uses most often,
or for Emacs to determine it at runtime?


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:24         ` Eli Zaretskii
  2020-07-07 19:48           ` Stefan Monnier
@ 2020-07-07 19:52           ` Yuri Khan
  2020-07-08  2:26             ` Eli Zaretskii
  2020-07-07 20:38           ` Philip K.
  2 siblings, 1 reply; 25+ messages in thread
From: Yuri Khan @ 2020-07-07 19:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Philip K., Emacs developers

On Wed, 8 Jul 2020 at 02:24, Eli Zaretskii <eliz@gnu.org> wrote:

> I mean, you said our current database is "not modern", so that
> probably means xdg-open invokes other programs, and I think it would
> be good to know the differences, so we have something tangible to talk
> about.

What xdg-open invokes depends on the installed applications and, if
multiple applications are registered for handling a MIME type, on user
preferences.

On Windows, the closest analogy is file type associations via the registry.

Both are better than a hard-coded list of applications that might or
might not be installed on the user’s machine, and, if installed, might
or might not be their preference.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:24         ` Eli Zaretskii
  2020-07-07 19:48           ` Stefan Monnier
  2020-07-07 19:52           ` Yuri Khan
@ 2020-07-07 20:38           ` Philip K.
  2020-07-08  2:28             ` Eli Zaretskii
  2 siblings, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-07 20:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Does xdg-open invoke different programs than what we have now in
> dired-guess-shell-alist-default?  Is there a way to know what it
> invokes for each file type?
>
> I mean, you said our current database is "not modern", so that
> probably means xdg-open invokes other programs, and I think it would
> be good to know the differences, so we have something tangible to talk
> about.

It will usually invoke whatever is the default on a given system, so for
a .pdf a GNOME desktop would use Evince while KDE would open it in
Okular. If a user changes their "preferred applications", xdg-open should
also change it's behaviour (hence the point with "configured outside of
Emacs" I mentioned before).

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:48           ` Stefan Monnier
@ 2020-07-08  2:25             ` Eli Zaretskii
  2020-07-08  4:12               ` Stefan Monnier
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-08  2:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: philip, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: "Philip K." <philip@warpmail.net>,  emacs-devel@gnu.org
> Date: Tue, 07 Jul 2020 15:48:26 -0400
> 
> > So you suggest to use xdg-open if it's available, and otherwise do
> > what? leave the current associations intact? or something else?
> 
> Actually, that might be a good&simple solution, yes.

If the current associations are way off, that would be simple but
somewhat wrong, IMO.

> > Does xdg-open invoke different programs than what we have now in
> > dired-guess-shell-alist-default?
> 
> It all depends on the system you have (and the tools that are
> installed), but yes, xpdf and xloadimage seem rather outdated (they
> still exist but are much less popular than they once were).

What is used in their stead?

> > Is there a way to know what it invokes for each file type?
> 
> Do you mean for use to know statistically what it uses most often,
> or for Emacs to determine it at runtime?

The former.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 19:52           ` Yuri Khan
@ 2020-07-08  2:26             ` Eli Zaretskii
  2020-07-08  2:48               ` Michael Welsh Duggan
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-08  2:26 UTC (permalink / raw)
  To: Yuri Khan; +Cc: philip, emacs-devel

> From: Yuri Khan <yuri.v.khan@gmail.com>
> Date: Wed, 8 Jul 2020 02:52:07 +0700
> Cc: "Philip K." <philip@warpmail.net>, Emacs developers <emacs-devel@gnu.org>
> 
> On Wed, 8 Jul 2020 at 02:24, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> > I mean, you said our current database is "not modern", so that
> > probably means xdg-open invokes other programs, and I think it would
> > be good to know the differences, so we have something tangible to talk
> > about.
> 
> What xdg-open invokes depends on the installed applications and, if
> multiple applications are registered for handling a MIME type, on user
> preferences.
> 
> On Windows, the closest analogy is file type associations via the registry.
> 
> Both are better than a hard-coded list of applications that might or
> might not be installed on the user’s machine, and, if installed, might
> or might not be their preference.

Thanks, I think everyone agrees with these general principles.  I was
asking whether we have enough information to provide practical
solutions for Posix hosts that don't have xdg-open.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07 20:38           ` Philip K.
@ 2020-07-08  2:28             ` Eli Zaretskii
  2020-07-08  4:15               ` Stefan Monnier
  2020-07-08  8:28               ` Philip K.
  0 siblings, 2 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-08  2:28 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Cc: emacs-devel@gnu.org
> Date: Tue, 07 Jul 2020 22:38:47 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Does xdg-open invoke different programs than what we have now in
> > dired-guess-shell-alist-default?  Is there a way to know what it
> > invokes for each file type?
> >
> > I mean, you said our current database is "not modern", so that
> > probably means xdg-open invokes other programs, and I think it would
> > be good to know the differences, so we have something tangible to talk
> > about.
> 
> It will usually invoke whatever is the default on a given system, so for
> a .pdf a GNOME desktop would use Evince while KDE would open it in
> Okular. If a user changes their "preferred applications", xdg-open should
> also change it's behaviour (hence the point with "configured outside of
> Emacs" I mentioned before).

I presume the list of those candidate applications is short and known
in advance, so I thought perhaps on Posix systems where xdg-open is
not available we could try them one by one until we find one that's
installed?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  2:26             ` Eli Zaretskii
@ 2020-07-08  2:48               ` Michael Welsh Duggan
  2020-07-08  7:52                 ` tomas
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Welsh Duggan @ 2020-07-08  2:48 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Yuri Khan <yuri.v.khan@gmail.com>
>> Date: Wed, 8 Jul 2020 02:52:07 +0700
>> Cc: "Philip K." <philip@warpmail.net>, Emacs developers <emacs-devel@gnu.org>
>> 
>> On Wed, 8 Jul 2020 at 02:24, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>> > I mean, you said our current database is "not modern", so that
>> > probably means xdg-open invokes other programs, and I think it would
>> > be good to know the differences, so we have something tangible to talk
>> > about.
>> 
>> What xdg-open invokes depends on the installed applications and, if
>> multiple applications are registered for handling a MIME type, on user
>> preferences.
>> 
>> On Windows, the closest analogy is file type associations via the registry.
>> 
>> Both are better than a hard-coded list of applications that might or
>> might not be installed on the user’s machine, and, if installed, might
>> or might not be their preference.
>
> Thanks, I think everyone agrees with these general principles.  I was
> asking whether we have enough information to provide practical
> solutions for Posix hosts that don't have xdg-open.

I looked into this a little, and it seems that this is more complicated
than I thought it might be.  I found this post on stackexchange:
https://unix.stackexchange.com/questions/144047/how-does-xdg-open-do-its-work

Seeing that xdg-open is a shell script, I poked around a little, and
there's an extensive tree of programs to use to try and figure out what
to do.  Even open_generic runs the gamut of using xdg-mime, using
mailcap, using mimeopen, and more.  In essence, xdg-open goes through a
lot of testing and checks to try to find a xdg-open-like program to
which it can delegate the opening of the file.

Most of the major desktops seem to have a way to maintain the file to
program mapping, but they all seem to do it differently.

-- 
Michael Welsh Duggan
(md5i@md5i.com)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  2:25             ` Eli Zaretskii
@ 2020-07-08  4:12               ` Stefan Monnier
  0 siblings, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2020-07-08  4:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: philip, emacs-devel

>> It all depends on the system you have (and the tools that are
>> installed), but yes, xpdf and xloadimage seem rather outdated (they
>> still exist but are much less popular than they once were).
> What is used in their stead?

Not sure what's standard.  I think it depends on lots of factors (such
as the main desktop environment in use).  In a Gnome desktop, I'd expect
`evince` to be used for PDF and for images ... not sure ... `display`
(from Imagemagick) or `eog`, maybe?

>> > Is there a way to know what it invokes for each file type?
>> Do you mean for use to know statistically what it uses most often,
>> or for Emacs to determine it at runtime?
> The former.

I guess we should look at what happens on a "stock" install of
Ubuntu/Debian/Fedora to see that.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  2:28             ` Eli Zaretskii
@ 2020-07-08  4:15               ` Stefan Monnier
  2020-07-08 14:21                 ` Eli Zaretskii
  2020-07-08  8:28               ` Philip K.
  1 sibling, 1 reply; 25+ messages in thread
From: Stefan Monnier @ 2020-07-08  4:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Philip K., emacs-devel

> I presume the list of those candidate applications is short and known
> in advance, so I thought perhaps on Posix systems where xdg-open is
> not available we could try them one by one until we find one that's
> installed?

I'm not sure it's worth the trouble.  Using `xdg-open` if it's installed
is already a significant improvement over what we have, I think, and
it brings no downside to those who don't have it.
And I haven't heard anyone without `xdg-open` ask for improvements in
this area.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  2:48               ` Michael Welsh Duggan
@ 2020-07-08  7:52                 ` tomas
  0 siblings, 0 replies; 25+ messages in thread
From: tomas @ 2020-07-08  7:52 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

On Tue, Jul 07, 2020 at 10:48:43PM -0400, Michael Welsh Duggan wrote:

[...]

> I looked into this a little [...]

> Seeing that xdg-open is a shell script, I poked around a little, and
> there's an extensive tree of programs to use to try and figure out what
> to do [...]

Yes, those freedesktop things have sometimes a tendency towards the
Rube Goldbergesque. Alas.

> Most of the major desktops seem to have a way to maintain the file to
> program mapping, but they all seem to do it differently.

It was a good idea. It ended up a bit of an xkcd927 [1]. Was worth a try,
though.

Cheers
[1] https://xkcd.com/927/
-- t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  2:28             ` Eli Zaretskii
  2020-07-08  4:15               ` Stefan Monnier
@ 2020-07-08  8:28               ` Philip K.
  2020-07-08 14:24                 ` Eli Zaretskii
  1 sibling, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-08  8:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> I presume the list of those candidate applications is short and known
> in advance, so I thought perhaps on Posix systems where xdg-open is
> not available we could try them one by one until we find one that's
> installed?

This sounds good, but will it work on non-POSIX systems too, or in
environments without any of the usual programmes?

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  4:15               ` Stefan Monnier
@ 2020-07-08 14:21                 ` Eli Zaretskii
  2020-07-08 15:08                   ` Stefan Monnier
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-08 14:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: philip, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: "Philip K." <philip@warpmail.net>,  emacs-devel@gnu.org
> Date: Wed, 08 Jul 2020 00:15:14 -0400
> 
> > I presume the list of those candidate applications is short and known
> > in advance, so I thought perhaps on Posix systems where xdg-open is
> > not available we could try them one by one until we find one that's
> > installed?
> 
> I'm not sure it's worth the trouble.  Using `xdg-open` if it's installed
> is already a significant improvement over what we have, I think, and
> it brings no downside to those who don't have it.
> And I haven't heard anyone without `xdg-open` ask for improvements in
> this area.

If the consensus is that systems which lack xdg-open can fall back on
what we have now, I'm fine with doing that.  I just thought originally
that what we have now is somewhat very wrong, not because it bypasses
xdg-open, but because it calls the wrong programs; so I wanted to see
if we could improve the fallbacks as well.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08  8:28               ` Philip K.
@ 2020-07-08 14:24                 ` Eli Zaretskii
  2020-07-08 14:33                   ` Philip K.
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-08 14:24 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Cc: emacs-devel@gnu.org
> Date: Wed, 08 Jul 2020 10:28:43 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I presume the list of those candidate applications is short and known
> > in advance, so I thought perhaps on Posix systems where xdg-open is
> > not available we could try them one by one until we find one that's
> > installed?
> 
> This sounds good, but will it work on non-POSIX systems too, or in
> environments without any of the usual programmes?

I'm not sure I follow: what is "it" in "will it work" above?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08 14:24                 ` Eli Zaretskii
@ 2020-07-08 14:33                   ` Philip K.
  0 siblings, 0 replies; 25+ messages in thread
From: Philip K. @ 2020-07-08 14:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> > I presume the list of those candidate applications is short and known
>> > in advance, so I thought perhaps on Posix systems where xdg-open is
>> > not available we could try them one by one until we find one that's
>> > installed?
>> 
>> This sounds good, but will it work on non-POSIX systems too, or in
>> environments without any of the usual programmes?
>
> I'm not sure I follow: what is "it" in "will it work" above?

The approach. But disregard the question, I must have misread your
comment and was worried about how a e.g. Emacs on Windows would handle
it, but that shouldn't be an issue, if whatever their default PDF
program is also in the list.

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-08 14:21                 ` Eli Zaretskii
@ 2020-07-08 15:08                   ` Stefan Monnier
  0 siblings, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2020-07-08 15:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: philip, emacs-devel

> If the consensus is that systems which lack xdg-open can fall back on
> what we have now, I'm fine with doing that.  I just thought originally
> that what we have now is somewhat very wrong, not because it bypasses
> xdg-open, but because it calls the wrong programs; so I wanted to see
> if we could improve the fallbacks as well.

We can probably improve the fallbacks, but I think it's orthogonal,


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-07  8:50 Updating dired-guess-shell-alist-default Philip K.
  2020-07-07 14:19 ` Eli Zaretskii
@ 2020-07-09 16:21 ` Philip K.
  2020-07-11 10:07   ` Eli Zaretskii
  1 sibling, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-09 16:21 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]


I've tried to implement something that picks xdg-open or an equivalent
default on other systems, and if not found looks for other popular
applications. 

Note: The database isn't completely updated, but I wanted to check back
and see if anyone would like to comment on the approach.

"Philip K." <philip@warpmail.net> writes:

> Hi,
>
> I wonder if anyone else shares my point of view: while useful,
> dired-do-shell-command seems somewhat outdated. Certain file formats
> haven't changed much, and their handling is still ok (.patch, .tar.*,
> .sig) but especially image, video files and documents suggest tools
> that don't seem to be installed by default on most systems (xloadimage,
> xpdf, ...).
>
> Of course this can be mitigated by using dired-guess-shell-alist-user,
> but I think that this shouldn't be necessary. I usually just map all
> images, videos and documents to xdg-open, and changing the values to
> something like this wouldn't be bad a bad idea, if you ask me
> (especially because xdg-open doesn't block).
>
> So if not xdg-open (at least on GNU/Linux and other XDG-compliant
> systems), should the default value be changed to something that makes
> dired-do-shell-command more useful, out of the box?

-- 
	Philip K.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired-x-guess.patch --]
[-- Type: text/x-diff, Size: 3783 bytes --]

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 873d586ca1..a4bb68ae1f 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -834,6 +834,22 @@ dired-shell-command-history
 (autoload 'Man-support-local-filenames "man")
 (autoload 'vc-responsible-backend "vc")
 
+(defcustom dired-guess-default-media-command
+  (cond ((eq system-type 'windows-nt)   "start")
+        ((eq system-type 'darwin)       "open")
+        ((executable-find "xdg-open")   "xdg-open"))
+  "Default command to use for opening media files."
+  :type '(choice (const :tag "No default command" nil)
+                 (string :tag "Command"))
+  :version "28.1")
+
+(defun dired-guess-find-command (&rest cmds)
+  (or dired-guess-default-media-command
+      (catch 'exists
+        (dolist (cmd cmds)
+          (when (executable-find cmd)
+            (throw 'exists cmd))))))
+
 (defvar dired-guess-shell-alist-default
   (list
    (list "\\.tar\\'"
@@ -956,7 +972,9 @@ dired-guess-shell-alist-default
 		  " " dired-guess-shell-znew-switches))
    '("\\.pod\\'" "perldoc" "pod2man * | nroff -man")
 
-   '("\\.dvi\\'" "xdvi" "dvips")	; preview and printing
+   '("\\.dvi\\'"
+     (dired-guess-find-command "evince" "okular" "atril")
+     "xdvi" "dvips")                    ; preview and printing
    '("\\.au\\'" "play")			; play Sun audiofiles
    '("\\.mpe?g\\'\\|\\.avi\\'" "xine -p")
    '("\\.ogg\\'" "ogg123")
@@ -967,16 +985,33 @@ dired-guess-shell-alist-default
    '("\\.sh\\'" "sh")			; execute shell scripts
    '("\\.xbm\\'" "bitmap")		; view X11 bitmaps
    '("\\.gp\\'" "gnuplot")
-   '("\\.p[bgpn]m\\'" "xloadimage")
-   '("\\.gif\\'" "xloadimage")		; view gif pictures
-   '("\\.tif\\'" "xloadimage")
-   '("\\.png\\'" "display")		; xloadimage 4.1 doesn't grok PNG
-   '("\\.jpe?g\\'" "xloadimage")
+   '("\\.p[bgpn]m\\'"
+     (dired-guess-find-command "eog" "eom" "feh" "shotwell" "ristretto"
+                               "gthumb" "gwenview")
+     "xloadimage")
+   '("\\.gif\\'"
+     (dired-guess-find-command "eog" "eom" "shotwell" "ristretto"
+                               "gthumb" "gwenview")
+     "xloadimage")
+   '("\\.tif\\'"
+     (dired-guess-find-command "eog" "eom" "feh" "shotwell" "ristretto"
+                               "gthumb" "gwenview")
+     "xloadimage")
+   '("\\.png\\'"
+     (dired-guess-find-command "eog" "eom" "feh" "shotwell" "ristretto"
+                               "gthumb" "gwenview")
+     "display")                      ; xloadimage 4.1 doesn't grok PNG
+   '("\\.jpe?g\\'"
+     (dired-guess-find-command "eog" "eom" "feh" "shotwell" "ristretto"
+                               "gthumb" "gwenview")
+     "xloadimage")
    '("\\.fig\\'" "xfig")		; edit fig pictures
    '("\\.out\\'" "xgraph")		; for plotting purposes.
    '("\\.tex\\'" "latex" "tex")
    '("\\.texi\\(nfo\\)?\\'" "makeinfo" "texi2dvi")
-   '("\\.pdf\\'" "xpdf")
+   '("\\.pdf\\'"
+     (dired-guess-find-command "evince" "okular" "atril" "mupdf" "zathura")
+     "xpdf")
    '("\\.doc\\'" "antiword" "strings")
    '("\\.rpm\\'" "rpm -qilp" "rpm -ivh")
    '("\\.dia\\'" "dia")
@@ -1069,9 +1104,10 @@ dired-guess-default
 
     ;; Return commands or nil if flist is still non-nil.
     ;; Evaluate the commands in order that any logical testing will be done.
-    (if (cdr cmds)
-	(delete-dups (mapcar (lambda (cmd) (eval cmd `((file . ,file)))) cmds))
-      (eval (car cmds) `((file . ,file))))))		; single command
+    (setq cmds (delete-dups (delq nil (mapcar
+                                       (lambda (cmd) (eval cmd `((file . ,file))))
+                                       cmds))))
+    (if (cdr cmds) cmds (car cmds))))
 
 (defun dired-guess-shell-command (prompt files)
   "Ask user with PROMPT for a shell command, guessing a default from FILES."

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-09 16:21 ` Philip K.
@ 2020-07-11 10:07   ` Eli Zaretskii
  2020-07-11 11:07     ` Philip K.
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-11 10:07 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Date: Thu, 09 Jul 2020 18:21:48 +0200
> 
> I've tried to implement something that picks xdg-open or an equivalent
> default on other systems, and if not found looks for other popular
> applications. 

Thanks.

> +(defcustom dired-guess-default-media-command
> +  (cond ((eq system-type 'windows-nt)   "start")
> +        ((eq system-type 'darwin)       "open")
> +        ((executable-find "xdg-open")   "xdg-open"))
> +  "Default command to use for opening media files."
> +  :type '(choice (const :tag "No default command" nil)
> +                 (string :tag "Command"))
> +  :version "28.1")

I think for MS-Windows this should use w32-shell-execute with
OPERATION set to "open".



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-11 10:07   ` Eli Zaretskii
@ 2020-07-11 11:07     ` Philip K.
  2020-07-11 11:15       ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Philip K. @ 2020-07-11 11:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> +(defcustom dired-guess-default-media-command
>> +  (cond ((eq system-type 'windows-nt)   "start")
>> +        ((eq system-type 'darwin)       "open")
>> +        ((executable-find "xdg-open")   "xdg-open"))
>> +  "Default command to use for opening media files."
>> +  :type '(choice (const :tag "No default command" nil)
>> +                 (string :tag "Command"))
>> +  :version "28.1")
>
> I think for MS-Windows this should use w32-shell-execute with
> OPERATION set to "open".

I don't have access to a Windows machine, but from asking a friend who
tested it, start should do the equivalent of open/xdg-open. What would
the reason be to prefer w32-shell-execute over "start"?

-- 
	Philip K.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Updating dired-guess-shell-alist-default
  2020-07-11 11:07     ` Philip K.
@ 2020-07-11 11:15       ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-07-11 11:15 UTC (permalink / raw)
  To: Philip K.; +Cc: emacs-devel

> From: "Philip K." <philip@warpmail.net>
> Cc: emacs-devel@gnu.org
> Date: Sat, 11 Jul 2020 13:07:31 +0200
> 
> > I think for MS-Windows this should use w32-shell-execute with
> > OPERATION set to "open".
> 
> I don't have access to a Windows machine, but from asking a friend who
> tested it, start should do the equivalent of open/xdg-open. What would
> the reason be to prefer w32-shell-execute over "start"?

It doesn't involve starting another program (either cmd.exe or 'start'
itself), and it works equally well on all versions of Windows, whereas
'start' changed its behavior at least twice.

But if we want to invoke a shell command, then I guess 'start' would
be fine.  Juts remember that dired-shell-stuff-it invokes 'start' as
well.



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2020-07-11 11:15 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07  8:50 Updating dired-guess-shell-alist-default Philip K.
2020-07-07 14:19 ` Eli Zaretskii
2020-07-07 16:10   ` Philip K.
2020-07-07 18:37     ` Eli Zaretskii
2020-07-07 19:05       ` Philip K.
2020-07-07 19:24         ` Eli Zaretskii
2020-07-07 19:48           ` Stefan Monnier
2020-07-08  2:25             ` Eli Zaretskii
2020-07-08  4:12               ` Stefan Monnier
2020-07-07 19:52           ` Yuri Khan
2020-07-08  2:26             ` Eli Zaretskii
2020-07-08  2:48               ` Michael Welsh Duggan
2020-07-08  7:52                 ` tomas
2020-07-07 20:38           ` Philip K.
2020-07-08  2:28             ` Eli Zaretskii
2020-07-08  4:15               ` Stefan Monnier
2020-07-08 14:21                 ` Eli Zaretskii
2020-07-08 15:08                   ` Stefan Monnier
2020-07-08  8:28               ` Philip K.
2020-07-08 14:24                 ` Eli Zaretskii
2020-07-08 14:33                   ` Philip K.
2020-07-09 16:21 ` Philip K.
2020-07-11 10:07   ` Eli Zaretskii
2020-07-11 11:07     ` Philip K.
2020-07-11 11:15       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).