From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#75052: 31; browse-url-transform-alist is not used by secondary browser Date: Sat, 04 Jan 2025 12:59:00 +0100 Message-ID: <875xmuokmz.fsf@daniel-mendler.de> References: <87cyhi6y3p.fsf@daniel-mendler.de> <87zfkl28vf.fsf@daniel-mendler.de> <87frlz3kvs.fsf@daniel-mendler.de> <878qrqomjc.fsf@daniel-mendler.de> Reply-To: Daniel Mendler Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6453"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 75052@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 04 13:00:48 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tU2pk-0001Td-8Z for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jan 2025 13:00:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tU2p3-0003wZ-Kd; Sat, 04 Jan 2025 07:00:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tU2p0-0003tp-Fr for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 07:00:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tU2p0-0001TG-4w for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 07:00:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=F9onSbGGxb4TLIgEviXZnfPajC0Y4BITmLcNCnY06IA=; b=hmN8E/BBZumxkK28UT/TVeFCwSqpyZ0kVU5pEELE59dxVC/iVWwsrsEadbi1DntVelnST9k81F1RF5httmy//WUdb1zv1l2E1R/PpncfVaMXyb6Rs8FqhjE3gKNvEdyJyYj10+KF823DNU8DbdohlQ8YQ5inbIDeNF0L4X3Xsr2TWX2XTZ0x/3iCBuduU+GvJXNT1/iuTOAE6N9if1ipVvheJ9G7yGZje/68l9fmSkoEPKCOJn175rZdSRLM26zZEWQwBb9HLzYyqm6TT8fvOCni+/sirQFd96crB94T5ll2NLinCRSO8V++F84IcnO7BdKJCgQypVvmib5gwnZD+Q==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tU2oz-0003uz-UN for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 07:00:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jan 2025 12:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75052 X-GNU-PR-Package: emacs Original-Received: via spool by 75052-submit@debbugs.gnu.org id=B75052.173599195314958 (code B ref 75052); Sat, 04 Jan 2025 12:00:01 +0000 Original-Received: (at 75052) by debbugs.gnu.org; 4 Jan 2025 11:59:13 +0000 Original-Received: from localhost ([127.0.0.1]:53721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tU2oD-0003tB-5v for submit@debbugs.gnu.org; Sat, 04 Jan 2025 06:59:13 -0500 Original-Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:38493 helo=mail.qxqx.de) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tU2o9-0003sv-Kc for 75052@debbugs.gnu.org; Sat, 04 Jan 2025 06:59:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F9onSbGGxb4TLIgEviXZnfPajC0Y4BITmLcNCnY06IA=; b=OA06uj03u6TCwABbB3NXUDwzba XvFnt/x/y08tmvKTaGmsY5cYMpV/46lvkSknQdZFAVRU3IurciRZgDHEsT1UF0y+GNduf6xXz2zw7 TLixZ6xIUlOso3567bF9F3HRkTZK8Fgg8zHqkjKloa5IU3Yz1gYHrPSZX7e+gJyDijpw=; In-Reply-To: <878qrqomjc.fsf@daniel-mendler.de> (Daniel Mendler's message of "Sat, 04 Jan 2025 12:17:59 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298381 Archived-At: --=-=-= Content-Type: text/plain Daniel Mendler writes: > Yes, I'll send a patch and then you can take another look. Updated patch attached to this mail. > Daniel --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Call-browser-functions-via-browse-url.patch >From a859519c83e73b9a61795c2c9200e1b853136b9d Mon Sep 17 00:00:00 2001 From: Daniel Mendler 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 --=-=-=--