GNU bug report logs - #15707
[PATCH 5/8] EWW: Option to always use external-browser for certain content.

Previous Next

Package: emacs;

Reported by: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>

Date: Thu, 24 Oct 2013 23:45:06 UTC

Severity: normal

Tags: fixed, patch

Merged with 15702, 15703, 15704, 15705, 15706, 15708, 15709, 15710

Fixed in version 24.4

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
To: 15707 <at> debbugs.gnu.org
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Subject: bug#15707: [PATCH 5/8] EWW: Option to always use external-browser for certain content.
Date: Fri, 25 Oct 2013 01:44 +0200
Emacs can not display videos and has only limited audio support.
Therefore it makes sense to call an external browser for links of that
kind.  This is also a problem because shr turns <video> and <audio>
tags into links to the media.

* lisp/net/eww.el (eww-use-external-browser-for-content-type): New
  customizable variable.
  (eww-render): Handle `eww-use-external-browser-for-content-type'.
  Use \\` to match beginning of string instead of ^.
  (eww-browse-with-external-browser): Provide optional URL parameter.

Signed-off-by: Rüdiger Sonderfeld <ruediger <at> c-plusplus.de>
---
 lisp/net/eww.el | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index ccc2399..6335bd8 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -75,6 +75,14 @@ (defcustom eww-form-checkbox-symbol "[ ]"
                  (const "☐")            ; Unicode BALLOT BOX
                  string))
 
+(defcustom eww-use-external-browser-for-content-type
+  "\\`\\(video/\\|audio/\\|application/ogg\\)"
+  "Always use external browser for specified content-type."
+  :version "24.4"
+  :group 'eww
+  :type '(choice (const :tag "Never" nil)
+                 regexp))
+
 (defface eww-form-submit
   '((((type x w32 ns) (class color))	; Like default mode line
      :box (:line-width 2 :style released-button)
@@ -173,10 +181,14 @@ (defun eww-render (status url &optional point)
     (unwind-protect
 	(progn
 	  (cond
+           ((and eww-use-external-browser-for-content-type
+                 (string-match-p eww-use-external-browser-for-content-type
+                                 (car content-type)))
+            (eww-browse-with-external-browser url))
 	   ((equal (car content-type) "text/html")
 	    (eww-display-html charset url))
-	   ((string-match "^image/" (car content-type))
-	    (eww-display-image))
+	   ((string-match-p "\\`image/" (car content-type))
+	    (eww-display-image url))
 	   (t
 	    (eww-display-raw)))
 	  (setq eww-current-url url
@@ -929,11 +941,11 @@ (defun eww-submit ()
 	"?"
 	(mm-url-encode-www-form-urlencoded values))))))
 
-(defun eww-browse-with-external-browser ()
+(defun eww-browse-with-external-browser (&optional url)
   "Browse the current URL with an external browser.
 The browser to used is specified by the `shr-external-browser' variable."
   (interactive)
-  (funcall shr-external-browser eww-current-url))
+  (funcall shr-external-browser (or url eww-current-url)))
 
 (defun eww-copy-page-url ()
   (interactive)
-- 
1.8.4.1






This bug report was last modified 11 years and 230 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.