about summary refs log tree commit diff
path: root/Completion/Core/_alternative
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-12 15:28:24 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-12 15:28:24 +0000
commite6282df1155e8d9b08b2e518a452c1997973f1ce (patch)
treeb0c8ed7e8512cc4397ae7df6d138ea66147565b3 /Completion/Core/_alternative
parent167b0ae3b98938f75287dcf2e112d41a03532c5f (diff)
downloadzsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.tar.gz
zsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.tar.xz
zsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.zip
manual/8630
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