zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: info completion doesn't offer index entries any longer
Date: Mon, 09 Aug 2021 15:36:58 +0200	[thread overview]
Message-ID: <24095-1628516218.744330@eGij.Ns0X.qUzs> (raw)
In-Reply-To: <20210808155804.v7di4mpoyyis7h4k@chazelas.org>

Stephane Chazelas wrote:
> > There is no actual attempt to complete anything for --index-search=
> > What do you think we should do there?
>
> Well, I was hoping zsh would give me similar completion as
> info's i would.
 ...
> Doing the same as i's completion may require parsing the contents of the info
> file directly.

We may be able to use the search for an empty string approach again,
e.g. info -o- --all --index-search='' zsh

The patch below tries that. You need to specify the manual first before
--index-search but for 'read' in the zsh manual I get a similar list to
the i command in info.

We could perhaps drop the info -k '' method in favour of this - would
need to compare results for a variety of info pages. In the patch here,
I've made it include in the part to the right of " -- " too so it is
generating more matches including the "info zsh read" case we started
with.

> What I mean is that I'd expect info -k '' would only need to be
> run once within a single interactive zsh session. When I
> instrument it with
>
> info() { echo info called>/dev/tty; command info "$@";}
>
> I can see info being called each time I complete info zsh something<Tab> for
> instance.

In my testing, it is running info -o- zsh each time but not the much
slower info -k ''
If you include "$@" in your instrumentation function are you able to
confirm that?
This is because both menu and index items are allowed.

Oliver

diff --git Completion/Unix/Command/_texinfo Completion/Unix/Command/_texinfo
index 2122a70ad..526a595a8 100644
--- Completion/Unix/Command/_texinfo
+++ Completion/Unix/Command/_texinfo
@@ -37,14 +37,14 @@ local -A opt_args infodirs
 case $service in
   info)
     cmd=${words[1]}
-    _arguments -C -s \
+    _arguments -C -s -S \
       '(-a --all)'{-a,--all}'[use all matching manuals]' \
       '(: -)'{-k+,--apropos=}'[look up string in indices]:search string: ' \
       \*{-d+,--directory=}'[add directory to infopath]:info dir:_files -/' \
       '--dribble=[record keystrokes]:file with keystrokes:_files' \
       '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles' \
       '(: - -h --help)'{-h,--help}'[display usage]' \
-      '(-o --output -O)--index-search=[go directly to node if found]:search string: ' \
+      '(-o --output -O)--index-search=[search for matching index entry]:search string:->index-entries' \
       '(--index-search -o --output -O)'{-o+,--output=}'[dump selected nodes to filename]:filename:_files -g "*(-.)"' \
       '--init-file=[specify initialisation file]:file:_files' \
       '(-n --node)'{-n+,--node=}'[specify nodes in first visited Info file]:node:->nodes' \
@@ -302,6 +302,13 @@ if [[ -n $state ]]; then
       tags+=( info-nodes )
     fi
     items=( ${${${(M)${(f)"$(_call_program menu-items info -o- $file)"}:#(#s)\* *::*}%%::*}#??} )
+  elif [[ $state = index-entries ]]; then
+    if [[ -n $file ]]; then
+      tags=( index-entries )
+      items=( ${${${(M)${(f)"$(_call_program index-entries info -o- --all --index-search= $file)"}:#(#s)\* *:*}%%:*}#??} )
+    else
+      _message -e index-entries $state_descr
+    fi
   fi
 
   _tags $tags
@@ -309,6 +316,7 @@ if [[ -n $state ]]; then
   while _tags; do
     _requested info-files expl 'info file' compadd $suf -M 'm:{a-zA-Z}={A-Za-z}' -a files && ret=0
     _requested menu-items expl 'menu item' compadd -M 'm:{a-zA-Z}={A-Za-z}' -a items && ret=0
+    _requested -x index-entries expl 'index entry' compadd -M 'm:{a-zA-Z}={A-Za-z}' -a items && ret=0
     _requested info-nodes expl 'node' compadd -M 'm:{a-zA-Z}={A-Za-z}' ${nodes#*:} && ret=0
 
     (( ret )) || break


      reply	other threads:[~2021-08-09 13:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 16:05 Stephane Chazelas
2021-08-01 16:24 ` Stephane Chazelas
2021-08-05  7:53   ` Oliver Kiddle
2021-08-08 15:58     ` Stephane Chazelas
2021-08-09 13:36       ` Oliver Kiddle [this message]

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=24095-1628516218.744330@eGij.Ns0X.qUzs \
    --to=opk@zsh.org \
    --cc=zsh-workers@zsh.org \
    /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 public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).