emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67615: closed ([PATCH] * lisp/info.el (Info-url-for-node): Support a


From: GNU bug Tracking System
Subject: bug#67615: closed ([PATCH] * lisp/info.el (Info-url-for-node): Support all Emacs info manuals.)
Date: Sat, 27 Jan 2024 10:22:01 +0000

Your message dated Sat, 27 Jan 2024 12:21:28 +0200
with message-id <86le8b84bb.fsf@gnu.org>
and subject line Re: [PATCH v7] Add option Info-url-alist
has caused the debbugs.gnu.org bug report #67615,
regarding [PATCH] * lisp/info.el (Info-url-for-node): Support all Emacs info 
manuals.
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
67615: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67615
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] * lisp/info.el (Info-url-for-node): Support all Emacs info manuals. Date: Mon, 04 Dec 2023 00:04:47 +0000
This is my first patch to Emacs. I probably made some mistakes regarding the 
many conventions. I tried my best, including regarding the code formatting. 
Also, I hope that my mail client is configured well and formats the patch well. 
Last but not least, note that my FSF-copyright-assignment is still ongoing.
---
ChangeLog.4  |   7 ++++
etc/NEWS     |   8 ++++
lisp/info.el | 101 ++++++++++++++++++++++++++++++++++++++-------------
3 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/ChangeLog.4 b/ChangeLog.4
index 24afabdbbb1..6e54264a32b 100644
--- a/ChangeLog.4
+++ b/ChangeLog.4
@@ -1,3 +1,10 @@
+2023-12-03  Mekeor Melire  <mekeor@posteo.de>
+
+       Support online-browsing all Emacs-contained manuals.
+
+ * lisp/info.el (Info-urls): New defcustom that maps manual-names
+       to URL-specifications.
+
2023-10-16  Po Lu  <luangruo@yahoo.com>

        Correctly register focus events concomitant with alpha changes
diff --git a/etc/NEWS b/etc/NEWS
index 29f4e5c0b66..6b5928bd74e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -356,6 +356,14 @@ respectively, in addition to the existing translations 'C-x 8 / e' and

* Changes in Specialized Modes and Packages in Emacs 30.1

+** Info
+
+---
+*** New user option 'Info-urls'.
+Browse any online info manual, not just the 'emacs' and 'elisp'
+manuals. By default, allow browsing online info manuals of all
+Emacs-contained manuals.
+
+++
** New command 'lldb'.
Run the LLDB debugger, analogous to the 'gud-gdb' command. Note that
diff --git a/lisp/info.el b/lisp/info.el
index 51e9eb72edf..0e16ee7340c 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -213,6 +213,45 @@ Info-additional-directory-list
These directories are searched after those in `Info-directory-list'."
  :type '(repeat directory))

+(defcustom Info-urls
+ '((("auth" "autotype" "bovine" "calc" "ccmode" "cl" "dbus" "dired-x" + "ebrowse" "ede" "ediff" "edt" "efaq" "efaq-w32" "eglot" "eieio" + "eintr" "elisp" "emacs" "emacs-gnutls" "emacs-mime" "epa" "erc" + "ert" "eshell" "eudc" "eww" "flymake" "forms" "gawk" "gnus"
+       "htmlfontify" "idlwave" "ido" "info" "mairix" "mairix-el"
+       "message" "mh-e" "modus-themes" "newsticker" "nxml-mode"
+ "octave-mode" "org" "pcl-cvs" "pgg" "rcirc" "reftex" "remember"
+       "sasl" "sc" "semantic" "ses" "sieve" "smtpmail" "speedbar"
+ "srecode" "todo-mode" "tramp" "transient" "url" "use-package" + "vhdl-mode" "vip" "viper" "vtable" "widget" "wisent" "woman") . + "https://www.gnu.org/software/emacs/manual/html_node/%m/%n.html";))
+  "Alist telling `Info-mode' where manuals are accessible online.
+
+Each element of this list should match the pattern (MANUALS
+. URL-SPEC).  MANUALS represents the name of one or many
+manuals. It should either be a string or a list of
+strings. URL-SPEC should be a string in which the substring
+\"%m\" will be expanded to the manual-name, and \"%n\" to the
+URL-encoded node-name. This URL-encoding of the node-name matches
+Texinfo's HTML cross-reference node name
+expansion. Alternatively, URL-SPEC can be the symbol of a
+function receiving the manual-name, the node-name and the
+URL-encoded node-name as arguments, returning a URL as string.
+
+The default value of this variable refers to the HTTP-accessible
+HTML-manuals of all manuals that Emacs includes. Specifically,
+the URL refers to the latest version of Emacs, disregarding the
+locally installed version."
+  :type '(alist
+ :tag "Mapping from manual-name(s) to URL-specification"
+           :key-type (choice
+                       (string :tag "A single manual-name")
+ (repeat :tag "List of manual-names" string))
+           :value-type (choice
+                         (string :tag "URL-specification string")
+                         (function-item
+                           :tag "URL-specification function"))))
+
(defcustom Info-scroll-prefer-subnodes nil
"If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.

@@ -1807,33 +1846,43 @@ Info-goto-node-web
     (Info-url-for-node (format "(%s)%s" filename node)))))

(defun Info-url-for-node (node)
- "Return a URL for NODE, a node in the GNU Emacs or Elisp manual.
-NODE should be a string on the form \"(manual)Node\".  Only emacs
-and elisp manuals are supported."
+  "Return a URL for NODE. NODE should be a string of the form
+\"(manual)Node\"."
  (unless (string-match "\\`(\\(.+\\))\\(.+\\)\\'" node)
-    (error "Invalid node name %s" node))
-  (let ((manual (match-string 1 node))
-        (node (match-string 2 node)))
-    (unless (member manual '("emacs" "elisp"))
-      (error "Only emacs/elisp manuals are supported"))
-    ;; Encode a bunch of characters the way that makeinfo does.
-    (setq node
-          (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
-                     ""))
- (concat "https://www.gnu.org/software/emacs/manual/html_node/";
-            manual "/"
-            (and (not (equal node "Top"))
-                 (concat
- (url-hexify-string (string-replace " " "-" node))
-                  ".html")))))
+    (error "Invalid node-name %s" node))
+  (if-let* ((manual (match-string 1 node))
+             (node (match-string 2 node))
+             (matched-pair (seq-find
+                             (lambda (pair)
+ (seq-contains (ensure-list (car pair)) + manual #'string-equal-ignore-case))
+                             Info-urls)))
+    (if-let* ((encoded-node
+                ;; Reproduce GNU Texinfo's way of URL-encoding.
+ ;; (info "(texinfo) HTML Xref Node Name Expansion")
+                (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-spec (cdr matched-pair))
+               (url-spec (cond
+                           ((functionp url-spec)
+                             (funcall url-spec
+                               manual node encoded-node))
+                           ((stringp url-spec) url-spec))))
+ (format-spec url-spec `((?m . ,manual) (?n . ,encoded-node))) + (error "`Info-urls' associates an invalid URL-specification with manual-name \"%s\"."
+        manual))
+ (error "`Info-urls' does not associate any URL-specification with manual-name \"%s\"."
+      manual)))

(defvar Info-read-node-completion-table)

--
2.41.0



--- End Message ---
--- Begin Message --- Subject: Re: [PATCH v7] Add option Info-url-alist Date: Sat, 27 Jan 2024 12:21:28 +0200
> From: Mekeor Melire <mekeor@posteo.de>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Sun, 21 Jan 2024 01:43:04 +0000
> 
> 2024-01-20 09:23 eliz@gnu.org:
> 
> > What about the case where the HTML docs are produced with one file per
> > node? doesn't Texinfo create in that case directories that are named
> > like the manual, but without the .html extension?
> 
> I tested this and found out that Texinfo does not create directories for
> each node in that case.
> 
> The reason why after omitting the .html-suffix gnu.org still serves the
> html-manual is its web-server configuration. This was confirmed to me
> via IRC in the #gnu channel on libera.chat server.
> 
> Attached is a new version of that patch with following changes:
> 
> - Let Info-url-for-node skip whitespace and newlines between closing
>   parenthesis and node-name. This mimics Texinfo as can be traced here:
> 
>   
> https://git.savannah.gnu.org/cgit/texinfo.git/tree/info/info.h?h=114e10b2a1cb5ee07ae6b9d1228d6d016c9f86e6#n44
>   
> https://git.savannah.gnu.org/cgit/texinfo.git/tree/info/scan.c?h=114e10b2a1cb5ee07ae6b9d1228d6d016c9f86e6#n123
> 
>   It also makes Info-url-for-node work with the string that is put into
>   kill-ring with the Info-copy-current-node-name command which uses a
>   whitespace.
> 
> - Do not use a .html suffix, neither in the default value for the new
>   Info-url-alist, nor in the %e format-thing that can be in user-defined
>   values of it. Users still can add a ".html" suffix themselves, if the
>   respective web-server does not support omitting it.
> 
> - More tests, including manuals in all relevant directories and formats
>   and "special" characters.

Thanks, installed on the master branch, and closing the bug.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]