about summary refs log tree commit diff
path: root/Completion/Core/_alternative
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Core/_alternative')
-rw-r--r--Completion/Core/_alternative25
1 files changed, 14 insertions, 11 deletions
diff --git a/Completion/Core/_alternative b/Completion/Core/_alternative
index 158f3a07a..f13fc9e5a 100644
--- a/Completion/Core/_alternative
+++ b/Completion/Core/_alternative
@@ -1,19 +1,22 @@
 #autoload
 
-local tags def expl descr action mesgs nm="$compstack[nmatches]"
-local context
+local tags def expl descr action mesgs nm="$compstack[nmatches]" subopts
 
-if [[ "$1" = -C?* ]]; then
-  context="${1[3,-1]}"
+if [[ "$1" = -O?* ]]; then
+  subopts=( "${(@P)1[3,-1]}" )
   shift
-elif [[ "$1" = -C ]]; then
-  context="$2"
+elif [[ "$1" = -O ]]; then
+  subopts=( "${(@P)2}" )
   shift 2
-fi
+else
+  subopts=()
+fi  
+
+[[ "$1" = -(|-) ]] && shift
 
 mesgs=()
 
-_tags -C "$context" "${(@)argv%%:*}"
+_tags "$1" "${(@)argv[2,-1]%%:*}"
 
 while _tags; do
   for def; do
@@ -35,12 +38,12 @@ while _tags; do
 
         eval ws\=\( "${action[3,-3]}" \)
 
-        _describe "$descr" ws -M 'r:|[_-]=* r:|=*'
+        _describe "$descr" ws -M 'r:|[_-]=* r:|=*' "$subopts[@]"
       elif [[ "$action" = \(*\) ]]; then
 
         # Anything inside `(...)' is added directly.
 
-        compadd "$expl[@]" - ${=action[2,-2]}
+        compadd "$subopts[@]" "$expl[@]" - ${=action[2,-2]}
       elif [[ "$action" = \{*\} ]]; then
 
         # A string in braces is evaluated.
@@ -56,7 +59,7 @@ while _tags; do
         # Otherwise we call it with the description-arguments built above.
 
         action=( $=action )
-        ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]}
+        ${(e)action[1]} "$subopts[@]" "$expl[@]" ${(e)~action[2,-1]}
       fi
     fi
   done