emacs-devel
[Top][All Lists]
Advanced

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

Re: master ec9523a: Add a keybinding to the help menu to display manuals


From: Stephen Berman
Subject: Re: master ec9523a: Add a keybinding to the help menu to display manuals
Date: Thu, 15 Oct 2020 00:33:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Wed, 14 Oct 2020 12:06:48 -0700 Stefan Kangas <stefankangas@gmail.com> wrote:

> larsi@gnus.org (Lars Ingebrigtsen) writes:
>
>> +*** New keybinding in 'help-for-help' to display a manual.
>> +The 'R' keybinding after 'C-h C-h' will prompt for a manual name and
>> +then display it.
>
> Shouldn't this NEWS entry rather say something like:
>
> * New keybinding 'C-h R' prompts for a manual display and displays it.
>
> Testing the command, the completion is a bit unsatisfactory.  It doesn't
> seem to prompt for a manual name, but a file name?  Or maybe it allows
> both?  I see all of "gnus", "gnus.info" and "gnus.info.gz" in the
> completion list, yet they all seem to lead to the same manual.  I also
> see ".", ".." and a directory "emacs/".
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

These last three are due to this bit in Info-read-node-name-2:

          ;; If the file name has no suffix or a standard suffix,
          ;; include it.
          (and (or (null (file-name-extension file))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   (string-match suffix file))

And it's even worse if Info-directory-list includes directories that
contain lots of extensionless files that aren't info files, such as, for
example, the AUCTeX package from GNU ELPA, which contains such files as
ChangeLog, COPYING, GNUmakefile, etc., all of which are listed in the
*Completions* buffer, and if you choose one of them, it gets visited in
Info mode, which throws the user-error: "No such node or anchor: Top".

An odd thing about Info-read-node-name-2 is that it explicitly removes
the empty string from Info-suffix-list but then in effect adds it back
by checking for extensionless files in the above code.  I checked the
info files installed on my system and all of them end in ".info" or
"info.gz" (in some cases followed by a dash and a number, indicating
split info subfiles, see below).  And also in the Emacs source all info
files under info/ end in ".info".  Are there known cases of
extensionless info files that do not correspond to a file ending in
".info" or ".info.gz" (or another compression suffix)?  If not, then
removing that bit of the code will prevent the current false positives.

In addition, Info-read-node-name-2 excludes subfiles of split info files
only where these are extensionless files ending in the regexp "-[0-9]+",
but this misses files which have the number before a compression
extension, of which my system has several, e.g. R-exts.info-3.gz.
However, in all cases on my system, split info files contain "info"
before "-[0-9]+", and if that's always the case, then the patch below
will make tab completion on info-display-manual (i.e. `C-h R') show all
info files without shwoing the .info extension and also excluding
numbered subfiles and false positives.  Granted this is still not the
manual name as shown in the top level Info directory but only the
extensionless file name, e.g. "eintr" instead of "Emacs Lisp Intro", but
at least it seems better than the status quo (if the assumption that all
info files include the ".info" extension is correct).

Steve Berman

diff --git a/lisp/info.el b/lisp/info.el
index 6dffb3993c..fb0de4d598 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1830,21 +1830,16 @@ Info-read-node-name-2
       (when (file-directory-p dir)
        (dolist (file (file-name-all-completions
                       (file-name-nondirectory string) dir))
-         ;; If the file name has no suffix or a standard suffix,
-         ;; include it.
-         (and (or (null (file-name-extension file))
-                  (string-match suffix file))
-              ;; But exclude subfiles of split Info files.
-              (not (string-match "-[0-9]+\\'" file))
+         ;; Check if the file name has a standard suffix.
+         (and (string-match suffix file)
+              ;; Exclude subfiles of split Info files.
+              (not (string-match "info-[0-9]+\\(\\..*\\)?\\'" file))
               ;; And exclude backup files.
               (not (string-match "~\\'" file))
-              (push (if string-dir (concat string-dir file) file) names))
-         ;; If the file name ends in a standard suffix,
-         ;; add the unsuffixed name as a completion option.
-         (when (string-match suffix file)
-           (setq file (substring file 0 (match-beginning 0)))
-           (push (if string-dir (concat string-dir file) file)
-                 names-sans-suffix)))))
+              ;; Use the unsuffixed name as a completion option.
+              (let ((file (substring file 0 (match-beginning 0))))
+                (push (if string-dir (concat string-dir file) file)
+                      names-sans-suffix))))))
     ;; If there is just one file, don't duplicate it with suffixes,
     ;; so `Info-read-node-name-1' will be able to complete a single
     ;; candidate and to add the terminating ")".

reply via email to

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