emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 546a68925c9: Fix 'Info-goto-node-web' when NODE is given in var


From: Eli Zaretskii
Subject: emacs-29 546a68925c9: Fix 'Info-goto-node-web' when NODE is given in various forms
Date: Sat, 2 Dec 2023 08:26:38 -0500 (EST)

branch: emacs-29
commit 546a68925c90829d6977b7e4649e7fc0ed20d9f7
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix 'Info-goto-node-web' when NODE is given in various forms
    
    * lisp/info.el (Info-goto-node-web): Support all forms of node
    input, per 'Info-read-node-name's documentation, and extract
    FILENAME from NODE if given there.  Default NODE to "Top" if not
    provided by the user.  (Bug#67531)
    (Info-url-for-node): Support browsing the "Top" node.
---
 lisp/info.el | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/lisp/info.el b/lisp/info.el
index 035dff66e75..d5ce3bc2ab3 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1787,11 +1787,24 @@ By default, go to the current Info node."
   (interactive (list (Info-read-node-name
                       "Go to node (default current page): " Info-current-node))
                Info-mode)
-  (browse-url-button-open-url
-   (Info-url-for-node (format "(%s)%s" (file-name-sans-extension
-                                        (file-name-nondirectory
-                                         Info-current-file))
-                              node))))
+  (let (filename)
+    (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
+                 node)
+    (setq filename (if (= (match-beginning 1) (match-end 1))
+                      ""
+                    (match-string 2 node))
+         node (match-string 3 node))
+    (let ((trim (string-match "\\s +\\'" filename)))
+      (if trim (setq filename (substring filename 0 trim))))
+    (let ((trim (string-match "\\s +\\'" node)))
+      (if trim (setq node (substring node 0 trim))))
+    (if (equal filename "")
+        (setq filename (file-name-sans-extension (file-name-nondirectory
+                                                  Info-current-file))))
+    (if (equal node "")
+        (setq node "Top"))
+    (browse-url-button-open-url
+     (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.
@@ -1817,8 +1830,10 @@ and elisp manuals are supported."
                      ""))
     (concat "https://www.gnu.org/software/emacs/manual/html_node/";
             manual "/"
-            (url-hexify-string (string-replace " " "-" node))
-            ".html")))
+            (and (not (equal node "Top"))
+                 (concat
+                  (url-hexify-string (string-replace " " "-" node))
+                  ".html")))))
 
 (defvar Info-read-node-completion-table)
 



reply via email to

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