1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-17 22:31:12 +01:00
zsh/Completion/Builtins/_compdef

40 lines
1.5 KiB
Text
Raw Normal View History

1999-09-22 14:35:20 +02:00
#compdef compdef
2000-03-09 12:46:27 +01:00
local state line expl list disp
1999-09-22 14:35:20 +02:00
2000-03-09 12:46:27 +01:00
_arguments -C -s \
'(-d)-a[make function autoloadable]' \
'(-d -p -P)-n[leave existing definitions intact]' \
'(-a -n -p -P -k -K)-d[delete]:*:completed command:->ccom' \
'(-n -d -P -k -K)-p[completion for command matching pattern]:completion function:->cfun:pattern' \
'(-n -d -p -k -K)-P[as -p for commands without own completion]:completion function:->cfun:pattern' \
'(-d -p -P -K)-k[define widget and key binding]:completion function:->cfun:widget name::style:->style:*:key' \
'(-d -p -P -k)-K[define multiple widgets based on function]:completion function:->cfun:widget name::style:->style:*:key' \
'1:completion function:->cfun' \
'2:commands:_command_names'
1999-09-22 14:35:20 +02:00
2000-03-09 12:46:27 +01:00
case $state in
ccom)
2000-03-23 05:19:26 +01:00
_wanted commands expl 'completed command' compadd - ${(k)_comps}
2000-03-09 12:46:27 +01:00
;;
cfun)
2000-03-23 05:19:26 +01:00
if _wanted functions; then
2000-03-09 12:46:27 +01:00
list=( ${^fpath:/.}/_(|*[^~])(N:t) )
2000-03-23 05:19:26 +01:00
if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
2000-03-09 12:46:27 +01:00
disp=( ${list[@]#_} )
2000-03-23 05:19:26 +01:00
_loop functions expl 'completion function' compadd -d disp - "$list[@]"
2000-03-09 12:46:27 +01:00
else
2000-03-23 05:19:26 +01:00
_loop functions expl 'completion function' compadd - "$list[@]"
2000-03-09 12:46:27 +01:00
fi
fi
;;
style)
2000-03-23 05:19:26 +01:00
_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
2000-03-09 12:46:27 +01:00
;;
esac