* Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
@ 2014-11-07 11:04 Florian v. Savigny
2014-11-08 17:19 ` bug#18986: " Jan D.
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Florian v. Savigny @ 2014-11-07 11:04 UTC (permalink / raw)
To: bug-gnu-emacs; +Cc: Denis Howe, emacs-devel
Dear maintainers/authors,
browse-url-can-use-xdg-open returns t only if emacs is running under one of the desktop environments, i.e. Gnome, KDE, Xfce4 or LXDE.
I do not know the deeper reasons for this, but from experience, I can confirm that this running under a desktop environment may be sufficient, but is not necessary: My emacs is running under fvwm, and xdg-open works fine. (You have to know how to configure it, but that is no dark magic either; I do it via ~/.local/share/applications/mimeapps.list.)
My guess is that it would be sufficient to check for the existence of the xdg-open binary. The condition of one of the desktop environments being run is somewhat annoying, because when not fulfilled, it causes browse-url-default-browser, which is often employed to open a URL, to default to mozilla (or whatever follows in its hardcoded list), which may not be exactly what you want. Effectively, it makes it impossible to specify your favourite browser without some kludgy hack.
I have included some of the information produced by M-x report-emacs-bug, but since I am fairly certain that most of it is irrelevant, I have left it out:
In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.3)
of 2014-10-21 on bitzer.hoetzel.info
Windowing system distributor `The X.Org Foundation', version 11.0.11601000
Configured using:
`configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
-fstack-protector-strong --param=ssp-buffer-size=4'
CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
Important settings:
value of $LANG: de_DE.ISO-8859-1
locale-coding-system: iso-latin-1-unix
Best regards,
Florian v. Savigny
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#18986: Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
2014-11-07 11:04 Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption Florian v. Savigny
@ 2014-11-08 17:19 ` Jan D.
[not found] ` <E1A681AD-2DC5-4143-B7ED-F179A8856D6B@swipnet.se>
2018-02-12 16:23 ` bug#18986: #18986 " Pierre Neidhardt
2 siblings, 0 replies; 12+ messages in thread
From: Jan D. @ 2014-11-08 17:19 UTC (permalink / raw)
To: Florian v. Savigny; +Cc: Denis Howe, 18986-done, emacs development
Hello.
It used to be that xdg-open just called the desktop version, i.e. gnome-open, kde-open and so on. It is not sufficient that xdg-open exists for the most part. We can't cater for every window manager out there, we have to go by the majority. If you can make xdg-open work, then making Emacs use it should be easy.
Jan D.
> 7 nov 2014 kl. 12:04 skrev Florian v. Savigny <florian@fsavigny.de>:
>
>
>
> Dear maintainers/authors,
>
> browse-url-can-use-xdg-open returns t only if emacs is running under one of the desktop environments, i.e. Gnome, KDE, Xfce4 or LXDE.
>
> I do not know the deeper reasons for this, but from experience, I can confirm that this running under a desktop environment may be sufficient, but is not necessary: My emacs is running under fvwm, and xdg-open works fine. (You have to know how to configure it, but that is no dark magic either; I do it via ~/.local/share/applications/mimeapps.list.)
>
> My guess is that it would be sufficient to check for the existence of the xdg-open binary. The condition of one of the desktop environments being run is somewhat annoying, because when not fulfilled, it causes browse-url-default-browser, which is often employed to open a URL, to default to mozilla (or whatever follows in its hardcoded list), which may not be exactly what you want. Effectively, it makes it impossible to specify your favourite browser without some kludgy hack.
>
> I have included some of the information produced by M-x report-emacs-bug, but since I am fairly certain that most of it is irrelevant, I have left it out:
>
>
> In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.3)
> of 2014-10-21 on bitzer.hoetzel.info
> Windowing system distributor `The X.Org Foundation', version 11.0.11601000
> Configured using:
> `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
> --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
> 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
> -fstack-protector-strong --param=ssp-buffer-size=4'
> CPPFLAGS=-D_FORTIFY_SOURCE=2
> LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
>
> Important settings:
> value of $LANG: de_DE.ISO-8859-1
> locale-coding-system: iso-latin-1-unix
>
>
> Best regards,
>
> Florian v. Savigny
>
>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <E1A681AD-2DC5-4143-B7ED-F179A8856D6B@swipnet.se>]
* bug#18986: Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
[not found] ` <E1A681AD-2DC5-4143-B7ED-F179A8856D6B@swipnet.se>
@ 2014-11-08 18:05 ` Stefan Monnier
2014-11-15 12:31 ` Florian v. Savigny
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2014-11-08 18:05 UTC (permalink / raw)
To: Jan D.; +Cc: Florian v. Savigny, 18986-done, Denis Howe, emacs development
> It used to be that xdg-open just called the desktop version,
> i.e. gnome-open, kde-open and so on. It is not sufficient that xdg-open
> exists for the most part. We can't cater for every window manager out
> there, we have to go by the majority. If you can make xdg-open work, then
> making Emacs use it should be easy.
The problem was specifically that just having xdg-open installed doesn't
guarantee that the user has configured it.
The code currently approximate "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.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#18986: Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
2014-11-08 18:05 ` Stefan Monnier
@ 2014-11-15 12:31 ` Florian v. Savigny
0 siblings, 0 replies; 12+ messages in thread
From: Florian v. Savigny @ 2014-11-15 12:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: dbh, 18986-done, emacs-devel
> From: Stefan Monnier <monnier@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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#18986: #18986 Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
2014-11-07 11:04 Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption Florian v. Savigny
2014-11-08 17:19 ` bug#18986: " Jan D.
[not found] ` <E1A681AD-2DC5-4143-B7ED-F179A8856D6B@swipnet.se>
@ 2018-02-12 16:23 ` Pierre Neidhardt
2018-02-12 17:47 ` Eli Zaretskii
2 siblings, 1 reply; 12+ messages in thread
From: Pierre Neidhardt @ 2018-02-12 16:23 UTC (permalink / raw)
To: 18986
[-- Attachment #1: Type: text/plain, Size: 939 bytes --]
Sorry for digging out this old issue, but it seemed that Florian's
suggestion (which was pretty good in my opinion) was never answered.
I've been battling with browse-url for longer than necessary, it seems
to me that there are just too many rough edges around xdg-open,
xdg-mime, ~/.config/mimeapps.list, `mailcap-mime-extensions'...
Having `browse-url-can-use-xdg-open' _and_ a customizable list of
default browser in `browse-url-default-browser' would help tremendously.
I'd like to add one more feature which could relieve non-DE users even further:
(defun browse-url-default-browser (url &rest args)
...
(apply
(cond
...
+ ((getenv "BROWSER") (executable-find (getenv "BROWSER")))
((memq system-type '(windows-nt ms-dos cygwin))
'browse-url-default-windows-browser)
The "BROWSER" environment variable is relativement common and if it is
set, it most probably means that the users did that themselves.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#18986: #18986 Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption
2018-02-12 16:23 ` bug#18986: #18986 " Pierre Neidhardt
@ 2018-02-12 17:47 ` Eli Zaretskii
2018-02-12 17:51 ` Pierre Neidhardt
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2018-02-12 17:47 UTC (permalink / raw)
To: Pierre Neidhardt; +Cc: 18986
> From: Pierre Neidhardt <ambrevar@gmail.com>
> Date: Mon, 12 Feb 2018 17:23:26 +0100
>
> Sorry for digging out this old issue, but it seemed that Florian's
> suggestion (which was pretty good in my opinion) was never answered.
What version of Emacs are you looking at?
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-02-16 0:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 11:04 Design bug in browse-url.el: browse-url-can-use-xdg-open's logic uses overly strict assumption Florian v. Savigny
2014-11-08 17:19 ` bug#18986: " Jan D.
[not found] ` <E1A681AD-2DC5-4143-B7ED-F179A8856D6B@swipnet.se>
2014-11-08 18:05 ` Stefan Monnier
2014-11-15 12:31 ` Florian v. Savigny
2018-02-12 16:23 ` bug#18986: #18986 " Pierre Neidhardt
2018-02-12 17:47 ` Eli Zaretskii
2018-02-12 17:51 ` Pierre Neidhardt
2018-02-12 18:42 ` Eli Zaretskii
2018-02-14 21:46 ` Pierre Neidhardt
2018-02-15 2:14 ` Noam Postavsky
2018-02-16 0:28 ` Pierre Neidhardt
2018-02-16 0:42 ` Pierre Neidhardt
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).