]> code.delx.au - gnu-emacs/blobdiff - lisp/net/browse-url.el
Ibuffer: Mark buffers by content
[gnu-emacs] / lisp / net / browse-url.el
index 2bda97f95d02beb895cd67d6af2fb01cbeda45ed..c0b359176ec3b657af8c1bd9c20ee044d76ef836 100644 (file)
@@ -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-chrome                  Chrome      47.0.2526.111
 ;; browse-url-chromium                Chromium    3.0
 ;; browse-url-epiphany                Epiphany    Don't know
 ;; browse-url-conkeror                Conkeror    Don't know
@@ -147,6 +148,7 @@ regexp should probably be \".\" to specify a default browser."
          (function-item :tag "eww" :value  eww-browse-url)
          (function-item :tag "Mozilla" :value  browse-url-mozilla)
          (function-item :tag "Firefox" :value browse-url-firefox)
+         (function-item :tag "Google Chrome" :value browse-url-chrome)
          (function-item :tag "Chromium" :value browse-url-chromium)
          (function-item :tag "Epiphany" :value  browse-url-epiphany)
          (function-item :tag "Conkeror" :value  browse-url-conkeror)
@@ -259,6 +261,22 @@ Defaults to the value of `browse-url-firefox-arguments' at the time
 (make-obsolete-variable 'browse-url-firefox-startup-arguments
                         "it no longer has any effect." "24.5")
 
+(defcustom browse-url-chrome-program
+  (let ((candidates '("google-chrome-stable" "google-chrome")))
+    (while (and candidates (not (executable-find (car candidates))))
+      (setq candidates (cdr candidates)))
+    (or (car candidates) "chromium"))
+  "The name by which to invoke the Chrome browser."
+  :type 'string
+  :version "25.1"
+  :group 'browse-url)
+
+(defcustom browse-url-chrome-arguments nil
+  "A list of strings to pass to Google Chrome as arguments."
+  :type '(repeat (string :tag "Argument"))
+  :version "25.1"
+  :group 'browse-url)
+
 (defcustom browse-url-chromium-program
   (let ((candidates '("chromium" "chromium-browser")))
     (while (and candidates (not (executable-find (car candidates))))
@@ -909,6 +927,7 @@ instead of `browse-url-new-window-flag'."
 ;;;    ((executable-find browse-url-netscape-program) 'browse-url-netscape)
 ;;;    ((executable-find browse-url-mosaic-program) 'browse-url-mosaic)
     ((executable-find browse-url-conkeror-program) 'browse-url-conkeror)
+    ((executable-find browse-url-chrome-program) 'browse-url-chrome)
     ((executable-find browse-url-xterm-program) 'browse-url-text-xterm)
     ((locate-library "w3") 'browse-url-w3)
     (t
@@ -1126,6 +1145,22 @@ The optional argument NEW-WINDOW is not used."
            browse-url-chromium-arguments
            (list url)))))
 
+(defun browse-url-chrome (url &optional _new-window)
+  "Ask the Google Chrome WWW browser to load URL.
+Default to the URL around or before point.  The strings in
+variable `browse-url-chrome-arguments' are also passed to
+Google Chrome.
+The optional argument NEW-WINDOW is not used."
+  (interactive (browse-url-interactive-arg "URL: "))
+  (setq url (browse-url-encode-url url))
+  (let* ((process-environment (browse-url-process-environment)))
+    (apply 'start-process
+          (concat "google-chrome " url) nil
+          browse-url-chrome-program
+          (append
+           browse-url-chrome-arguments
+           (list url)))))
+
 ;;;###autoload
 (defun browse-url-galeon (url &optional new-window)
   "Ask the Galeon WWW browser to load URL.