summaryrefslogtreecommitdiffstats
path: root/Completion/Builtins/_compdef
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-09 11:46:27 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-09 11:46:27 +0000
commitda55261a17ca9b5b35191db1c1c0cdccd09cb702 (patch)
treeb3e7a2a7fd67f5665c75659c5ec6a2521ca5a14a /Completion/Builtins/_compdef
parentzsh-workers/10011 (diff)
downloadzsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar.gz
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar.bz2
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar.lz
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar.xz
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.tar.zst
zsh-da55261a17ca9b5b35191db1c1c0cdccd09cb702.zip
zsh-workers/10013
Diffstat (limited to 'Completion/Builtins/_compdef')
-rw-r--r--Completion/Builtins/_compdef55
1 files changed, 35 insertions, 20 deletions
diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef
index 7b4b0cb35..772c6b90d 100644
--- a/Completion/Builtins/_compdef
+++ b/Completion/Builtins/_compdef
@@ -1,24 +1,39 @@
#compdef compdef
-local expl func base=2
+local state line expl list disp
-while [[ $words[base] = -* ]]; do
- case $words[base] in
- -d) delete=yes ;;
- -p) type=pattern ;;
- -k) type=key ;;
- esac
- (( base++ ))
-done
+_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'
+
-if [ "$delete" ]; then
- _wanted commands expl 'completed command' &&
- compadd "$expl[@]" - ${(k)_comps}
-else
- if [[ CURRENT -eq base ]]; then
- _wanted functions expl 'completion function' &&
- compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t)
- else
- _command_names
- fi
-fi
+case $state in
+ ccom)
+ _wanted commands expl 'completed command' &&
+ compadd "$expl[@]" - ${(k)_comps}
+ ;;
+ cfun)
+ if _wanted functions expl 'completion function'; then
+ list=( ${^fpath:/.}/_(|*[^~])(N:t) )
+ if zstyle -T ":completion:${curcontext}" prefix-hidden; then
+ disp=( ${list[@]#_} )
+ compadd "$expl[@]" -d disp - "$list[@]"
+ else
+ compadd "$expl[@]" - "$list[@]"
+ fi
+ fi
+ ;;
+ style)
+ _wanted widgetstyle expl 'widget style' &&
+ compadd 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