1#autoload 2 3local prev 4 5# A `--' as the first argument says that we should tell comptags to use 6# the preceding function nesting level. This is only documented here because 7# if everything goes well, users won't have to worry about it and should 8# not mess with it. 9 10if [[ "$1" = -- ]]; then 11 prev=- 12 shift 13fi 14 15if (( $# )); then 16 17 # We have arguments: the tags supported in this context. 18 19 local curcontext="$curcontext" order tag nodef tmp 20 21 if [[ "$1" = -C?* ]]; then 22 curcontext="${curcontext%:*}:${1[3,-1]}" 23 shift 24 elif [[ "$1" = -C ]]; then 25 curcontext="${curcontext%:*}:${2}" 26 shift 2 27 fi 28 29 [[ "$1" = -(|-) ]] && shift 30 31 zstyle -a ":completion:${curcontext}:" group-order order && 32 compgroups "$order[@]" 33 34 # Set and remember offered tags. 35 36 comptags "-i$prev" "$curcontext" "$@" 37 38 # Sort the tags. 39 40 if [[ -n "$_sort_tags" ]]; then 41 "$_sort_tags" "$@" 42 else 43 zstyle -a ":completion:${curcontext}:" tag-order order || 44 (( ! ${@[(I)options]} )) || 45 order=('(|*-)argument-* (|*-)option[-+]* values' options) 46 47 for tag in $order; do 48 case $tag in 49 -) nodef=yes;; 50 \!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";; 51 ?*) comptry -m "$tag";; 52 esac 53 done 54 55 [[ -z "$nodef" ]] && comptry "$@" 56 fi 57 58 # Return non-zero if at least one set of tags should be used. 59 60 comptags "-T$prev" 61 62 return 63fi 64 65# The other mode: switch to the next set of tags. 66 67comptags "-N$prev" 68