From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mekeor Melire Newsgroups: gmane.emacs.bugs Subject: bug#68970: 30.0.50; Info.el: Info-url-alist should support format-sequence that encodes "Top" node as "index" Date: Wed, 07 Feb 2024 13:27:35 +0000 Message-ID: <87fry44bz6.fsf@posteo.de> 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="26791"; mail-complaints-to="usenet@ciao.gmane.io" To: 68970@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 07 14:55:09 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 1rXiOK-0006fj-4M for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Feb 2024 14:55:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXiO2-0005ni-SR; Wed, 07 Feb 2024 08:54:50 -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 1rXiO1-0005nX-2f for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:54:49 -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 1rXiO0-0004kv-QX for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:54:48 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXiOE-0003fk-5N for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mekeor Melire Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Feb 2024 13:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68970 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170731405014040 (code B ref -1); Wed, 07 Feb 2024 13:55:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Feb 2024 13:54:10 +0000 Original-Received: from localhost ([127.0.0.1]:55904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXiNN-0003eM-RO for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:54:10 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:49184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXiNL-0003e7-WD for submit@debbugs.gnu.org; Wed, 07 Feb 2024 08:54:08 -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 1rXiN2-0005jp-Hj for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:53:48 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXiMy-0004cv-LS for bug-gnu-emacs@gnu.org; Wed, 07 Feb 2024 08:53:48 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B1D02240028 for ; Wed, 7 Feb 2024 14:53:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1707314019; bh=8mWZRBFGF8z/JyGR1OhrNA+IlDhJPy7Tlovhr/YdT28=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Ek8N/XRM7TKiLu0nyVzfkMUDhyS1uvsIchESgclvWjJjUaYvisAIpCiyDw+89wFU8 0PIshFqwg5ZtsEkE9ctw86gRrqKyhnOnWSBY5iLDf4HtPd5FLq6XQ3NDoFkdJstp2a w8QiWaSFaoa99B0FT1VSlE2TQvAKDR/2MeXzCZTRMDAQwWiTtwDqGtzVKYVAzGfP31 FNP7uQFQaTc9v3ugA/A7t2NI8IJBekGRrkdPFIsCaO7rbIql+DlL8PgAwrfre1Z5qy bErmvT8ROy76rXHPmiljnzHgIe4u0cDyeMSUzgfIqccScaUz/U8va5JTGNVST0Blox HMCTL7EFocjsQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TVM5t5tzGz9rxS; Wed, 7 Feb 2024 14:53:38 +0100 (CET) Received-SPF: pass client-ip=185.67.36.65; envelope-from=mekeor@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:279550 Archived-At: --=-=-= Content-Type: text/plain After a discussion on emacs-devel[1] and a discussion on a bug-report[2], this was commited on the master-branch: 756daa93b3ef7ce33e741ab30000fa397fcd9783 Author: Mekeor Melire AuthorDate: Mon Dec 4 16:37:37 2023 +0100 Commit: Eli Zaretskii CommitDate: Sat Jan 27 12:18:17 2024 +0200 Add option Info-url-alist The new option Info-url-alist allow users to add custom mappings from manual-names to URLs. When the URL-SPEC is provided as string, users may use the %e format-sequence. But in the most common case, namely when URLs need to use a .html-suffix, this is not usable: In the case of the special "Top" node, the %e format-sequence resolves to "", i.e. the empty string. It is thus not possible to use a URL-SPEC like "https://example.com/%e.html" because "https://example.com/.html" is invalid. The user rather wants "https://example.com/index.html" in this case. Currently, the user needs to choose to use a function as URL-SPEC in this case. This works but is tedious, especially since this is the most common case. Thus, I suggest to provide another format-sequence to the URL-SPEC-string: %i. It will resolve the "Top" node as "index", thus allowing for "https://example.com/%i.html" to be used as URL-SPEC. Find attached a patch that does so, and also refills the doc-string. [1] https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg01286.html [2] https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-12/msg00156.html --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Provide-format-sequence-i-in-Info-url-for-node.patch >From 03752ac8f3b2c86dd81da21db4fb5981461af3e5 Mon Sep 17 00:00:00 2001 From: Mekeor Melire Date: Wed, 7 Feb 2024 14:47:07 +0100 Subject: [PATCH] Provide format-sequence %i in Info-url-for-node * lisp/info.el (Info-url-for-node): Provide format-sequence %i which resolves "Top" node as "index". (Info-url-alist): Explain it in refilled docstring. --- lisp/info.el | 76 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/lisp/info.el b/lisp/info.el index e91cc7b8e54..7c58879e545 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -227,28 +227,35 @@ Info-url-alist "https://www.gnu.org/software/emacs/manual/html_node/%m/%e")) "Alist telling `Info-mode' where manuals are accessible online. -Each element of this list has the form (MANUALs . URL-SPEC). -MANUALs represents the name of one or more manuals. It can -either be a string or a list of strings. URL-SPEC can be a -string in which the substring \"%m\" will be expanded to the -manual-name, \"%n\" to the node-name, and \"%e\" to the -URL-encoded node-name (without a `.html' suffix). (The -URL-encoding of the node-name mimics GNU Texinfo, as documented -at Info node `(texinfo)HTML Xref Node Name Expansion'.) -Alternatively, URL-SPEC can be a function which is given -manual-name, node-name and URL-encoded node-name as arguments, -and is expected to return the corresponding URL as a string. +Each element of this list has the form (MANUALs . URL-SPEC). MANUALs +represents the name of one or more manuals. It can either be a string +or a list of strings. URL-SPEC can be a string in which the format +sequences explained below can be used. Alternatively, it can be a +function which is given arguments corresponding to the format sequences +below and is expected to return the corresponding URL as a string. + +`%m' represents the manual-name. + +`%n' represents the (raw) node-name. + +`%e' represents a URL-encoded node-name. (The encoding mimics GNU + Texinfo, as documented at Info node `(texinfo)HTML Xref Node Name + Expansion'.) It does not include any suffix like `.html'. In case + of the `Top' node, it is the empty string. + +`%i' represents a URL-encoded node-name, which in case of the `Top' + node, is the string \"index\". This variable particularly affects the command `Info-goto-node-web', which see. The default value of this variable refers to the official, HTTPS-accessible HTML-representations of all manuals that Emacs -includes. These URLs refer to the most recently released version -of Emacs, disregarding the version of the running Emacs. In -other words, the content of your local Info node and the -associated online node may differ. The resource represented by -the generated URL may even be not found by the gnu.org server." +includes. These URLs refer to the most recently released version of +Emacs, disregarding the version of the running Emacs. In other words, +the content of your local Info node and the associated online node may +differ. The resource represented by the generated URL may even be not +found by the gnu.org server." :version "30.1" :type '(alist :tag "Mapping from manual-name(s) to URL-specification" @@ -1922,26 +1929,31 @@ Info-url-for-node (encoded-node ;; Reproduce GNU Texinfo's way of URL-encoding. ;; (info "(texinfo) HTML Xref Node Name Expansion") - (if (equal node "Top") - "" - (url-hexify-string - (string-replace " " "-" - (mapconcat - (lambda (ch) - (if (or (< ch 32) ; ^@^A-^Z^[^\^]^^^- - (<= 33 ch 47) ; !"#$%&'()*+,-./ - (<= 58 ch 64) ; :;<=>?@ - (<= 91 ch 96) ; [\]_` - (<= 123 ch 127)) ; {|}~ DEL - (format "_00%x" ch) - (char-to-string ch))) - node "")))))) + (url-hexify-string + (string-replace " " "-" + (mapconcat + (lambda (ch) + (if (or (< ch 32) ; ^@^A-^Z^[^\^]^^^- + (<= 33 ch 47) ; !"#$%&'()*+,-./ + (<= 58 ch 64) ; :;<=>?@ + (<= 91 ch 96) ; [\]_` + (<= 123 ch 127)) ; {|}~ DEL + (format "_00%x" ch) + (char-to-string ch))) + node "")))) + (top-as-empty-node + (if (string= node "Top") "" encoded-node)) + (top-as-index-node + (if (string= node "Top") "index" encoded-node))) (cond ((stringp url-spec) (format-spec url-spec - `((?m . ,manual) (?n . ,node) (?e . ,encoded-node)))) + `((?m . ,manual) (?n . ,node) + (?e . ,top-as-empty-node) + (?i . ,top-as-index-node)))) ((functionp url-spec) - (funcall url-spec manual node encoded-node)) + (funcall url-spec manual node + top-as-empty-node top-as-index-node)) (t (error "URL-specification neither string nor function"))) (error "No URL-specification associated with manual-name `%s'" manual))) -- 2.41.0 --=-=-=--