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

Re: Completing comma seprated list of option values in _atguments

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

  _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.


Sven Wischnowsky                          wischnow@xxxxxxxxx

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