Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completing multiple states with _arguments



On Wed, Nov 10, 2010 at 11:20, Peter Stephenson
<Peter.Stephenson@xxxxxxx> wrote:
> On Tue, 9 Nov 2010 23:49:41 +0100
> Nikolai Weibull <now@xxxxxxxx> wrote:

>> How do I deal with multiple states when completing with _arguments?
>>
>> local context state line
>> typeset -A opt_args
>>
>> _arguments \
>> Â ':: :->something-optional-before-files' \
>> Â '*:: :->file' && ret=0
>>
>> # Now what?
>
> Usually you would use "case $state ... esac" to handle the states, with
> matches against something-optional-before-files, file, etc. ÂThere are
> quite a few uses of this if you search for $state in completion.

No, no, $state is (something-optional-before-files file) in this case.

Is it as simple as

local s
for s in $state; do
  case $s in â esac
done

or do you need to deal with tags and such through _alternative or so?



Messages sorted by: Reverse Date, Date, Thread, Author