Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completing comma seprated list of option values in _atguments
- X-seq: zsh-users 4688
- From: Sven Wischnowsky <wischnow@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Completing comma seprated list of option values in _atguments
- Date: Mon, 25 Feb 2002 09:54:52 +0100
- In-reply-to: <005601c1bb9a$7f047200$21c9ca95@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <005601c1bb9a$7f047200$21c9ca95@xxxxxxxxxxxxxx>
Borsenkow Andrej wrote:
> I must be entirely stupid but I cannot figure out how to do it. Values
> must be generated on the fly not chosen from fixed array. And _values
> seems to want fixed values only :(
Yes, _values is not intended for that, although it depends on how the
values are generated, of course...
We probably don't need utility functions for everything, simple
solution, not that nice, but ok when values may appear more than once:
local expl
compset -P '*,'
_wanted foos expl foo compadd -qS, calculated values
More sophisticated, values may appear only once:
local expl comps suf
comps=(value calculation goes here)
compset -P '*,'
comps=( ${comps:#${~IPREFIX//,/|}} )
if [[ $#comps -gt 1 ]]; then
suf=(-qS,)
else
suf=()
fi
_wanted foos expl foo compadd $suf $comps
If you want to generate the matches even later, I'd suggest using the
first version with _wanted calling a utility function that builds the
matches. But if those values are the only possible matches in that
context and hence are the normal completions in that case it's
probably not worth it and the code above should be enough.
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author