all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, emacs-devel@gnu.org
Subject: Re: master ec9523a: Add a keybinding to the help menu to display manuals
Date: Thu, 15 Oct 2020 00:33:52 +0200	[thread overview]
Message-ID: <87k0vs4eun.fsf@rub.de> (raw)
In-Reply-To: <CADwFkmkhuju_JGQNh-iT9nyTL-0f-E7D7EhSRAAW3-Z34Y0nEw@mail.gmail.com> (Stefan Kangas's message of "Wed, 14 Oct 2020 12:06:48 -0700")

[-- Attachment #1: Type: text/plain, Size: 3090 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Info-read-node-name-2 patch --]
[-- Type: text/x-patch, Size: 1588 bytes --]

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	other threads:[~2020-10-14 22:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201013010930.20500.91773@vcs0.savannah.gnu.org>
     [not found] ` <20201013010931.ABE62209AA@vcs0.savannah.gnu.org>
2020-10-14 19:06   ` master ec9523a: Add a keybinding to the help menu to display manuals Stefan Kangas
2020-10-14 22:33     ` Stephen Berman [this message]
2020-10-15  1:57       ` Stefan Monnier
2020-10-15  7:00         ` Lars Ingebrigtsen
2020-10-15  7:34           ` Stephen Berman
2020-10-15  7:43           ` Eli Zaretskii
2020-10-15  9:00             ` Stephen Berman
2020-10-15 13:51       ` Eli Zaretskii
2020-10-16  4:08         ` Richard Stallman
2020-10-16  6:10           ` Eli Zaretskii
2020-10-18  4:10             ` Richard Stallman
2020-10-18 14:35               ` Eli Zaretskii
2020-10-19  3:48                 ` Richard Stallman
2020-10-16  4:57         ` Lars Ingebrigtsen
2020-10-15  6:55     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0vs4eun.fsf@rub.de \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.