From 9c14983767905260fb5a57543adc4c446e26cb92 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 20 Dec 2022 02:49:54 +0100 Subject: [PATCH 1/2] Make Info-url-for-node support more manuals * lisp/info.el (info--url-for-node-manuals-built-in) (info-url-for-node-manuals): New variables. (Info-url-for-node): Support all built-in manuals, and add support for external manuals. --- lisp/info.el | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/lisp/info.el b/lisp/info.el index 05ad27e180..f939c42874 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -1793,16 +1793,43 @@ Info-goto-node-web Info-current-file)) node)))) +(defvar info--url-for-node-manuals-built-in + ;; All manuals are at https://www.gnu.org/software/emacs/manual/ + '("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" "faq" "flymake" "forms" "gnus" + "htmlfontify" "idlwave" "ido" "info" "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" "widget" + "wisent" "woman") + "List of built-in manual names (strings) supported by `Info-url-for-node'.") + +(defvar info-url-for-node-manuals () + "Alist of manuals for `Info-url-for-node'. +Each entry has the form (NAME . URL) where NAME is the Info +manual name, and URL is the canonical URL of the manual. +The URL should not end in \"/\".") + (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, a node in the current manual. +NODE should be a string on the form \"(manual)Node\". + +All built-in manuals are supported by default, but additional +manuals can be added to the variable `info-url-for-node-manuals'." (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")) + (let* ((manual (match-string 1 node)) + (node (match-string 2 node)) + (base-url + (or (assoc manual info-url-for-node-manuals) + (and (member manual info--url-for-node-manuals-built-in) + "https://www.gnu.org/software/emacs/manual/html_node") + (error "Manual not supported: %s" manual)))) + (when (equal node "Top") + (setq node "index")) ;; Encode a bunch of characters the way that makeinfo does. (setq node (mapconcat (lambda (ch) @@ -1815,8 +1842,7 @@ Info-url-for-node (char-to-string ch))) node "")) - (concat "https://www.gnu.org/software/emacs/manual/html_node/" - manual "/" + (concat base-url "/" manual "/" (url-hexify-string (string-replace " " "-" node)) ".html"))) -- 2.35.1