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

Re: completion for "info -f" does not work



> On 16 March 2022 at 15:28 "Jun. T" <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> > 2022/03/17 0:06, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> > 
> >> On 16 March 2022 at 08:46 Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> >>> 2022/03/16 3:05, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> >>> 
> >>> +    if [[ $PREFIX = (./|../|/)* ]]; then
> >>> +      files=( $^infopath/*.info(|.gz|.bz2)(-.:t:s/.gz//:s/.bz2//:r) )
> >>> +      tags=(files)
> >>> +      items=()
> >>> +    else
> >> (snip)
> >>> +    _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)'
>
> I feel just '_files -g "*.info(|.gz|.bz2)"' is enough for 'info -f'.
> But if we want to combine it with files in infopath, we need to set
> tags=(files info-files), am I right?

Yes, something like the following might do it.

I can see info -f is a roundabout way of completing via the info path,
but it does work, so we might as well support it.

pws

diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo
index 7dfa32e45..39f8cd1b5 100644
--- a/Completion/Unix/Command/_texinfo
+++ b/Completion/Unix/Command/_texinfo
@@ -41,7 +41,7 @@ case $service in
       '(: -)'{-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' \
+      '(-f --file 1)'{-f+,--file=}'[specify Info manual to visit]:info manual:->infofiles+' \
       '(: - -h --help)'{-h,--help}'[display usage]' \
       '(-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 "*(-.)"' \
@@ -289,7 +289,11 @@ if [[ -n $state ]]; then
     items=( ${${${(M)${(f)"$(_call_program menu-items info -o-)"}:#(#s)\* *: \(*}#??}%%\)*} )
     files+=( ${items##*\(} )
     tags=( info-files )
-    if [[ $state != infofiles ]]; then
+    if [[ $state = infofiles+ ]]; then
+      # local files allowed
+      tags+=(files)
+    fi
+    if [[ $state != infofiles* ]]; then
       tags+=( menu-items )
       items=( ${items%:*} )
     fi
@@ -317,6 +321,7 @@ if [[ -n $state ]]; then
     _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
+    _requested files expl 'file' && _files -g '*.info(|.gz|.bz2)'
 
     (( ret )) || break
   done




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