Subject: bug#13365: 24.3.50; info node name completion busted

From: Juri Linkov <[email-masked]>
Date: Sun, 06 Jan 2013 00:39:49 +0200

> Following is something I have done going back to emacs 18; launch
> emacs, start info brower via C-h i, then type "g" to call
> Info-goto-node, type "(emacs)" followed by RETURN.
>
> Above no longer works.  Why?

Thanks for the report.  This change was a result of the discussion
in http://debbugs.gnu.org/12456

> I think this should be changed so that node names such as "(emacs)" is
> allowed and interpreted same as if it was "(emacs)Top" as emacs has
> done for over 25 years.

I agree there is no reason to not allow empty node names to be
interpreted as "Top", despite the fact that this feature is not
documented anywhere and has been available for years by mere chance
(note the phrase "any node is fair game" in the old comment).

This could be improved by the patch below that will also legitimate
this feature in the docstring of `Info-read-node-name' and in the
Info reader manual.

BTW, do you think that `g RET' (without specifying a filename)
should also go to the Top node of the current Info file?
Currently it just recursively repeats the same query
that is not quite standard behavior for the minibuffer.

=== modified file 'lisp/info.el'
--- lisp/info.el	2013-01-03 00:36:36 +0000
+++ lisp/info.el	2013-01-05 22:39:39 +0000
@@ -1712,7 +1712,9 @@ (defun Info-goto-node (nodename &optiona
 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
 its sub-files).
-Completion is available, but only for node names in the current Info file.
+Completion is available for node names in the current Info file as well as
+in the Info file FILENAME after the closing parenthesis in (FILENAME).
+Empty NODENAME in (FILENAME) defaults to the node `Top'.
 If FORK is non-nil (interactively with a prefix arg), show the node in
 a new Info buffer.
 If FORK is a string, it is the name to use for the new buffer."
@@ -1802,6 +1804,9 @@ (defun Info-read-node-name-1 (string pre
     (let ((file0 (match-string 0 string))
 	  (file1 (match-string 1 string))
 	  (node (substring string (match-end 0))))
+      (if (and (equal node "") (eq code 'lambda))
+	  ;; Empty node name is permitted that means "Top".
+	  t
       (completion-table-with-context
        file0
        (apply-partially
@@ -1810,7 +1815,7 @@ (defun Info-read-node-name-1 (string pre
 	   action
 	   (Info-build-node-completions (Info-find-file file1))
 	   string pred)))
-       node predicate code)))
+	 node predicate code))))
    ;; Otherwise use Info-read-node-completion-table.
    (t (complete-with-action
        code Info-read-node-completion-table string predicate))))
@@ -1819,7 +1824,9 @@ (defun Info-read-node-name-1 (string pre
 (defun Info-read-node-name (prompt)
   "Read an Info node name with completion, prompting with PROMPT.
 A node name can have the form \"NODENAME\", referring to a node
-in the current Info file, or \"(FILENAME)NODENAME\"."
+in the current Info file, or \"(FILENAME)NODENAME\", referring to
+a node in FILENAME.  \"(FILENAME)\" is a short format to go to the
+node `Top' in FILENAME."
   (let* ((completion-ignore-case t)
 	 (Info-read-node-completion-table (Info-build-node-completions))
 	 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))

=== modified file 'doc/misc/info.texi'
--- doc/misc/info.texi	2013-01-01 09:11:05 +0000
+++ doc/misc/info.texi	2013-01-05 22:39:36 +0000
@@ -1079,7 +1079,8 @@ (@pxref{Emacs Info Variables}).
 node name by putting it at the front, in parentheses.  Thus,
 @kbd{g(dir)Top@key{RET}} would go to the Info Directory node, which is
 the node @samp{Top} in the Info file @file{dir}.  Likewise,
-@kbd{g(emacs)Top@key{RET}} goes to the top node of the Emacs manual.
+@kbd{g(emacs)Top@key{RET}} or just @kbd{g(emacs)@key{RET}} goes to the
+top node of the Emacs manual.
 
   The node name @samp{*} specifies the whole file.  So you can look at
 all of the current file by typing @kbd{g*@key{RET}} or all of any