From: Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: 75052@debbugs.gnu.org
Subject: bug#75052: 31; browse-url-transform-alist is not used by secondary browser
Date: Sat, 04 Jan 2025 12:59:00 +0100 [thread overview]
Message-ID: <875xmuokmz.fsf@daniel-mendler.de> (raw)
In-Reply-To: <878qrqomjc.fsf@daniel-mendler.de> (Daniel Mendler's message of "Sat, 04 Jan 2025 12:17:59 +0100")
[-- Attachment #1: Type: text/plain, Size: 159 bytes --]
Daniel Mendler <mail@daniel-mendler.de> writes:
> Yes, I'll send a patch and then you can take another look.
Updated patch attached to this mail.
> Daniel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Call-browser-functions-via-browse-url.patch --]
[-- Type: text/x-diff, Size: 6839 bytes --]
From a859519c83e73b9a61795c2c9200e1b853136b9d Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
Date: Tue, 24 Dec 2024 01:31:35 +0100
Subject: [PATCH] Call browser functions via `browse-url'
`browse-url' applies `browse-url-transform-alist'
transformations to the URL argument and initializes appropriate
environment variables. Therefore always call browser functions
via `browse-url' and not directly, by let-binding
`browse-url-browser-function'.
* lisp/net/browse-url.el (browse-url-with-browser-kind)
(browse-url-button-open, browse-url-button-open-url):
* lisp/net/shr.el (shr-browse-url):
* lisp/net/eww.el (eww-browse-with-external-browser):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/emacs-lisp/package.el (package-browse-url): Let-bind
`browse-url-browser-function' and call `browse-url'.
---
lisp/emacs-lisp/package.el | 6 ++++--
lisp/gnus/gnus-sum.el | 10 ++++++----
lisp/net/browse-url.el | 23 +++++++++++++++--------
lisp/net/eww.el | 3 ++-
lisp/net/shr.el | 9 +++++----
5 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index b4a33db1a77..6a04108b9f8 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -4692,8 +4692,10 @@ package-browse-url
(let ((url (cdr (assoc :url (package-desc-extras desc)))))
(unless url
(user-error "No website for %s" (package-desc-name desc)))
- (if secondary
- (funcall browse-url-secondary-browser-function url)
+ (let ((browse-url-browser-function
+ (if secondary
+ browse-url-secondary-browser-function
+ browse-url-browser-function)))
(browse-url url))))
(declare-function ietf-drums-parse-address "ietf-drums"
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index c909d9cfd5c..06367b7293e 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9408,7 +9408,7 @@ gnus-shorten-url
(concat "#" target)))))
(concat host (string-truncate-left rest (- max (length host)))))))
-(defun gnus-summary-browse-url (&optional external)
+(defun gnus-summary-browse-url (&optional secondary)
"Scan the current article body for links, and offer to browse them.
Links are opened using `browse-url' unless a prefix argument is
@@ -9429,9 +9429,11 @@ gnus-summary-browse-url
(gnus-shorten-url (car urls) 40))
urls nil t nil nil (car urls))))))
(if target
- (if external
- (funcall browse-url-secondary-browser-function target)
- (browse-url target))
+ (let ((browse-url-browser-function
+ (if secondary
+ browse-url-secondary-browser-function
+ browse-url-browser-function)))
+ (browse-url target))
(message "No URLs found."))))
(defun gnus-summary-isearch-article (&optional regexp-p)
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index b9610fec150..e67c2fd79da 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -999,7 +999,10 @@ browse-url-with-browser-kind
browse-url-secondary-browser-function
#'browse-url-default-browser
#'eww))))
- (funcall function url arg)))
+ (let ((browse-url-browser-function function)
+ (browse-url-handlers nil)
+ (browse-url-default-handlers nil))
+ (browse-url url))))
;;;###autoload
(defun browse-url-at-mouse (event)
@@ -1786,17 +1789,19 @@ browse-url-add-buttons
browse-url-data ,(match-string 0)))))))
;;;###autoload
-(defun browse-url-button-open (&optional external mouse-event)
+(defun browse-url-button-open (&optional secondary mouse-event)
"Follow the link under point using `browse-url'.
-If EXTERNAL (the prefix if used interactively), open with the
-external browser instead of the default one."
+If SECONDARY (the prefix if used interactively), open with the
+secondary browser instead of the default one."
(interactive (list current-prefix-arg last-nonmenu-event))
(mouse-set-point mouse-event)
(let ((url (get-text-property (point) 'browse-url-data)))
(unless url
(error "No URL under point"))
- (if external
- (funcall browse-url-secondary-browser-function url)
+ (let ((browse-url-browser-function
+ (if secondary
+ browse-url-secondary-browser-function
+ browse-url-browser-function)))
(browse-url url))))
;;;###autoload
@@ -1804,8 +1809,10 @@ browse-url-button-open-url
"Open URL using `browse-url'.
If `current-prefix-arg' is non-nil, use
`browse-url-secondary-browser-function' instead."
- (if current-prefix-arg
- (funcall browse-url-secondary-browser-function url)
+ (let ((browse-url-browser-function
+ (if current-prefix-arg
+ browse-url-secondary-browser-function
+ browse-url-browser-function)))
(browse-url url)))
(defun browse-url-button-copy ()
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 95513a67acd..df9e5ad88a7 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -2166,7 +2166,8 @@ eww-browse-with-external-browser
(setq url (or url (plist-get eww-data :url)))
(if (eq 'external (browse-url--browser-kind
browse-url-secondary-browser-function url))
- (funcall browse-url-secondary-browser-function url)
+ (let ((browse-url-browser-function browse-url-secondary-browser-function))
+ (browse-url url))
(browse-url-with-browser-kind 'external url)))
(defun eww-remove-tracking (url)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 24c779524dc..c2d01bd2e0d 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1097,9 +1097,9 @@ shr-mouse-browse-url-new-window
(mouse-set-point ev)
(shr-browse-url nil nil t))
-(defun shr-browse-url (&optional external mouse-event new-window)
+(defun shr-browse-url (&optional secondary mouse-event new-window)
"Browse the URL at point using `browse-url'.
-If EXTERNAL is non-nil (interactively, the prefix argument), browse
+If SECONDARY is non-nil (interactively, the prefix argument), browse
the URL using `browse-url-secondary-browser-function'.
If this function is invoked by a mouse click, it will browse the URL
at the position of the click. Optional argument MOUSE-EVENT describes
@@ -1110,8 +1110,9 @@ shr-browse-url
(cond
((not url)
(message "No link under point"))
- (external
- (funcall browse-url-secondary-browser-function url)
+ (secondary
+ (let ((browse-url-browser-function browse-url-secondary-browser-function))
+ (browse-url url))
(shr--blink-link))
(t
(browse-url url (xor new-window browse-url-new-window-flag))))))
--
2.45.2
prev parent reply other threads:[~2025-01-04 11:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-23 18:41 bug#75052: 31; browse-url-transform-alist is not used by secondary browser Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-24 1:00 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-03 16:18 ` Stefan Kangas
2025-01-03 16:47 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-04 2:55 ` Stefan Kangas
2025-01-04 11:17 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-04 11:59 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875xmuokmz.fsf@daniel-mendler.de \
--to=bug-gnu-emacs@gnu.org \
--cc=75052@debbugs.gnu.org \
--cc=mail@daniel-mendler.de \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).