emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101105: Add ability to use xdg-open,


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101105: Add ability to use xdg-open, i.e. your desktop default browser.
Date: Tue, 17 Aug 2010 10:01:10 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101105
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Tue 2010-08-17 10:01:10 +0200
message:
  Add ability to use xdg-open, i.e. your desktop default browser.
  
  * net/browse-url.el (browse-url-default-browser): Add cond
  for browse-url-xdg-open
  (browse-url-can-use-xdg-open, browse-url-xdg-open): New functions
modified:
  lisp/ChangeLog
  lisp/net/browse-url.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-08-17 06:54:03 +0000
+++ b/lisp/ChangeLog    2010-08-17 08:01:10 +0000
@@ -1,3 +1,9 @@
+2010-08-17  Jan Djärv  <address@hidden>
+
+       * net/browse-url.el (browse-url-default-browser): Add cond
+       for browse-url-xdg-open
+       (browse-url-can-use-xdg-open, browse-url-xdg-open): New functions
+
 2010-08-17  Glenn Morris  <address@hidden>
 
        * progmodes/cc-engine.el (c-new-BEG, c-new-END)

=== modified file 'lisp/net/browse-url.el'
--- a/lisp/net/browse-url.el    2010-04-29 14:04:33 +0000
+++ b/lisp/net/browse-url.el    2010-08-17 08:01:10 +0000
@@ -892,6 +892,7 @@
 Galeon, Konqueror, Netscape, Mosaic, Lynx in an xterm, and then W3."
   (apply
    (cond
+    ((browse-url-can-use-xdg-open) 'browse-url-xdg-open)
     ((executable-find browse-url-gnome-moz-program) 'browse-url-gnome-moz)
     ((executable-find browse-url-mozilla-program) 'browse-url-mozilla)
     ((executable-find browse-url-firefox-program) 'browse-url-firefox)
@@ -905,6 +906,41 @@
      (lambda (&rest ignore) (error "No usable browser found"))))
    url args))
 
+(defun browse-url-can-use-xdg-open ()
+  "Check if xdg-open can be used, i.e. we are on Gnome, KDE or xfce4."
+  (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.
+       (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"
+                     "xprop -root _DT_SAVE_MODE|grep xfce4"))
+            (error nil)))))
+
+
+;;;###autoload
+(defun browse-url-xdg-open (url &optional new-window)
+  (interactive (browse-url-interactive-arg "URL: "))
+  (call-process "/bin/sh" nil nil nil
+               "-c"
+               (concat "nohup xdg-open " url
+                       ">/dev/null 2>&1 </dev/null")))
+
 ;;;###autoload
 (defun browse-url-netscape (url &optional new-window)
   "Ask the Netscape WWW browser to load URL.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]