1# This makes defining styles a bit simpler by using a single `+' as a
2# special token that allows one to append a context name to the
3# previously used context name. Like this:
4#
5#   zstyle+ ':foo:bar' style1 value1 \
6#         + ':baz'     style2 value2 \
7#         + ':frob'    style3 value3
8#
9# This defines style1 with value1 for the context :foo:bar as usual.
10# But it also defines styles2 with value2 for the context :foo:bar:baz
11# and style3 with value3 for :foo:bar:frob.
12# Of course, any of the sub-contexts after the plus signs may be
13# empty strings to re-use the previous context unchanged.
14#
15# If you don't want to change all your calls to `zstyle' to use
16# `zstyle+' you can use an alias `alias zstyle=zstyle+' and make sure
17# the completion functions are autoloaded without alias expansion (the
18# -U option to the autoload builtin). The completion system normally
19# loads its functions with without alias expansion.
20
21case "$1" in
22-*) zstyle "$@";;
23
24*)  setopt localoptions noksharrays
25    integer i
26    local context="$1"
27    1=''
28    for ((i=2; $#; ++i)); do
29      if [[ $i -gt $# || "$argv[i]" == '+' ]]; then
30        zstyle "$context${(@)argv[1,i-1]}"
31        shift "i > $# ? $# : i"  # Stupid shift error on i > $#
32  	i=1
33      fi
34    done;;
35esac
36