aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mendler2024-12-07 22:56:15 +0100
committerEli Zaretskii2024-12-12 12:40:42 +0200
commita3610381ff65490da33cd1870dd3dfd491bff06f (patch)
tree262f2907d4f37ab749f05c9ea12f1f6abdd0d452
parenteb9ba4830e4c7853150eaed93f89225c00d6e52a (diff)
downloademacs-a3610381ff65490da33cd1870dd3dfd491bff06f.tar.gz
emacs-a3610381ff65490da33cd1870dd3dfd491bff06f.zip
eww: Use browse-url-with-browser-kind in eww-browse-with-external-browser
Guarantee that an external browser is used by EWW if `browse-url-secondary-browser-function' is set to `eww-browse-url'. * lisp/net/eww.el (eww-browse-with-external-browser): Use `browse-url-secondary-browser-function' only if it is an external browser, otherwise fall back to `browse-url-with-browser-kind'. (eww-follow-link): Use `eww-browse-with-external-browser' if the EXTERNAL prefix argument is non-nil. Improve docstring. * lisp/net/browse-url.el (browse-url-secondary-browser-function): Update docstring. (Bug#74730)
-rw-r--r--lisp/net/browse-url.el14
-rw-r--r--lisp/net/eww.el23
2 files changed, 24 insertions, 13 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index a4de177f972..de2fa9c2bfb 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -198,10 +198,16 @@ Also see `browse-url-secondary-browser-function' and
198 198
199(defcustom browse-url-secondary-browser-function 'browse-url-default-browser 199(defcustom browse-url-secondary-browser-function 'browse-url-default-browser
200 "Function used to launch an alternative browser. 200 "Function used to launch an alternative browser.
201This is usually an external browser (that is, not eww or w3m), 201
202used as the secondary browser choice, typically when a prefix 202This browser is used as the secondary browser choice, typically
203argument is given to a URL-opening command in those modes that 203when a prefix argument is given to a URL-opening command in those
204support this (for instance, eww/shr). 204modes that support this (for instance `browse-url-at-point',
205`goto-addr-at-point', eww or shr).
206
207This assumption is that `browse-url-secondary-browser-function'
208and `browse-url-browser-function' are set to distinct browsers.
209Either one of the two functions should call an external browser
210and the other one should not do the same.
205 211
206Also see `browse-url-browser-function'." 212Also see `browse-url-browser-function'."
207 :version "27.1" 213 :version "27.1"
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 4d4d4d6beac..4609755a902 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -2142,11 +2142,15 @@ Interactively, EVENT is the value of `last-nonmenu-event'."
2142 2142
2143(defun eww-browse-with-external-browser (&optional url) 2143(defun eww-browse-with-external-browser (&optional url)
2144 "Browse the current URL with an external browser. 2144 "Browse the current URL with an external browser.
2145The browser to used is specified by the 2145Use `browse-url-secondary-browser-function' if it is an external
2146`browse-url-secondary-browser-function' variable." 2146browser, otherwise use `browse-url-with-browser-kind' to open an
2147external browser."
2147 (interactive nil eww-mode) 2148 (interactive nil eww-mode)
2148 (funcall browse-url-secondary-browser-function 2149 (setq url (or url (plist-get eww-data :url)))
2149 (or url (plist-get eww-data :url)))) 2150 (if (eq 'external (browse-url--browser-kind
2151 browse-url-secondary-browser-function url))
2152 (funcall browse-url-secondary-browser-function url)
2153 (browse-url-with-browser-kind 'external url)))
2150 2154
2151(defun eww-remove-tracking (url) 2155(defun eww-remove-tracking (url)
2152 "Remove the commong utm_ tracking cookies from URLs." 2156 "Remove the commong utm_ tracking cookies from URLs."
@@ -2160,11 +2164,12 @@ The browser to used is specified by the
2160 url)) 2164 url))
2161 2165
2162(defun eww-follow-link (&optional external mouse-event) 2166(defun eww-follow-link (&optional external mouse-event)
2163 "Browse the URL under point. 2167 "Browse the URL at point, optionally the position of MOUSE-EVENT.
2164If EXTERNAL is single prefix, browse the URL using
2165`browse-url-secondary-browser-function'.
2166 2168
2167If EXTERNAL is double prefix, browse in new buffer." 2169EXTERNAL is the prefix argument. If called interactively with
2170\\[universal-argument] pressed once, browse the URL using
2171`eww-browse-with-external-browser'. If called interactively, with
2172\\[universal-argument] pressed twice, browse in new buffer."
2168 (interactive 2173 (interactive
2169 (list current-prefix-arg last-nonmenu-event) 2174 (list current-prefix-arg last-nonmenu-event)
2170 eww-mode) 2175 eww-mode)
@@ -2180,7 +2185,7 @@ If EXTERNAL is double prefix, browse in new buffer."
2180 ;; and `browse-url-mailto-function'. 2185 ;; and `browse-url-mailto-function'.
2181 (browse-url url)) 2186 (browse-url url))
2182 ((and (consp external) (<= (car external) 4)) 2187 ((and (consp external) (<= (car external) 4))
2183 (funcall browse-url-secondary-browser-function url) 2188 (eww-browse-with-external-browser url)
2184 (shr--blink-link)) 2189 (shr--blink-link))
2185 ;; This is a #target url in the same page as the current one. 2190 ;; This is a #target url in the same page as the current one.
2186 ((and (setq target (url-target (url-generic-parse-url url))) 2191 ((and (setq target (url-target (url-generic-parse-url url)))