diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-03-09 19:01:19 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-03-09 19:02:35 -0800 |
commit | 26848af97f333c4699934a545eb2888b1006b326 (patch) | |
tree | c455bb6e73d9706f290e8c6b26c31fc3c12ebcef /lisp/net/browse-url.el | |
parent | 092071345f265efcd3abd6de01552ebe95ffb9a1 (diff) | |
download | emacs-26848af97f333c4699934a545eb2888b1006b326.tar.gz |
Simplify checks for xdg-open and xdg-email
browse-url's xdg-open detection was too picky on some GNU/Linux
desktops; see Bug#25778. Simplify the code by assuming xdg-open works
if it is executable, as nowadays this is more likely to be correct than
trying to use heuristics from a few years ago. Don't test for nohup: it
is ineffective nowadays, as xdg-open's child uses the default action for
SIGHUP even if xdg-open's invoker ignores SIGHUP. While we're at it,
allow for Wayland here, as "emacs -nw" might be running in a non-X
Wayland terminal.
* lisp/mail/emacsbug.el (report-emacs-bug-can-use-xdg-email):
* lisp/net/browse-url.el (browse-url-can-use-xdg-open):
Simplify to a test for DISPLAY and whether the helper program is
executable. Allow WAYLAND_DISPLAY as an option.
Diffstat (limited to 'lisp/net/browse-url.el')
-rw-r--r-- | lisp/net/browse-url.el | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 04b49c44313..20ae072f652 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -45,7 +45,7 @@ ;; browse-url-generic arbitrary ;; browse-url-default-windows-browser MS-Windows browser ;; browse-url-default-macosx-browser macOS browser -;; browse-url-xdg-open Free Desktop xdg-open on Gnome, KDE, Xfce4, LXDE +;; browse-url-xdg-open freedesktop.org xdg-open ;; browse-url-kde KDE konqueror (kfm) ;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT) @@ -944,36 +944,14 @@ instead of `browse-url-new-window-flag'." (defun browse-url-can-use-xdg-open () "Return non-nil if the \"xdg-open\" program can be used. -xdg-open is a desktop utility that calls your preferred web browser. -This requires you to be running either Gnome, KDE, Xfce4 or LXDE." - (and (getenv "DISPLAY") - (executable-find "xdg-open") - ;; xdg-open may call gnome-open and that does not wait for its child - ;; to finish. This child may then be killed when the parent dies. - ;; Use nohup to work around. See bug#7166, bug#8917, bug#9779 and - ;; http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg00279.html - (executable-find "nohup") - (or (getenv "GNOME_DESKTOP_SESSION_ID") - ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also. - (condition-case nil - (eq 0 (call-process - "dbus-send" nil nil nil - "--dest=org.gnome.SessionManager" - "--print-reply" - "/org/gnome/SessionManager" - "org.gnome.SessionManager.CanShutdown")) - (error nil)) - (equal (getenv "KDE_FULL_SESSION") "true") - (condition-case nil - (eq 0 (call-process - "/bin/sh" nil nil nil - "-c" - ;; FIXME use string-match rather than grep. - "xprop -root _DT_SAVE_MODE|grep xfce4")) - (error nil)) - (member (getenv "DESKTOP_SESSION") '("LXDE" "Lubuntu")) - (equal (getenv "XDG_CURRENT_DESKTOP") "LXDE")))) - +xdg-open is a desktop utility that calls your preferred web browser." + ;; The exact set of situations where xdg-open works is complicated, + ;; and it would be a pain to duplicate xdg-open's situation-specific + ;; code here, as the code is a moving target. So assume that + ;; xdg-open will work if there is a graphical display; this should + ;; be good enough for platforms Emacs is likely to be running on. + (and (or (getenv "DISPLAY") (getenv "WAYLAND_DISPLAY")) + (executable-find "xdg-open"))) ;;;###autoload (defun browse-url-xdg-open (url &optional ignored) |