1999-09-22 14:35:29 +02:00
|
|
|
#compdef compdef
|
|
|
|
|
2000-05-05 15:38:45 +02:00
|
|
|
local state line expl list disp curcontext="$curcontext"
|
|
|
|
typeset -A opt_args
|
1999-09-22 14:35:29 +02:00
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
_arguments -C -s \
|
|
|
|
'(-d)-a[make function autoloadable]' \
|
|
|
|
'(-d -p -P)-n[leave existing definitions intact]' \
|
2000-04-25 11:48:08 +02:00
|
|
|
':completion function:->cfun' \
|
2000-05-25 17:09:04 +02:00
|
|
|
'*:commands: _command_names' \
|
|
|
|
- d \
|
|
|
|
'(-a -n)-d[delete]:*:completed command:->ccom' \
|
|
|
|
- p \
|
|
|
|
'(-n)-p[completion for command matching pattern]:completion function:->cfun:pattern' \
|
|
|
|
- P \
|
|
|
|
'(-n)-P[as -p for commands without own completion]:completion function:->cfun:pattern' \
|
|
|
|
- k \
|
|
|
|
'-k[define widget and key binding]:completion function:->cfun:style:->style:*:key' \
|
|
|
|
- K \
|
|
|
|
'-K[define multiple widgets based on function]:*::: :->multi' && return 0
|
2000-04-25 11:48:08 +02:00
|
|
|
|
|
|
|
if [[ $state = multi ]]; then
|
|
|
|
case $(( CURRENT % 3 )) in
|
|
|
|
0) _message key
|
|
|
|
return 1;;
|
|
|
|
1) state=cfun;;
|
|
|
|
2) state=style;;
|
|
|
|
esac
|
|
|
|
fi
|
1999-09-22 14:35:29 +02:00
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
case $state in
|
|
|
|
ccom)
|
2000-05-31 11:38:25 +02:00
|
|
|
_wanted commands expl 'completed command' compadd -k _comps
|
2000-04-01 22:43:43 +02:00
|
|
|
;;
|
|
|
|
cfun)
|
2000-04-11 09:57:56 +02:00
|
|
|
list=( ${^fpath:/.}/_(|*[^~])(N:t) )
|
|
|
|
if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
|
|
|
|
disp=( ${list[@]#_} )
|
|
|
|
_wanted functions expl 'completion function' \
|
2000-05-31 11:38:25 +02:00
|
|
|
compadd -d disp -a list
|
2000-04-11 09:57:56 +02:00
|
|
|
else
|
2000-05-31 11:38:25 +02:00
|
|
|
_wanted functions expl 'completion function' compadd -a list
|
2000-04-01 22:43:43 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
style)
|
|
|
|
_wanted widgetstyle expl 'widget style' \
|
|
|
|
compadd -M 'r:|-=* r:|=*' \
|
|
|
|
complete-word delete-char-or-list expand-or-complete \
|
|
|
|
expand-or-complete-prefix list-choices menu-complete \
|
|
|
|
menu-expand-or-complete reverse-menu-complete
|
|
|
|
;;
|
|
|
|
esac
|