X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/5ed99d3685cc8d13f8e4c63ad449a6e4d63c8eb0..8520d9c4e50520db79410ec6ef0052df129231dc:/lisp/net/browse-url.el diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index f9bc13e1e2..87e772f183 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -36,6 +36,7 @@ ;; Function Browser Earliest version ;; browse-url-mozilla Mozilla Don't know ;; browse-url-firefox Firefox Don't know (tried with 1.0.1) +;; browse-url-chromium Chromium 3.0 ;; browse-url-galeon Galeon Don't know ;; browse-url-epiphany Epiphany Don't know ;; browse-url-netscape Netscape 1.1b1 @@ -47,6 +48,7 @@ ;; browse-url-generic arbitrary ;; browse-url-default-windows-browser MS-Windows browser ;; browse-url-default-macosx-browser Mac OS X browser +;; browse-url-xdg-open Free Desktop xdg-open on Gnome, KDE, Xfce4, LXDE ;; browse-url-gnome-moz GNOME interface to Mozilla ;; browse-url-kde KDE konqueror (kfm) ;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT) @@ -230,6 +232,7 @@ regexp should probably be \".\" to specify a default browser." :value browse-url-w3-gnudoit) (function-item :tag "Mozilla" :value browse-url-mozilla) (function-item :tag "Firefox" :value browse-url-firefox) + (function-item :tag "Chromium" :value browse-url-chromium) (function-item :tag "Galeon" :value browse-url-galeon) (function-item :tag "Epiphany" :value browse-url-epiphany) (function-item :tag "Netscape" :value browse-url-netscape) @@ -336,6 +339,22 @@ Defaults to the value of `browse-url-firefox-arguments' at the time :type '(repeat (string :tag "Argument")) :group 'browse-url) +(defcustom browse-url-chromium-program + (let ((candidates '("chromium" "chromium-browser"))) + (while (and candidates (not (executable-find (car candidates)))) + (setq candidates (cdr candidates))) + (or (car candidates) "chromium")) + "The name by which to invoke Chromium." + :type 'string + :version "24.1" + :group 'browse-url) + +(defcustom browse-url-chromium-arguments nil + "A list of strings to pass to Chromium as arguments." + :type '(repeat (string :tag "Argument")) + :version "24.1" + :group 'browse-url) + (defcustom browse-url-galeon-program "galeon" "The name by which to invoke Galeon." :type 'string @@ -650,7 +669,7 @@ regarding its parameter treatment." ;; functions allows them to be stand-alone commands, making it easier ;; to switch between browsers. -(defun browse-url-interactive-arg (prompt) +(defun browse-url-interactive-arg (prompt &optional default-url) "Read a URL from the minibuffer, prompting with PROMPT. If `transient-mark-mode' is non-nil and the mark is active, it defaults to the current region, else to the URL at or before @@ -667,7 +686,8 @@ for use in `interactive'." "[\t\r\f\n ]+" "" (buffer-substring-no-properties (region-beginning) (region-end)))) - (browse-url-url-at-point))) + (browse-url-url-at-point) + default-url)) (not (eq (null browse-url-new-window-flag) (null current-prefix-arg))))) @@ -780,6 +800,13 @@ narrowed." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Browser-independent commands +(defun url-tidy (url) + "Tidy up URL as much as possible." + (if (equal 0 (string-match ".*://" url)) + url + (concat "http://" url) ;;TODO guess more url forms, like mailto + )) + ;; A generic command to call the current browse-url-browser-function ;;;###autoload @@ -792,6 +819,7 @@ first, if that exists." (interactive (browse-url-interactive-arg "URL: ")) (unless (called-interactively-p 'interactive) (setq args (or args (list browse-url-new-window-flag)))) + (setq url (url-tidy url)) (let ((process-environment (copy-sequence process-environment)) (function (or (and (string-match "\\`mailto:" url) browse-url-mailto-function) @@ -913,6 +941,7 @@ used instead of `browse-url-new-window-flag'." ((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) + ((executable-find browse-url-chromium-program) 'browse-url-chromium) ((executable-find browse-url-galeon-program) 'browse-url-galeon) ((executable-find browse-url-kde-program) 'browse-url-kde) ((executable-find browse-url-netscape-program) 'browse-url-netscape) @@ -924,12 +953,13 @@ used instead of `browse-url-new-window-flag'." 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." + "Check if xdg-open can be used, i.e. we are on 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. + ;; 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. @@ -947,7 +977,9 @@ used instead of `browse-url-new-window-flag'." "/bin/sh" nil nil nil "-c" "xprop -root _DT_SAVE_MODE|grep xfce4")) - (error nil))))) + (error nil)) + (member (getenv "DESKTOP_SESSION") '("LXDE" "Lubuntu")) + (equal (getenv "XDG_CURRENT_DESKTOP") "LXDE")))) ;;;###autoload @@ -1140,6 +1172,22 @@ URL in a new window." browse-url-firefox-program (append browse-url-firefox-startup-arguments (list url)))))) +;;;###autoload +(defun browse-url-chromium (url &optional new-window) + "Ask the Chromium WWW browser to load URL. +Default to the URL around or before point. The strings in +variable `browse-url-chromium-arguments' are also passed to +Chromium." + (interactive (browse-url-interactive-arg "URL: ")) + (setq url (browse-url-encode-url url)) + (let* ((process-environment (browse-url-process-environment))) + (apply 'start-process + (concat "chromium " url) nil + browse-url-chromium-program + (append + browse-url-chromium-arguments + (list url))))) + ;;;###autoload (defun browse-url-galeon (url &optional new-window) "Ask the Galeon WWW browser to load URL.