From e6282df1155e8d9b08b2e518a452c1997973f1ce Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 12 Nov 1999 15:28:24 +0000 Subject: manual/8630 --- Completion/Core/_alternative | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'Completion/Core/_alternative') 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 -- cgit 1.4.1