1. xemacs
  2. mail-lib


scop  committed 4dc3c03

Add xdg-open support to browse-url <200701212152.52470.scop@xemacs.org>

  • Participants
  • Parent commits 0056798
  • Branches default

Comments (0)

Files changed (3)

File ChangeLog

View file
+2007-01-21  Ville Skyttä  <scop@xemacs.org>
+	* browse-url.el: Add support for freedesktop.org xdg-open.
+	(browse-url-xdg-open-program): New.
+	(browse-url-default-xdg-browser): New.
+	(browse-url-browser-function): Add item for freedesktop.org browser.
+	(browse-url-default-browser): Try freedesktop.org browser first,
+	fix order of other tried browsers.
+	* browse-url-xemacs.el (browse-url-menu): Add SeaMonkey and
+	freedesktop.org items.
 2006-10-21  Norbert Koch  <viteno@xemacs.org>
 	* Makefile (VERSION): XEmacs package 1.78 released.

File browse-url-xemacs.el

View file
 	    :selected (eq browse-url-browser-function 'browse-url-firefox)
 	    :active (and (fboundp 'browse-url-firefox)
 			 (executable-find browse-url-firefox-program))]
+	   ["Seamonkey"
+	    (customize-set-variable 'browse-url-browser-function
+				    'browse-url-seamonkey)
+	    :style radio
+	    :selected (eq browse-url-browser-function 'browse-url-seamonkey)
+	    :active (and (fboundp 'browse-url-seamonkey)
+			 (executable-find browse-url-seamonkey-program))]
 	    (customize-set-variable 'browse-url-browser-function
 	    :selected (eq browse-url-browser-function 'browse-url-default-windows-browser)
 	    :active (and (fboundp 'mswindows-shell-execute)
 			 (fboundp 'browse-url-default-windows-browser))]
+	   ["Free%_desktop.org Default Browser"
+	    (customize-set-variable 'browse-url-browser-function
+				    'browse-url-default-xdg-browser)
+	    :style radio
+	    :selected (eq browse-url-browser-function
+			  'browse-url-default-xdg-browser)
+	    :active (and (fboundp 'browse-url-default-xdg-browser)
+			 (executable-find browse-url-xdg-open-program))]
 	   ["G%_eneric Browser"
 	    (customize-set-variable 'browse-url-browser-function

File browse-url.el

View file
 ;; browse-url-generic                 arbitrary
 ;; browse-url-default-windows-browser MS-Windows browser
 ;; browse-url-default-macosx-browser  Mac OS X browser
+;; browse-url-default-xdg-browser     freedesktop.org browser
 ;; browse-url-gnome-moz               GNOME interface to Mozilla
 ;; browse-url-kde                     KDE konqueror (kfm)
 ;; browse-url-opera                   Opera
    ((memq system-type '(windows-nt ms-dos cygwin32)) ;; XEmacs change
    ((memq system-type '(darwin)) 'browse-url-default-macosx-browser)
+   ;; XEmacs TODO: add 'browse-url-default-xdg-browser here, but how to detect
+   ;; a freedesktop.org desktop?  executable-find xdg-open is not the way.
    (t 'browse-url-default-browser))
   "*Function to display the current buffer in a WWW browser.
 This is used by the `browse-url-at-point', `browse-url-at-mouse', and
 			 :value browse-url-default-windows-browser)
 	  (function-item :tag "Default Mac OS X browser"
 			 :value browse-url-default-macosx-browser)
+	  ;; XEmacs addition
+	  (function-item :tag "Default freedesktop.org browser"
+			 :value browse-url-default-xdg-browser)
 	  (function-item :tag "GNOME invoking Mozilla"
 			 :value browse-url-gnome-moz)
 	  (function-item :tag "Default browser"
   (interactive (browse-url-interactive-arg "URL: "))
   (start-process (concat "open " url) nil "open" url))
+;; XEmacs addition
+(defcustom browse-url-xdg-open-program "xdg-open"
+  "*The name by which to invoke xdg-open."
+  :type 'string
+  :group 'browse-url)
+;; XEmacs addition
+(defun browse-url-default-xdg-browser (url &optional new-window)
+  (interactive (browse-url-interactive-arg "URL: "))
+  (let ((process-environment (browse-url-process-environment))
+	(process-connection-type nil))
+    (start-process (concat browse-url-xdg-open-program " " url) nil
+		   browse-url-xdg-open-program url)))
 ;; --- Netscape ---
 (defun browse-url-process-environment ()
 When called non-interactively, optional second argument NEW-WINDOW is
 used instead of `browse-url-new-window-flag'.
-The order attempted is emacs-w3m, gnome-moz-remote, Mozilla, Firefox,
-SeaMonkey, Galeon, Konqueror, Netscape, Opera, Mosaic, IXI Mosaic,
-Lynx in an xterm, MMM, and then W3."
+The order attempted is freedesktop.org default, gnome-moz-remote, Mozilla,
+Firefox, SeaMonkey, Galeon, Konqueror, Netscape, Opera, Mosaic, IXI Mosaic,
+emacs-w3m, Lynx in an xterm, MMM, and then W3."
+     ;; XEmacs addition
+     ((executable-find browse-url-xdg-open-program)
+      'browse-url-default-xdg-browser)
      ((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)