Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: info completion doesn't offer index entries any longer



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




Messages sorted by: Reverse Date, Date, Thread, Author