From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 17:02:19 2024 Received: (at submit) by debbugs.gnu.org; 7 Dec 2024 22:02:19 +0000 Received: from localhost ([127.0.0.1]:48826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK2sV-00066W-CA for submit@debbugs.gnu.org; Sat, 07 Dec 2024 17:02:19 -0500 Received: from lists.gnu.org ([209.51.188.17]:47430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK2sT-00066O-16 for submit@debbugs.gnu.org; Sat, 07 Dec 2024 17:02:18 -0500 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 1tK2sS-0002Vk-82 for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 17:02:16 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1] helo=mail.qxqx.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tK2sQ-0006Hq-9h for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 17:02:16 -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: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=o5ZQOr4CJp2St5xlUtR2EUaf0qHeXy7y8/+VNfdlDyU=; b=IIGpH8FELf1WJskMyyYAEmkqlj K12WvrQTS8RUPPVUVYndJv1/Y0RUcEEl3EJvElRPNKmhinmlPHfmNNDLDdqXEyL6VIRNLopm+Nk8l pxv5v8t1H1pBaPyd9EJ219o4kaoPHn+ca9Zl1QSmF2i+0/gSdPLGIP7VHOWpbw8NSSi8=; From: Daniel Mendler To: bug-gnu-emacs@gnu.org Subject: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind Date: Sat, 07 Dec 2024 23:02:09 +0100 Message-ID: <87frmz40f2.fsf@daniel-mendler.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a01:4f8:c012:9177::1; envelope-from=mail@daniel-mendler.de; helo=mail.qxqx.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch The command `eww-browse-with-external-browser' uses `browse-url-secondary-browser-function'. This makes the command ineffective in the common setup where `browse-url-secondary-browser-function' is set to `eww-browse-url' and `browse-url-browser-function' is set to an external browser. Fortunately we can use `browse-url-with-browser-kind' instead, which guarantees that an external browser is launched. Furthermore `eww-follow-link' should use `browse-url-with-browser-kind' if the EXTERNAL prefix argument is non-nil. I've looked at all other uses of `browse-url-browser-function' and `browse-url-secondary-browser-function' in the Emacs code base and I have not found other problems. Most commands use a prefix argument to switch to the secondary browser, relying on the primary browser by default. The problem is limited to `eww-browse-with-external-browser' and `eww-follow-link'. In GNU Emacs 30.0.92 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.2, Xaw scroll bars) of 2024-11-20 --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-eww-Use-browse-url-browser-kind-for-external-browsin.patch >From 361b9d970631b3547bd859fb8686597e651447ce Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 7 Dec 2024 22:56:15 +0100 Subject: [PATCH] eww: Use browse-url-browser-kind for external browsing Guarantee that an external browser is used by Eww even if `browse-url-secondary-browser-function' is set to `eww-browse-url'. * lisp/net/eww.el (eww-browse-with-external-browser): Use `browse-url-with-browser-kind'. (eww-follow-link): Use `browse-url-with-browser-kind' if the EXTERNAL prefix argument is non-nil. --- lisp/net/eww.el | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 4d4d4d6beac..bace519c7c4 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2141,12 +2141,11 @@ eww-submit (mm-url-encode-www-form-urlencoded values)))))) (defun eww-browse-with-external-browser (&optional url) - "Browse the current URL with an external browser. -The browser to used is specified by the -`browse-url-secondary-browser-function' variable." + "Browse the current URL with an external browser." (interactive nil eww-mode) - (funcall browse-url-secondary-browser-function - (or url (plist-get eww-data :url)))) + (browse-url-with-browser-kind + 'external + (or url (plist-get eww-data :url)))) (defun eww-remove-tracking (url) "Remove the commong utm_ tracking cookies from URLs." @@ -2161,9 +2160,7 @@ eww--transform-url (defun eww-follow-link (&optional external mouse-event) "Browse the URL under point. -If EXTERNAL is single prefix, browse the URL using -`browse-url-secondary-browser-function'. - +If EXTERNAL is single prefix, browse the URL using an external browser. If EXTERNAL is double prefix, browse in new buffer." (interactive (list current-prefix-arg last-nonmenu-event) @@ -2180,7 +2177,7 @@ eww-follow-link ;; and `browse-url-mailto-function'. (browse-url url)) ((and (consp external) (<= (car external) 4)) - (funcall browse-url-secondary-browser-function url) + (browse-url-with-browser-kind 'external url) (shr--blink-link)) ;; This is a #target url in the same page as the current one. ((and (setq target (url-target (url-generic-parse-url url))) -- 2.45.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 00:59:37 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 05:59:37 +0000 Received: from localhost ([127.0.0.1]:49358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKAKP-0004Cr-Aj for submit@debbugs.gnu.org; Sun, 08 Dec 2024 00:59:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKAKL-0004CZ-P5 for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 00:59:35 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKAI8-0008EN-Os; Sun, 08 Dec 2024 00:57:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=98lrpbHaOTy0899iSVz2sMRdWyQ+2awnV4ax1p6dSWA=; b=aP/S2K6FOvRu 6MNIRfgmfB3I/ZeEu8C//LJE/X4nckorO+x4nxmk8cvqpHlk6M/e926dXYOG6DNx55KvGa+UbeLlu V1rCHs3J1kRh/TZUXRwUeTIRZkKHgVSN0r67X7D/sh0/SmIYqafXQy1yK78Ngjon9ryW1s9hW63n1 ZLhkffuoBYQvcCF2J62sRDAe5gEWAhPEuUpmOsL2fRGDKYhPESDY4QODrK7r4Alc3wZKweAlKQL5Y Xp2hr+QUQbFfr7bf72QZWx+l2x9WcufSQQGTMgL0CM/rAGQ6AQYt/VlR16t8JTb/WejFPf/SpZJjD fh8RCtHWp8Z5aBzwoJQkkA==; Date: Sun, 08 Dec 2024 07:57:13 +0200 Message-Id: <86ikruhg3q.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <87frmz40f2.fsf@daniel-mendler.de> (bug-gnu-emacs@gnu.org) Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind References: <87frmz40f2.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 07 Dec 2024 23:02:09 +0100 > From: Daniel Mendler via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > The command `eww-browse-with-external-browser' uses > `browse-url-secondary-browser-function'. This makes the command > ineffective in the common setup where > `browse-url-secondary-browser-function' is set to `eww-browse-url' and > `browse-url-browser-function' is set to an external browser. The doc string of browse-url-secondary-browser-function explicitly says not to set it to eww. So users who do the above are acting against the design and the recommended usage, and I'm not sure we should support that at all, let alone with a (seemingly) backward-incompatible change such as the one you propose. > Fortunately we can use `browse-url-with-browser-kind' instead, which > guarantees that an external browser is launched. > > Furthermore `eww-follow-link' should use `browse-url-with-browser-kind' > if the EXTERNAL prefix argument is non-nil. > > I've looked at all other uses of `browse-url-browser-function' and > `browse-url-secondary-browser-function' in the Emacs code base and I > have not found other problems. Most commands use a prefix argument to > switch to the secondary browser, relying on the primary browser by > default. The problem is limited to `eww-browse-with-external-browser' > and `eww-follow-link'. What will happen as result of this change to users who customize browse-url-secondary-browser-function as its doc string says, and then invoke the command eww-browse-with-external-browser? From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 01:16:15 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 06:16:15 +0000 Received: from localhost ([127.0.0.1]:49404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKAaV-0005GJ-8Q for submit@debbugs.gnu.org; Sun, 08 Dec 2024 01:16:15 -0500 Received: from server.qxqx.de ([49.12.34.165]:58575 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKAaT-0005G4-Ap for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 01:16:14 -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=pitGgrZr76MAF+QZbqxJuaVOpN89G7YCnmmlfR+RVAQ=; b=BqR/Fo9GLtkkKV8NZtOezDCTN0 EIUDxFOIaceaaBER6xUPBkZD1lfHW9totMiW1JrEnbfnfynMluL+YCfdnabBucdN5bPrfjZULCwIl cHkxAWzc7N2TexJVfmqLOQNgfHO9Sl2rsm66VDl6Z30W5rydahKL4bKShuE5l1egRvlk=; From: Daniel Mendler To: Eli Zaretskii Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind In-Reply-To: <86ikruhg3q.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Dec 2024 07:57:13 +0200") References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> Date: Sun, 08 Dec 2024 07:13:54 +0100 Message-ID: <87wmga7lct.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: >> Date: Sat, 07 Dec 2024 23:02:09 +0100 >> From: Daniel Mendler via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> The command `eww-browse-with-external-browser' uses >> `browse-url-secondary-browser-function'. This makes the command >> ineffective in the common setup where >> `browse-url-secondary-browser-function' is set to `eww-browse-url' and >> `browse-url-browser-function' is set to an external browser. > > The doc string of browse-url-secondary-browser-function explicitly > says not to set it to eww. So users who do the above are acting > against the design and the recommended usage, and I'm not sure we > should support that at all, let alone with a (seemingly) > backward-incompatible change such as the one you propose. How can I then use an external browser as the default and Eww as alternative? I argue that this is a legitimate use case - an external browser as primary and Eww as secondary browser for distraction-free reading. As I wrote, the only place which leads to problems is in `eww-browse-with-external-browser' - I checked all other places in Emacs. I argue that the behavior and implementation will be even more explicit, since `browse-url-with-browser-kind' explicitly supports the `external' kind. But you are right about the backward compatibility problem, see below. >> Fortunately we can use `browse-url-with-browser-kind' instead, which >> guarantees that an external browser is launched. >> >> Furthermore `eww-follow-link' should use `browse-url-with-browser-kind' >> if the EXTERNAL prefix argument is non-nil. >> >> I've looked at all other uses of `browse-url-browser-function' and >> `browse-url-secondary-browser-function' in the Emacs code base and I >> have not found other problems. Most commands use a prefix argument to >> switch to the secondary browser, relying on the primary browser by >> default. The problem is limited to `eww-browse-with-external-browser' >> and `eww-follow-link'. > > What will happen as result of this change to users who customize > browse-url-secondary-browser-function as its doc string says, and then > invoke the command eww-browse-with-external-browser? In this case the change will indeed be backward-incompatible, if multiple external browsers are used and the secondary browser is configured to a different one than the one which will be selected by `browse-url-with-browser-kind'. The patch can be extended however. I can change it such that the `browse-url-secondary-browser-function' is checked first if it is indeed external (via the `browser-kind' property). And only if it is not external, `browse-url-with-browser-kind' will be used. One could be even more strict and compare `browse-url-secondary-browser-function' to `eww-browse-url' and only in this case fall back to `browse-url-with-browser-kind'. Daniel From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 02:03:13 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 07:03:13 +0000 Received: from localhost ([127.0.0.1]:49475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKBJw-0007v0-OE for submit@debbugs.gnu.org; Sun, 08 Dec 2024 02:03:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKBJv-0007uk-44 for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 02:03:12 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKBJo-00069C-70; Sun, 08 Dec 2024 02:03:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=waFNwsASOMRHzQ/SJs3nRE2nJBr9eDfiqKiLGGhyMeU=; b=OdvjgHAyA3/k 0n93ynOGfs43cfpqR6iV+TWNJ+ow7fq2JOt4cpHhTJgxtryhIwCbZLDrNj0eIBpyvHoC0FE2QeC78 VoSgbHxEqw2LfOu4bMihHSPX0+/4/9Z4E/JoAS1IDOgOyDxspDx+E2CdQG0p2h6zJ9p2z0cAjXidF M06OctglSXofpu5VzVN1Bheial3eDEh6BZNLcXvUqz0shXkqmXOL8LWjpg7T5KCtIrPH9zo9DB7dL DtmLDmcFtzc1SbBch6BdC54zZ/ORgwDO8Lv1hoaa2XkmvCNcxMofrZR9vfdFgw3RuA+HTDTlnqj+c q9LNEYvRu1N3+MEqi0cgjg==; Date: Sun, 08 Dec 2024 09:03:02 +0200 Message-Id: <867c8ahd21.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <87wmga7lct.fsf@daniel-mendler.de> (message from Daniel Mendler on Sun, 08 Dec 2024 07:13:54 +0100) Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <87wmga7lct.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Daniel Mendler > Cc: 74730@debbugs.gnu.org > Date: Sun, 08 Dec 2024 07:13:54 +0100 > > Eli Zaretskii writes: > > > The doc string of browse-url-secondary-browser-function explicitly > > says not to set it to eww. So users who do the above are acting > > against the design and the recommended usage, and I'm not sure we > > should support that at all, let alone with a (seemingly) > > backward-incompatible change such as the one you propose. > > How can I then use an external browser as the default and Eww as > alternative? I argue that this is a legitimate use case - an external > browser as primary and Eww as secondary browser for distraction-free > reading. It is a legitimate use case, but please describe it in more detail: what do you mean by "using external browser as primary and eww as secondary"? That is, which Emacs commands should behave like that? E.g., is "use browse-url-with-browser-kind" a valid solution for the use case you describe? If not, why not? > As I wrote, the only place which leads to problems is in > `eww-browse-with-external-browser' - I checked all other places in > Emacs. You haven't describe the results of your investigation in detail. I see 6 callers of browse-url-secondary-browser-function, so please explain how this change is not a problem in each one of them. Your original message said that "most commands use a prefix argument to switch to the secondary browser", but I don't understand how saying that allows you to conclude that this change will not cause trouble? > I argue that the behavior and implementation will be even more > explicit, since `browse-url-with-browser-kind' explicitly supports the > `external' kind. But you are right about the backward compatibility > problem, see below. > [...] > > What will happen as result of this change to users who customize > > browse-url-secondary-browser-function as its doc string says, and then > > invoke the command eww-browse-with-external-browser? > > In this case the change will indeed be backward-incompatible, if > multiple external browsers are used and the secondary browser is > configured to a different one than the one which will be selected by > `browse-url-with-browser-kind'. > > The patch can be extended however. I can change it such that the > `browse-url-secondary-browser-function' is checked first if it is indeed > external (via the `browser-kind' property). And only if it is not > external, `browse-url-with-browser-kind' will be used. One could be even > more strict and compare `browse-url-secondary-browser-function' to > `eww-browse-url' and only in this case fall back to > `browse-url-with-browser-kind'. If we can make it so that existing customizations of browse-url-secondary-browser-function will keep working as they did, then the backward incompatibility issue will disappear, and such a change becomes possible. But in any case, the doc string of browse-url-secondary-browser-function should be amended if we are going to support its setting to eww. Also, are we sure all the relevant functions always have the 'browse-url-browser-kind property? what about user-defined functions, for example? From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 02:27:31 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 07:27:31 +0000 Received: from localhost ([127.0.0.1]:49509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKBhS-0000hj-JU for submit@debbugs.gnu.org; Sun, 08 Dec 2024 02:27:31 -0500 Received: from server.qxqx.de ([49.12.34.165]:41349 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKBhQ-0000hR-2Q for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 02:27:29 -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=pHmEEzbM4UYZZmWbsqIeJA5Aas3nU8wRfCWFpK3t3hE=; b=ijOZgTdM+IYqI9NQwaVzkZpLou Dv7co7WmiX390is1YtKrw+D+GEvFAqfGSe93nsHxp9uUV8kIYzkKUWAnvRopGP0NgK3S67RRIOjNz ArID0SF/reGaLjMNUnNvdheB/UESiMh2JXBcZZzevP4fxwOtUZ1PpU/4VUGTb3MWmp/U=; From: Daniel Mendler To: Eli Zaretskii Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind In-Reply-To: <86ikruhg3q.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Dec 2024 07:57:13 +0200") References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> Date: Sun, 08 Dec 2024 08:27:20 +0100 Message-ID: <874j3ed487.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: >> From: Daniel Mendler >> Cc: 74730@debbugs.gnu.org >> Date: Sun, 08 Dec 2024 07:13:54 +0100 >> >> Eli Zaretskii writes: >> >> > The doc string of browse-url-secondary-browser-function explicitly >> > says not to set it to eww. So users who do the above are acting >> > against the design and the recommended usage, and I'm not sure we >> > should support that at all, let alone with a (seemingly) >> > backward-incompatible change such as the one you propose. >> >> How can I then use an external browser as the default and Eww as >> alternative? I argue that this is a legitimate use case - an external >> browser as primary and Eww as secondary browser for distraction-free >> reading. > > It is a legitimate use case, but please describe it in more detail: > what do you mean by "using external browser as primary and eww as > secondary"? That is, which Emacs commands should behave like that? In Emacs there are many commands which use `browse-url-browser-function' or `browse-url-secondary-browser-function' depending on the prefix argument. Many of the commands are generic and act on URLs or buttons at point in different kinds of buffers. Also many external packages use `browse-url'. - `goto-address-at-point' - `browse-url-button-open' - `browse-url-button-open-url' - `package-browse-url' - `gnus-summary-browse-url' When any of these commands on links is invoked, the `browse-url-browser-function' is used by default. The primary browser is configured by `browse-url-browser-function' while the secondary browser is configured by `browse-url-secondary-browser-function'. Both use cases are plausible: `browse-url-browser-function' can be external and `browse-url-secondary-browser-function' can be internal and vice versa. > E.g., is "use browse-url-with-browser-kind" a valid solution for the > use case you describe? If not, why not? `browse-url-with-browser-kind' can be used when one explicitly wants to call an external or internal browser. The command in Eww `eww-browse-with-external-browser' has `*-external-*' as part of its name, so in this case I think is a valid solution. >> As I wrote, the only place which leads to problems is in >> `eww-browse-with-external-browser' - I checked all other places in >> Emacs. > > You haven't describe the results of your investigation in detail. I > see 6 callers of browse-url-secondary-browser-function, so please > explain how this change is not a problem in each one of them. Your > original message said that "most commands use a prefix argument to > switch to the secondary browser", but I don't understand how saying > that allows you to conclude that this change will not cause trouble? Each of the other call sites does not make assumptions about the internal or external distinction. All that is important is that two browser functions exist - a primary browser function and a secondary function. By default the primary function is called, and if explicitly requested by the user via a prefix argument, the secondary function is used. It does not matter if the functions point to external or internal browsers. >> I argue that the behavior and implementation will be even more >> explicit, since `browse-url-with-browser-kind' explicitly supports the >> `external' kind. But you are right about the backward compatibility >> problem, see below. >> [...] >> > What will happen as result of this change to users who customize >> > browse-url-secondary-browser-function as its doc string says, and then >> > invoke the command eww-browse-with-external-browser? >> >> In this case the change will indeed be backward-incompatible, if >> multiple external browsers are used and the secondary browser is >> configured to a different one than the one which will be selected by >> `browse-url-with-browser-kind'. >> >> The patch can be extended however. I can change it such that the >> `browse-url-secondary-browser-function' is checked first if it is indeed >> external (via the `browser-kind' property). And only if it is not >> external, `browse-url-with-browser-kind' will be used. One could be even >> more strict and compare `browse-url-secondary-browser-function' to >> `eww-browse-url' and only in this case fall back to >> `browse-url-with-browser-kind'. > > If we can make it so that existing customizations of > browse-url-secondary-browser-function will keep working as they did, > then the backward incompatibility issue will disappear, and such a > change becomes possible. But in any case, the doc string of > browse-url-secondary-browser-function should be amended if we are > going to support its setting to eww. Okay, I can do that. > Also, are we sure all the relevant functions always have the > 'browse-url-browser-kind property? what about user-defined functions, > for example? User-defined functions may not have the property. But we can be conservative and preserve the existing behavior in the case where the property is unavailable, treating the missing property like the value `external'. Only if the property is found and `internal', the `browse-url-with-browser-kind' will be used to make sure that an external browser is used. As I mentioned, alternatively one can be even more conservative and only use `browse-url-with-browser-kind' if `browse-url-secondary-browser-function' is set to `eww-browse-url'. That might be a little bit too restrictive, but it would be completely backward compatible. Daniel From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 07:04:33 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 12:04:33 +0000 Received: from localhost ([127.0.0.1]:49897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKG1Y-0005Oe-Ra for submit@debbugs.gnu.org; Sun, 08 Dec 2024 07:04:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKG1W-0005OP-Vo for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 07:04:31 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKFzJ-0003Ft-BO; Sun, 08 Dec 2024 07:02:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=RRhULYWYVHIcK2TEMVpyhw+SBjT2EXNv9bVQW+ott5A=; b=hGrr77RtHENh rHGdEMQ9Acr1ijqWhn7hOApTbwbwGoPtgaqi1zpB4dtNgE6qU3MkYPHV9O5gWV7uyM3HdBeFp6vtR yC+PkSvkAYnjdo6ykriO8El9SCHVppFJI7FaDWKtpMPnPvbP4p55imlu4QJoyBtOpN9+LxBNlHIRB gbXmM8zyHXlGN1Yn7hkhdlvXp4IrlsU+y0wgmkT1HI9uGEKUiOHrrAbnBLs5+lcH9JgtMrLCMSk83 kUWvJPRFT22egPp10SLS9EwY5hkS/N3P06w7tG+200Gbab/Eo4PV9lEUD+08RXh9BbeXa2+Lvti6r 4OnwWhIjNP6n8OGi/FrM6w==; Date: Sun, 08 Dec 2024 14:02:04 +0200 Message-Id: <86r06ifkn7.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <874j3ed487.fsf@daniel-mendler.de> (message from Daniel Mendler on Sun, 08 Dec 2024 08:27:20 +0100) Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <874j3ed487.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Daniel Mendler > Cc: 74730@debbugs.gnu.org > Date: Sun, 08 Dec 2024 08:27:20 +0100 > > > You haven't describe the results of your investigation in detail. I > > see 6 callers of browse-url-secondary-browser-function, so please > > explain how this change is not a problem in each one of them. Your > > original message said that "most commands use a prefix argument to > > switch to the secondary browser", but I don't understand how saying > > that allows you to conclude that this change will not cause trouble? > > Each of the other call sites does not make assumptions about the > internal or external distinction. Except that anything that calls them in eww must make some assumptions, because it could otherwise cause infinite recursion. > > If we can make it so that existing customizations of > > browse-url-secondary-browser-function will keep working as they did, > > then the backward incompatibility issue will disappear, and such a > > change becomes possible. But in any case, the doc string of > > browse-url-secondary-browser-function should be amended if we are > > going to support its setting to eww. > > Okay, I can do that. > > > Also, are we sure all the relevant functions always have the > > 'browse-url-browser-kind property? what about user-defined functions, > > for example? > > User-defined functions may not have the property. But we can be > conservative and preserve the existing behavior in the case where the > property is unavailable, treating the missing property like the value > `external'. Only if the property is found and `internal', the > `browse-url-with-browser-kind' will be used to make sure that an > external browser is used. As I mentioned, alternatively one can be even > more conservative and only use `browse-url-with-browser-kind' if > `browse-url-secondary-browser-function' is set to `eww-browse-url'. That > might be a little bit too restrictive, but it would be completely > backward compatible. Looking forward to seeing an updated patch which preserves the current behavior wrt browse-url-secondary-browser-function's customization. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 08:03:17 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 13:03:17 +0000 Received: from localhost ([127.0.0.1]:49989 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKGwO-0008Gr-Sk for submit@debbugs.gnu.org; Sun, 08 Dec 2024 08:03:17 -0500 Received: from server.qxqx.de ([49.12.34.165]:60055 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKGwL-0008GW-NS for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 08:03:14 -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=6IJbY2kJ8Ah20vaPdUkzArm//umAx8qLgry6H2SuGjk=; b=hhCngEtBozcQWukFRDESKCGJHc 2VfUk/jIiGTP/gkViyQVUz8qcmtvdBBM+VyR5zSIrLd9k2yN2FlAQN3Y5Om9UQW9kYlUtJFFd1LsW rc7xoqS4FzLsul2+rJD+YMAXO5hyOzAawIvifP11NjhThYPoxkjsBuJVfqT9wyNV3wkw=; From: Daniel Mendler To: Eli Zaretskii Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind In-Reply-To: <86r06ifkn7.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Dec 2024 14:02:04 +0200") References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <874j3ed487.fsf@daniel-mendler.de> <86r06ifkn7.fsf@gnu.org> Date: Sun, 08 Dec 2024 14:00:56 +0100 Message-ID: <8734iycos7.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> > If we can make it so that existing customizations of >> > browse-url-secondary-browser-function will keep working as they did, >> > then the backward incompatibility issue will disappear, and such a >> > change becomes possible. But in any case, the doc string of >> > browse-url-secondary-browser-function should be amended if we are >> > going to support its setting to eww. >> >> Okay, I can do that. >> >> > Also, are we sure all the relevant functions always have the >> > 'browse-url-browser-kind property? what about user-defined functions, >> > for example? >> >> User-defined functions may not have the property. But we can be >> conservative and preserve the existing behavior in the case where the >> property is unavailable, treating the missing property like the value >> `external'. Only if the property is found and `internal', the >> `browse-url-with-browser-kind' will be used to make sure that an >> external browser is used. As I mentioned, alternatively one can be even >> more conservative and only use `browse-url-with-browser-kind' if >> `browse-url-secondary-browser-function' is set to `eww-browse-url'. That >> might be a little bit too restrictive, but it would be completely >> backward compatible. > > Looking forward to seeing an updated patch which preserves the current > behavior wrt browse-url-secondary-browser-function's customization. > > Thanks. Updated patch attached. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-eww-Improve-eww-browse-with-external-browser.patch >From 9d782ed2123b34fd09268f6c83305d7d9d4acf7d Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 7 Dec 2024 22:56:15 +0100 Subject: [PATCH] eww: Improve 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' if it does not correspond to EWW, otherwise fall back to `browse-url'. (eww-follow-link): Use `eww-browse-with-external-browser' if the EXTERNAL prefix argument is non-nil. * lisp/net/browse-url.el (browse-url-secondary-browser-function): Update docstring. --- lisp/net/browse-url.el | 8 ++++---- lisp/net/eww.el | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index c10bc671a88..c9d8b2ee80d 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -198,10 +198,10 @@ browse-url-browser-function (defcustom browse-url-secondary-browser-function 'browse-url-default-browser "Function used to launch an alternative browser. -This is usually an external browser (that is, not eww or w3m), -used as the secondary browser choice, typically when a prefix -argument is given to a URL-opening command in those modes that -support this (for instance, eww/shr). + +This is browser is used as the secondary browser choice, typically +when a prefix argument is given to a URL-opening command in those +modes that support this (for instance `goto-addr-at-point', eww or shr). Also see `browse-url-browser-function'." :version "27.1" diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 4d4d4d6beac..b2d295a4dcf 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2142,10 +2142,13 @@ eww-submit (defun eww-browse-with-external-browser (&optional url) "Browse the current URL with an external browser. -The browser to used is specified by the -`browse-url-secondary-browser-function' variable." +Calls `browse-url-secondary-browser-function' if it does not correspond +to EWW. Otherwise `browse-url' is used." (interactive nil eww-mode) - (funcall browse-url-secondary-browser-function + (funcall (if (memq browse-url-secondary-browser-function + '(eww eww-browse-url)) + #'browse-url + browse-url-secondary-browser-function) (or url (plist-get eww-data :url)))) (defun eww-remove-tracking (url) @@ -2162,8 +2165,7 @@ eww--transform-url (defun eww-follow-link (&optional external mouse-event) "Browse the URL under point. If EXTERNAL is single prefix, browse the URL using -`browse-url-secondary-browser-function'. - +`eww-browse-with-external-browser'. If EXTERNAL is double prefix, browse in new buffer." (interactive (list current-prefix-arg last-nonmenu-event) @@ -2180,7 +2182,7 @@ eww-follow-link ;; and `browse-url-mailto-function'. (browse-url url)) ((and (consp external) (<= (car external) 4)) - (funcall browse-url-secondary-browser-function url) + (eww-browse-with-external-browser url) (shr--blink-link)) ;; This is a #target url in the same page as the current one. ((and (setq target (url-target (url-generic-parse-url url))) -- 2.45.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 08:32:45 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 13:32:45 +0000 Received: from localhost ([127.0.0.1]:50033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKHOu-0001HS-Fu for submit@debbugs.gnu.org; Sun, 08 Dec 2024 08:32:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKHOs-0001HC-Uj for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 08:32:43 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKHOm-0006bp-4t; Sun, 08 Dec 2024 08:32:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=k7rNacL3UZbG6k7l6bMhX1j6tV8Oy5YQvYrAEPbp2Q4=; b=FlU+1ehYFF/r wNNmu2YfoQ+ntLSs7reQQYZZRpWCITUxPPDoA0nJ4CfsQ6M4pXUwr4CZFjAZk0QOsaKVBxlueFYxe nFNJv9O8xX4FEUfno1H5davApqJSZl7DSQU/kwgNwpGp8x8vgsmCjpr6wXJDZpQNr+VqsVvnuAKdU XbxbgIInurFZB4H7Bwq5yyIL5PcnY3L/uPSU44NQQDGBMHdZFePWCHUOWwod0KIE9pmJr27PXiAiv DsRJvUNtJyCmqsCANGD8AkImCfqy9qZpn795yxPxaVhOFWaLNsRSld8v/Ml8KHKQL3yRyNCwNkBAf pn7x/zm1tI6hzG919PCEKA==; Date: Sun, 08 Dec 2024 15:32:31 +0200 Message-Id: <86msh6fggg.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <8734iycos7.fsf@daniel-mendler.de> (message from Daniel Mendler on Sun, 08 Dec 2024 14:00:56 +0100) Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <874j3ed487.fsf@daniel-mendler.de> <86r06ifkn7.fsf@gnu.org> <8734iycos7.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Daniel Mendler > Cc: 74730@debbugs.gnu.org > Date: Sun, 08 Dec 2024 14:00:56 +0100 > > Eli Zaretskii writes: > > >> > If we can make it so that existing customizations of > >> > browse-url-secondary-browser-function will keep working as they did, > >> > then the backward incompatibility issue will disappear, and such a > >> > change becomes possible. But in any case, the doc string of > >> > browse-url-secondary-browser-function should be amended if we are > >> > going to support its setting to eww. > >> > >> Okay, I can do that. > >> > >> > Also, are we sure all the relevant functions always have the > >> > 'browse-url-browser-kind property? what about user-defined functions, > >> > for example? > >> > >> User-defined functions may not have the property. But we can be > >> conservative and preserve the existing behavior in the case where the > >> property is unavailable, treating the missing property like the value > >> `external'. Only if the property is found and `internal', the > >> `browse-url-with-browser-kind' will be used to make sure that an > >> external browser is used. As I mentioned, alternatively one can be even > >> more conservative and only use `browse-url-with-browser-kind' if > >> `browse-url-secondary-browser-function' is set to `eww-browse-url'. That > >> might be a little bit too restrictive, but it would be completely > >> backward compatible. > > > > Looking forward to seeing an updated patch which preserves the current > > behavior wrt browse-url-secondary-browser-function's customization. > > > > Thanks. > > Updated patch attached. Thanks, a few comments below. > (defcustom browse-url-secondary-browser-function 'browse-url-default-browser > "Function used to launch an alternative browser. > -This is usually an external browser (that is, not eww or w3m), > -used as the secondary browser choice, typically when a prefix > -argument is given to a URL-opening command in those modes that > -support this (for instance, eww/shr). > + > +This is browser is used as the secondary browser choice, typically > +when a prefix argument is given to a URL-opening command in those > +modes that support this (for instance `goto-addr-at-point', eww or shr). This doc string should explain the assumptions about this and the other variable, browse-url-browser-function: that either one or the other invokes the external browser, and the other one should then NOT do the same. Users should be aware and understand the rules of the game here, which are now slightly more complex than they were before, so removing the previous assumption without replacing it with anything makes the doc string less useful. > (defun eww-browse-with-external-browser (&optional url) > "Browse the current URL with an external browser. > -The browser to used is specified by the > -`browse-url-secondary-browser-function' variable." > +Calls `browse-url-secondary-browser-function' if it does not correspond > +to EWW. Otherwise `browse-url' is used." ^^^^^^^^^^^^^^^^^^^^ Passive tense alert! > (interactive nil eww-mode) > - (funcall browse-url-secondary-browser-function > + (funcall (if (memq browse-url-secondary-browser-function > + '(eww eww-browse-url)) > + #'browse-url > + browse-url-secondary-browser-function) I think we should allow here (and document) more just 2 literal functions hard-coded in this command. Perhaps some special property on the function's symbol? Then these two specific functions can be supported via the property, and what's more important, users and applications could use other functions with the same semantics. > (defun eww-follow-link (&optional external mouse-event) > "Browse the URL under point. > If EXTERNAL is single prefix, browse the URL using ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What does this mean? does it mean that EXTERNAL is non-nil in interactive usage if the command is invoked with C-u? If so, let's say that. (Yes, I know that problem came from the original doc string.) > @@ -2180,7 +2182,7 @@ eww-follow-link > ;; and `browse-url-mailto-function'. > (browse-url url)) > ((and (consp external) (<= (car external) 4)) > - (funcall browse-url-secondary-browser-function url) > + (eww-browse-with-external-browser url) I'm not sure I agree. The call to eww-browse-with-external-browser will no longer ensure an external browser is used, after these changes. Why not call browse-url-default-browser instead? In any case, the doc string should say that if no external browser could be found, this will fall back to eww. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 12:39:39 2024 Received: (at 74730) by debbugs.gnu.org; 8 Dec 2024 17:39:39 +0000 Received: from localhost ([127.0.0.1]:51598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKLFq-0005Ni-HT for submit@debbugs.gnu.org; Sun, 08 Dec 2024 12:39:39 -0500 Received: from server.qxqx.de ([49.12.34.165]:53379 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKLFo-0005NF-Cm for 74730@debbugs.gnu.org; Sun, 08 Dec 2024 12:39:37 -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=WBMIUzY/9u0yNIAoX9Zx0CR1lC7OuzlicNKjES2AIbc=; b=V0eapLTQoVK7/l8L6dnCcwVMGB w7HD8ybbHT2Yn+d3FlVNsSiIPE0LyVf3O7x5Qsmj9+mJVamVwn2Y5E06yrXPVL90KpM1XAboK6/SO eNBRljdSlWYWyE2yFpoJTnwe2N4YoySzRmTV+bI54anhfSsgaQ1ngKhy3+JOAP4tCEa0=; From: Daniel Mendler To: Eli Zaretskii Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind In-Reply-To: <86msh6fggg.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 08 Dec 2024 15:32:31 +0200") References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <874j3ed487.fsf@daniel-mendler.de> <86r06ifkn7.fsf@gnu.org> <8734iycos7.fsf@daniel-mendler.de> <86msh6fggg.fsf@gnu.org> Date: Sun, 08 Dec 2024 18:39:28 +0100 Message-ID: <87h67e3whb.fsf@daniel-mendler.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74730 Cc: 74730@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: Updated patch attached. >> (defcustom browse-url-secondary-browser-function 'browse-url-default-browser >> "Function used to launch an alternative browser. >> -This is usually an external browser (that is, not eww or w3m), >> -used as the secondary browser choice, typically when a prefix >> -argument is given to a URL-opening command in those modes that >> -support this (for instance, eww/shr). >> + >> +This is browser is used as the secondary browser choice, typically >> +when a prefix argument is given to a URL-opening command in those >> +modes that support this (for instance `goto-addr-at-point', eww or shr). > > This doc string should explain the assumptions about this and the > other variable, browse-url-browser-function: that either one or the > other invokes the external browser, and the other one should then NOT > do the same. Users should be aware and understand the rules of the > game here, which are now slightly more complex than they were before, > so removing the previous assumption without replacing it with anything > makes the doc string less useful. I expanded the docstring. >> (interactive nil eww-mode) >> - (funcall browse-url-secondary-browser-function >> + (funcall (if (memq browse-url-secondary-browser-function >> + '(eww eww-browse-url)) >> + #'browse-url >> + browse-url-secondary-browser-function) > > I think we should allow here (and document) more just 2 literal > functions hard-coded in this command. Perhaps some special property > on the function's symbol? Then these two specific functions can be > supported via the property, and what's more important, users and > applications could use other functions with the same semantics. In this case I think it is better to use `browse-url-with-browser-kind' as I had initially suggested. This will be better than introducing yet another property only for this purpose. >> (defun eww-follow-link (&optional external mouse-event) >> "Browse the URL under point. >> If EXTERNAL is single prefix, browse the URL using > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > What does this mean? does it mean that EXTERNAL is non-nil in > interactive usage if the command is invoked with C-u? If so, let's > say that. (Yes, I know that problem came from the original doc > string.) I improved the docstring. >> @@ -2180,7 +2182,7 @@ eww-follow-link >> ;; and `browse-url-mailto-function'. >> (browse-url url)) >> ((and (consp external) (<= (car external) 4)) >> - (funcall browse-url-secondary-browser-function url) >> + (eww-browse-with-external-browser url) > > I'm not sure I agree. The call to eww-browse-with-external-browser > will no longer ensure an external browser is used, after these > changes. Why not call browse-url-default-browser instead? Now, it is ensured that the external browser is called. Daniel --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-eww-Use-browse-url-with-browser-kind-in-eww-browse-w.patch >From f56022cc4b1f9c007ba583ece8f2c714a92eefc6 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Sat, 7 Dec 2024 22:56:15 +0100 Subject: [PATCH] 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. --- lisp/net/browse-url.el | 14 ++++++++++---- lisp/net/eww.el | 23 ++++++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index c10bc671a88..8ec025d017b 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -198,10 +198,16 @@ browse-url-browser-function (defcustom browse-url-secondary-browser-function 'browse-url-default-browser "Function used to launch an alternative browser. -This is usually an external browser (that is, not eww or w3m), -used as the secondary browser choice, typically when a prefix -argument is given to a URL-opening command in those modes that -support this (for instance, eww/shr). + +This browser is used as the secondary browser choice, typically +when a prefix argument is given to a URL-opening command in those +modes that support this (for instance `browse-url-at-point', +`goto-addr-at-point', eww or shr). + +This assumption is that `browse-url-secondary-browser-function' +and `browse-url-browser-function' are set to distinct browsers. +Either one of the two functions should call an external browser +and the other one should not do the same. Also see `browse-url-browser-function'." :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 @@ eww-submit (defun eww-browse-with-external-browser (&optional url) "Browse the current URL with an external browser. -The browser to used is specified by the -`browse-url-secondary-browser-function' variable." +Use `browse-url-secondary-browser-function' if it is an external +browser, otherwise use `browse-url-with-browser-kind' to open an +external browser." (interactive nil eww-mode) - (funcall browse-url-secondary-browser-function - (or url (plist-get eww-data :url)))) + (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) + (browse-url-with-browser-kind 'external url))) (defun eww-remove-tracking (url) "Remove the commong utm_ tracking cookies from URLs." @@ -2160,11 +2164,12 @@ eww--transform-url url)) (defun eww-follow-link (&optional external mouse-event) - "Browse the URL under point. -If EXTERNAL is single prefix, browse the URL using -`browse-url-secondary-browser-function'. + "Browse the URL at point, optionally the position of MOUSE-EVENT. -If EXTERNAL is double prefix, browse in new buffer." +EXTERNAL is the prefix argument. If called interactively with +\\[universal-argument] pressed once, browse the URL using +`eww-browse-with-external-browser'. If called interactively, with +\\[universal-argument] pressed twice, browse in new buffer." (interactive (list current-prefix-arg last-nonmenu-event) eww-mode) @@ -2180,7 +2185,7 @@ eww-follow-link ;; and `browse-url-mailto-function'. (browse-url url)) ((and (consp external) (<= (car external) 4)) - (funcall browse-url-secondary-browser-function url) + (eww-browse-with-external-browser url) (shr--blink-link)) ;; This is a #target url in the same page as the current one. ((and (setq target (url-target (url-generic-parse-url url))) -- 2.45.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 12 05:42:27 2024 Received: (at 74730-done) by debbugs.gnu.org; 12 Dec 2024 10:42:27 +0000 Received: from localhost ([127.0.0.1]:37786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLgeJ-0007xo-9L for submit@debbugs.gnu.org; Thu, 12 Dec 2024 05:42:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLgeE-0007xL-QJ for 74730-done@debbugs.gnu.org; Thu, 12 Dec 2024 05:42:25 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLge8-0002kV-P0; Thu, 12 Dec 2024 05:42:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=lbvrA/K7WDEbXOMLPj1QF9WyfetL9/66Y7bkxhPA7es=; b=Yh1vKRpse9/e Cnzd84T4+U+VG18JOAspRZHL+HOd7wdQRMGcyStOxNDbidpZh9YcD+npldOWOuvynFq6e5DIdsqxx HYGRLKx8wRehhTC9yKZcRBZdILidlu6wdYBY1E++BZLaFUJJk9yfk8ZnIflHSTyD/tGv4CSDgy2pJ 6oSd7LpliQY30xX+Aj7QasEzutUSscRyag6DQq5AWQR2Ogf1OQ/DirWp5fC8AOcNGzg+wrbeYlzVE +LoHX1CNSoNg9Vs77XPpnnpvVawe1xM6XwALYQ86+x40yMaVDE5atbGFsUonfa8/Cppw+FMF/XvIV nUhhQe9+72oNKHppr9T5ew==; Date: Thu, 12 Dec 2024 12:42:12 +0200 Message-Id: <861pyd18u3.fsf@gnu.org> From: Eli Zaretskii To: Daniel Mendler In-Reply-To: <87h67e3whb.fsf@daniel-mendler.de> (message from Daniel Mendler on Sun, 08 Dec 2024 18:39:28 +0100) Subject: Re: bug#74730: [PATCH] 30.0.92; eww-browse-with-external-browser and eww-follow-link should use browse-url-with-browser-kind References: <87frmz40f2.fsf@daniel-mendler.de> <86ikruhg3q.fsf@gnu.org> <874j3ed487.fsf@daniel-mendler.de> <86r06ifkn7.fsf@gnu.org> <8734iycos7.fsf@daniel-mendler.de> <86msh6fggg.fsf@gnu.org> <87h67e3whb.fsf@daniel-mendler.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74730-done Cc: 74730-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Daniel Mendler > Cc: 74730@debbugs.gnu.org > Date: Sun, 08 Dec 2024 18:39:28 +0100 > > Updated patch attached. Thanks, installed on the master branch, and closing the bug. From unknown Sun Jun 15 08:45:52 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 09 Jan 2025 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator