1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-10 00:31:07 +02:00

16913: fix completion after compdef -a and correct typos

This commit is contained in:
Oliver Kiddle 2002-03-27 16:10:07 +00:00
parent 1f14da726e
commit ac88d2bbef
3 changed files with 20 additions and 17 deletions

View file

@ -1,5 +1,8 @@
2002-03-27 Oliver Kiddle <opk@zsh.org> 2002-03-27 Oliver Kiddle <opk@zsh.org>
* 16913: Completion/Zsh/Command/_compdef, Doc/Zsh/compsys.yo:
fix completion after compdef -a and correct typos
* John Beppu: 16866 (tweaked): Completion/Unix/Command/_figlet: * John Beppu: 16866 (tweaked): Completion/Unix/Command/_figlet:
new completion for figlet new completion for figlet

View file

@ -13,7 +13,7 @@ if (( ! ${words[2,-1][(I)[^-]*]} || ${words[(I)-[kK]]} )); then
) )
args2=( args2=(
- d - d
'(-a -n)-d[delete]:*:completed command:->ccom' '-d[delete]:*:completed command:->ccom'
- k - k
'-k[define widget and key binding]:completion function:->cfun:style:->style:*:key' '-k[define widget and key binding]:completion function:->cfun:style:->style:*:key'
- K - K
@ -21,14 +21,15 @@ if (( ! ${words[2,-1][(I)[^-]*]} || ${words[(I)-[kK]]} )); then
) )
else else
args1=( args1=(
'-N[completion for named command]' '!-a' '!-n'
'*-N[completion for named command]'
) )
fi fi
_arguments -C -s -S \ _arguments -C -s -S \
"$args1[@]" \ "$args1[@]" \
'-p[completion for command matching pattern]' \ '*-p[completion for command matching pattern]' \
'-P[completion for command matching pattern]' \ '*-P[completion for command matching pattern]' \
':completion function:->cfun' \ ':completion function:->cfun' \
'*:commands:->com' \ '*:commands:->com' \
"$args2[@]" && return 0 "$args2[@]" && return 0

View file

@ -272,25 +272,24 @@ with the tt(#compdef) tag and an argument of the form
`var(cmd)tt(=)var(service)'. This kind of use makes the arguments of `var(cmd)tt(=)var(service)'. This kind of use makes the arguments of
the var(cmd)s be completed as those for the var(services). the var(cmd)s be completed as those for the var(services).
In the first case and the following cases the var(function) may actually The var(function) may actually be a string containing any shell code
be a string containing any shell code and that string will be executed and that string will be executed via the tt(eval) builtin command.
via the tt(eval) builtin command. This allows to easily define completions This allows to easily define completions for commands that need to call
for commands that need to call one of the completion functions with one of the completion functions with arguments. For example to make
arguments. For example to make files ending in `tt(.h)' be completed as files ending in `tt(.h)' be completed as arguments to the command
arguments to the command tt(foo), one would use: tt(foo), one would use:
example(compdef '_files -g "*.h"' foo) example(compdef '_files -g "*.h"' foo)
If the If the tt(-n) option is given, any existing completion behaviour for
tt(-n) option is given, any existing completion behaviour for particular particular contexts or commands will not be altered. These definitions
contexts or commands will not be altered. These definitions can be deleted can be deleted by giving the tt(-d) option as in the second form.
by giving the tt(-d) option as in the second form.
In both of the first two cases forms and as for the tt(#compdef) tag In both of the first two forms and as for the tt(#compdef) tag
described above, the var(names) may also contain tt(-p), tt(-P) and described above, the var(names) may also contain tt(-p), tt(-P) and
tt(-N) options. The first two make the following arguments be used as tt(-N) options. The first two make the following arguments be used as
patterns and the var(function) will be called for all commands and patterns and the var(function) will be called for all commands and
contexts matching one of the patterns. Wtih tt(-P) this will only contexts matching one of the patterns. With tt(-P) this will only
happen if no specific function is defined for the command or context. happen if no specific function is defined for the command or context.
The tt(-N) option toggles back to using the var(names) as described The tt(-N) option toggles back to using the var(names) as described
above. above.
@ -335,7 +334,7 @@ do:
example(compdef _pids foo) example(compdef _pids foo)
using the tt(_pids) function from the distribution to generate the using the tt(_pids) function from the distribution to generate the
process identifiers. Not also the tt(_gnu_generic) function described process identifiers. Note also the tt(_gnu_generic) function described
below, which can be used to complete options for commands that below, which can be used to complete options for commands that
understand the `tt(-)tt(-help)' option. understand the `tt(-)tt(-help)' option.