From: Lars Ingebrigtsen Date: Tue, 24 Nov 2020 07:22:26 +0000 (+0100) Subject: Add a user option to control how links are followed in eww X-Git-Tag: emacs-28.0.90~5049 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6dad1f25de0f9f62dd4855bb6400405b627fd700;p=emacs.git Add a user option to control how links are followed in eww * doc/misc/eww.texi (Advanced): Document it (bug#44783). * lisp/net/eww.el (eww-use-browse-url): New variable. (eww-follow-link): Use it. --- diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi index 1bccbd7261a..a2a21f031d5 100644 --- a/doc/misc/eww.texi +++ b/doc/misc/eww.texi @@ -262,6 +262,12 @@ fetching images that originate from the same source as the retrieving these images'' and @code{t} means ``always send cookies when retrieving these images''. +@vindex eww-use-browse-url + When following links in EWW, @acronym{URL}s that match the +@code{eww-use-browse-url} regexp will be passed to @code{browse-url} +instead of EWW handling them itself. The action can be further +customized by altering @code{browse-url-handlers}. + @vindex eww-header-line-format @cindex Header The header line of the EWW buffer can be changed by customizing diff --git a/etc/NEWS b/etc/NEWS index 9361cff3869..f3a75e4965c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1099,6 +1099,10 @@ background colors or transparency, such as xbm, pbm, svg, png and gif. ** EWW ++++ +*** New user option 'eww-use-browse-url'. +This is a regexp that can be set to alter how links are followed in eww. + +++ *** New user option 'eww-retrieve-command'. This can be used to download data via an external command. If nil diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 9ed01ecc473..597ce95c67c 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -56,6 +56,13 @@ :group 'eww :type 'string) +(defcustom eww-use-browse-url "\\`mailto:" + "eww will use `browse-url' when following links that match this regexp. +The action to be taken can further be customized via +`browse-url-handlers'." + :version "28.1" + :type 'regexp) + (defun erc--download-directory () "Return the name of the download directory. If ~/Downloads/ exists, that will be used, and if not, the @@ -1731,7 +1738,7 @@ If EXTERNAL is double prefix, browse in new buffer." (cond ((not url) (message "No link under point")) - ((string-match-p "\\`mailto:" url) + ((string-match-p eww-use-browse-url url) ;; This respects the user options `browse-url-handlers' ;; and `browse-url-mailto-function'. (browse-url url))