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#74820: [PATCH] browse-url-with-browser-kind: Improve browser function selection Date: Thu, 12 Dec 2024 12:41:50 +0100 Message-ID: <87pllx9lhd.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="2156"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 74820@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 12 12:43:32 2024 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 1tLhbQ-0000O6-IW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Dec 2024 12:43:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLhay-0006PG-Tf; Thu, 12 Dec 2024 06:43: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 1tLhaw-0006OH-RJ for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 06:43:02 -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 1tLhaw-0006dd-Ie for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 06:43: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:From:To:Subject; bh=eok/6WYYOToTcXoTpjFA2SbKiTsonXHmwDkfFTAHick=; b=j/YQ+rp0Oeeg07QzJzz7PMn9OZtx8Rs3Dfn3jph/S/nJTkpfb7cWUIgUKf8aoxmZUOzrmuFOEygj5rO3RTLUFPvJlQ8QOO4V0w4hAef0n+p8Yvb/x6wMqKilvu2Doia/IGi5q+WGqSyxy/wjovVVDXx97yTstrsLb+/vV9UWE856cpL8Sdx/SKx4MsdLgDasmYEOXcdNBtjFklSQAEm5INxTZQnwZGUuvhU1gbo1ZyX+QuJxzeODqGeTbirpNITeOYEj3Bq0RBsFFASfiNnFttPNiNP+YKRx+7u/tt45vhBdal+hS4NhxHvskX79OZf0Qq03cU5y9SI7NWqVC4VnBA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLhaw-0002qp-BR for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 06:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2024 11:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74820 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173400374610882 (code B ref -1); Thu, 12 Dec 2024 11:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Dec 2024 11:42:26 +0000 Original-Received: from localhost ([127.0.0.1]:37959 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLhaL-0002pS-PJ for submit@debbugs.gnu.org; Thu, 12 Dec 2024 06:42:26 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLhaJ-0002pJ-Bk for submit@debbugs.gnu.org; Thu, 12 Dec 2024 06:42:24 -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 1tLhaH-0006Ik-Lb for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 06:42:22 -0500 Original-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 1tLhaD-0006Zo-OP for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 06:42:21 -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=eok/6WYYOToTcXoTpjFA2SbKiTsonXHmwDkfFTAHick=; b=RTmB6g6adEcgis9y4xZRyvkrqt Fj3IDW28u23YG1Dzgzq5Qh3AN+x7a2us2CCb2NuIgFEiqKNoBs/wJc1lYoEOv2uWO8s8Z34yomKrB dzw+p4zgiVc+tWENZq5/EeJBC4Mj8m22stfN+JSmBQ+aas4sRBfSH6Tsy4hvpt9UY1bo=; 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-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:296909 Archived-At: --=-=-= Content-Type: text/plain Tags: patch In order to find an appropriate browser function for the given kind, first the browser handler lists are consulted. If no handler is found, the `browse-url-browser-function', `browse-url-secondary-browser-function`, `browse-url-default-browser' and `eww' are tried in that order until a browser function with a matching kind is found. This way the user customization of `browse-url-browser-function' and `browse-url-secondary-browser-function` is respected by `browse-url-with-browser-kind'. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-browse-url-with-browser-kind-Improve-browser-functio.patch >From f2972d6074e314e43fbb9630e5b597ff2ae47b22 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Thu, 12 Dec 2024 12:15:10 +0100 Subject: [PATCH] browse-url-with-browser-kind: Improve browser function selection In order to find an appropriate browser function for the given kind, first the browser handler lists are consulted. If no handler is found, the `browse-url-browser-function', `browse-url-secondary-browser-function`, `browse-url-default-browser' and `eww' are tried in that order until a browser function with a matching kind is found. This way the user customization of `browse-url-browser-function' and `browse-url-secondary-browser-function` is respected by `browse-url-with-browser-kind'. * lisp/net/browse-url.el (browse-url-with-browser-kind): Try the browser functions in the aforementioned order. --- lisp/net/browse-url.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 10165465921..e43f96c1fd5 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -976,7 +976,13 @@ browse-url-at-point ;;;###autoload (defun browse-url-with-browser-kind (kind url &optional arg) "Browse URL with a browser of the given browser KIND. -KIND is either `internal' or `external'. + +KIND is either `internal' or `external'. In order to find an +appropriate browser for the given KIND, first the `browse-url-handlers' +and `browse-url-default-handlers' lists are consulted. If no handler is +found, the functions `browse-url-browser-function', +`browse-url-secondary-browser-function', `browse-url-default-browser' +and `eww' are tried in that order. When called interactively, the default browser kind is the opposite of the browser kind of `browse-url-browser-function'." @@ -996,9 +1002,14 @@ browse-url-with-browser-kind (cons k url-arg))) (let ((function (browse-url-select-handler url kind))) (unless function - (setq function (if (eq kind 'external) - #'browse-url-default-browser - #'eww))) + (setq function + (seq-find + (lambda (fun) + (eq kind (browse-url--browser-kind fun url))) + (list browse-url-browser-function + browse-url-secondary-browser-function + #'browse-url-default-browser + #'eww)))) (funcall function url arg))) ;;;###autoload -- 2.45.2 --=-=-=--