GNU bug report logs - #18986
Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption

Previous Next

Package: emacs;

Reported by: "Florian v. Savigny" <florian <at> fsavigny.de>

Date: Fri, 7 Nov 2014 16:44:02 UTC

Severity: normal

Tags: patch

Merged with 25778

Found in version 25.1

Fixed in version 26.1

Done: "Jan D." <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: florian <at> fsavigny.de (Florian v. Savigny)
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: dbh <at> doc.ic.ac.uk, jan.h.d <at> swipnet.se, 18986-done <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: bug#18986: Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
Date: Sat, 15 Nov 2014 13:31:39 +0100


  > From: Stefan Monnier <monnier <at> iro.umontreal.ca>
  > Date: Sat, 08 Nov 2014 13:05:54 -0500
  > 
  > The problem was specifically that just having xdg-open installed
  > doesn't guarantee that the user has configured it.  The code
  > currently approximates "is it configured" by checking the desktop
  > environment in use.  It's clearly a gross hack (or a crude
  > approximation), so if you know a better way, we'd like to hear it.


Thank you very much for your feedback!

It would seem to me that checking if

   xdg-mime query default text/html

or, in a more general way, perhaps

   xdg-mime query default `xdg-mime query filetype URL/FILE`

returns SOMETHING should be sufficient.

I am absolutely NOT sure, I have to admit, because I have found the
documentation for the xdg system not very accessible if you are
interested in manual configuration, and lack the time to study it
hard.

I have found that what the above command returns is not necessarily
what xdg-open will actually run (i.e. it does not seem to reflect user
reconfiguration - which is probably why the query is called
"default"), but it would seem to me that if it returns SOMETHING,
there is a guarantee that there is a default, which in turn guarantees
that xdg-open will start SOMETHING.

This line of thought assumes that /usr/share/applications/*.desktop
files for any given application will ONLY be there if the application
itself is also installed, i.e. that they both come with the same
package. I think that this is the case for any distribution I have
used so far.

Even if this assumption is unsafe, I think one could check if the
return value of xdg-open is 3 or 4, which could then lead to a message
such as "Please configure your xdg system properly; see man xdg-mime
or your desktop environment's configuration tool" and/or to some
fallback action (which browse-url is already capable of). Of course,
this last measure could not be implemented within the
browse-url-can-use-xdg-open function.

An alternative approach (which would however not be mutually exclusive
with the above) might be to make the hardcoded browser list in
browse-url-default-browser customisable, which currently forces an
order of preference on the user as follows:


browse-url-gnome-moz-program
browse-url-mozilla-program
browse-url-firefox-program
browse-url-chromium-program
browse-url-galeon-program
browse-url-kde-program
browse-url-netscape-program
browse-url-mosaic-program
browse-url-xterm-program


The reason why I am somehow uncomfortable with browse-url's logic of
determining a browser to start is that I find it effectively (if most
probably not intentionally) patronising, and this is, in my view,
unusual for Emacs - out of character, as it were.

I would like to apologise if my suggestions are not sufficiently
substantial.

Best regards,

-- 

Florian von Savigny
Melanchthonstr. 41
33615 Bielefeld




This bug report was last modified 7 years and 98 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.