eww.el: Add a command to browse using and external browser
authorIvan Kanis <ivan@kanis.fr>
Sun, 23 Jun 2013 18:27:58 +0000 (20:27 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 23 Jun 2013 18:27:58 +0000 (20:27 +0200)
(eww-external-browser): New variable.
(eww-mode-map): New keystroke.
(eww-browse-with-external-browser): New command.

lisp/ChangeLog
lisp/net/eww.el

index 521827c..6f696af 100644 (file)
@@ -2,6 +2,9 @@
 
        * net/eww.el (eww-search-prefix): New variable.
        (eww): Use it.
+       (eww-external-browser): New variable.
+       (eww-mode-map): New keystroke.
+       (eww-browse-with-external-browser): New command.
 
 2013-06-23  Juanma Barranquero  <lekktu@gmail.com>
 
index eb1b0a2..2653d48 100644 (file)
   :group 'eww
   :type 'string)
 
+(defcustom eww-external-browser
+  (cond ((eq system-type 'windows-nt)
+        'browse-url-default-windows-browser)
+       ((eq system-type 'darwin)
+        'browse-url-default-macosx-browser)
+       (t
+        'browse-url-netscape))
+  "Function used to launch an external browser."
+  :version "24.4"
+  :group 'eww
+  :type 'function)
+
 (defface eww-form-submit
   '((((type x w32 ns) (class color))   ; Like default mode line
      :box (:line-width 2 :style released-button)
@@ -317,6 +329,7 @@ word(s) will be searched for via `eww-search-prefix'."
     (define-key map "p" 'eww-previous-url)
     (define-key map "u" 'eww-up-url)
     (define-key map "t" 'eww-top-url)
+    (define-key map "w" 'eww-browse-with-external-browser)
     map))
 
 (define-derived-mode eww-mode nil "eww"
@@ -823,6 +836,12 @@ appears in a <link> or <a> tag."
        "?"
        (mm-url-encode-www-form-urlencoded values))))))
 
+(defun eww-browse-with-external-browser ()
+  "Browse the current URL with an external browser.
+The browser to used is specified by the `eww-external-browser' variable."
+  (interactive)
+  (funcall eww-external-browser eww-current-url))
+
 (provide 'eww)
 
 ;;; eww.el ends here