diff options
| author | Paul Eggert | 2017-03-09 19:01:19 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-03-09 19:02:35 -0800 |
| commit | 26848af97f333c4699934a545eb2888b1006b326 (patch) | |
| tree | c455bb6e73d9706f290e8c6b26c31fc3c12ebcef | |
| parent | 092071345f265efcd3abd6de01552ebe95ffb9a1 (diff) | |
| download | emacs-26848af97f333c4699934a545eb2888b1006b326.tar.gz emacs-26848af97f333c4699934a545eb2888b1006b326.zip | |
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.
| -rw-r--r-- | lisp/mail/emacsbug.el | 29 | ||||
| -rw-r--r-- | lisp/net/browse-url.el | 40 |
2 files changed, 13 insertions, 56 deletions
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el index ecb7db60ae1..c1aec6923fb 100644 --- a/lisp/mail/emacsbug.el +++ b/lisp/mail/emacsbug.el | |||
| @@ -77,33 +77,12 @@ | |||
| 77 | (equal (executable-find "open") "/usr/bin/open") | 77 | (equal (executable-find "open") "/usr/bin/open") |
| 78 | (memq system-type '(darwin)))) | 78 | (memq system-type '(darwin)))) |
| 79 | 79 | ||
| 80 | ;; FIXME this duplicates much of the logic from browse-url-can-use-xdg-open. | ||
| 81 | (defun report-emacs-bug-can-use-xdg-email () | 80 | (defun report-emacs-bug-can-use-xdg-email () |
| 82 | "Return non-nil if the \"xdg-email\" command can be used. | 81 | "Return non-nil if the \"xdg-email\" command can be used. |
| 83 | xdg-email is a desktop utility that calls your preferred mail client. | 82 | xdg-email is a desktop utility that calls your preferred mail client." |
| 84 | This requires you to be running either Gnome, KDE, or Xfce4." | 83 | (and ;; See browse-url-can-use-xdg-open. |
| 85 | (and (getenv "DISPLAY") | 84 | (or (getenv "DISPLAY") (getenv "WAYLAND_DISPLAY")) |
| 86 | (executable-find "xdg-email") | 85 | (executable-find "xdg-email"))) |
| 87 | (or (getenv "GNOME_DESKTOP_SESSION_ID") | ||
| 88 | ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also. | ||
| 89 | (condition-case nil | ||
| 90 | (eq 0 (call-process | ||
| 91 | "dbus-send" nil nil nil | ||
| 92 | "--dest=org.gnome.SessionManager" | ||
| 93 | "--print-reply" | ||
| 94 | "/org/gnome/SessionManager" | ||
| 95 | "org.gnome.SessionManager.CanShutdown")) | ||
| 96 | (error nil)) | ||
| 97 | (equal (getenv "KDE_FULL_SESSION") "true") | ||
| 98 | ;; FIXME? browse-url-can-use-xdg-open also accepts LXDE. | ||
| 99 | ;; Is that no good here, or just overlooked? | ||
| 100 | (condition-case nil | ||
| 101 | (eq 0 (call-process | ||
| 102 | "/bin/sh" nil nil nil | ||
| 103 | "-c" | ||
| 104 | ;; FIXME use string-match rather than grep. | ||
| 105 | "xprop -root _DT_SAVE_MODE|grep xfce4")) | ||
| 106 | (error nil))))) | ||
| 107 | 86 | ||
| 108 | (defun report-emacs-bug-insert-to-mailer () | 87 | (defun report-emacs-bug-insert-to-mailer () |
| 109 | "Send the message to your preferred mail client. | 88 | "Send the message to your preferred mail client. |
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 @@ | |||
| 45 | ;; browse-url-generic arbitrary | 45 | ;; browse-url-generic arbitrary |
| 46 | ;; browse-url-default-windows-browser MS-Windows browser | 46 | ;; browse-url-default-windows-browser MS-Windows browser |
| 47 | ;; browse-url-default-macosx-browser macOS browser | 47 | ;; browse-url-default-macosx-browser macOS browser |
| 48 | ;; browse-url-xdg-open Free Desktop xdg-open on Gnome, KDE, Xfce4, LXDE | 48 | ;; browse-url-xdg-open freedesktop.org xdg-open |
| 49 | ;; browse-url-kde KDE konqueror (kfm) | 49 | ;; browse-url-kde KDE konqueror (kfm) |
| 50 | ;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT) | 50 | ;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT) |
| 51 | 51 | ||
| @@ -944,36 +944,14 @@ instead of `browse-url-new-window-flag'." | |||
| 944 | 944 | ||
| 945 | (defun browse-url-can-use-xdg-open () | 945 | (defun browse-url-can-use-xdg-open () |
| 946 | "Return non-nil if the \"xdg-open\" program can be used. | 946 | "Return non-nil if the \"xdg-open\" program can be used. |
| 947 | xdg-open is a desktop utility that calls your preferred web browser. | 947 | xdg-open is a desktop utility that calls your preferred web browser." |
| 948 | This requires you to be running either Gnome, KDE, Xfce4 or LXDE." | 948 | ;; The exact set of situations where xdg-open works is complicated, |
| 949 | (and (getenv "DISPLAY") | 949 | ;; and it would be a pain to duplicate xdg-open's situation-specific |
| 950 | (executable-find "xdg-open") | 950 | ;; code here, as the code is a moving target. So assume that |
| 951 | ;; xdg-open may call gnome-open and that does not wait for its child | 951 | ;; xdg-open will work if there is a graphical display; this should |
| 952 | ;; to finish. This child may then be killed when the parent dies. | 952 | ;; be good enough for platforms Emacs is likely to be running on. |
| 953 | ;; Use nohup to work around. See bug#7166, bug#8917, bug#9779 and | 953 | (and (or (getenv "DISPLAY") (getenv "WAYLAND_DISPLAY")) |
| 954 | ;; http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg00279.html | 954 | (executable-find "xdg-open"))) |
| 955 | (executable-find "nohup") | ||
| 956 | (or (getenv "GNOME_DESKTOP_SESSION_ID") | ||
| 957 | ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also. | ||
| 958 | (condition-case nil | ||
| 959 | (eq 0 (call-process | ||
| 960 | "dbus-send" nil nil nil | ||
| 961 | "--dest=org.gnome.SessionManager" | ||
| 962 | "--print-reply" | ||
| 963 | "/org/gnome/SessionManager" | ||
| 964 | "org.gnome.SessionManager.CanShutdown")) | ||
| 965 | (error nil)) | ||
| 966 | (equal (getenv "KDE_FULL_SESSION") "true") | ||
| 967 | (condition-case nil | ||
| 968 | (eq 0 (call-process | ||
| 969 | "/bin/sh" nil nil nil | ||
| 970 | "-c" | ||
| 971 | ;; FIXME use string-match rather than grep. | ||
| 972 | "xprop -root _DT_SAVE_MODE|grep xfce4")) | ||
| 973 | (error nil)) | ||
| 974 | (member (getenv "DESKTOP_SESSION") '("LXDE" "Lubuntu")) | ||
| 975 | (equal (getenv "XDG_CURRENT_DESKTOP") "LXDE")))) | ||
| 976 | |||
| 977 | 955 | ||
| 978 | ;;;###autoload | 956 | ;;;###autoload |
| 979 | (defun browse-url-xdg-open (url &optional ignored) | 957 | (defun browse-url-xdg-open (url &optional ignored) |