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

Re: Complete value from list with colons



On 8/24/2019 9:18 PM, Oliver Kiddle wrote:
"Daniel Shahaf" wrote:
Scott Frazer wrote on Sat, 24 Aug 2019 12:44 +00:00:
I would like to do completion from a list of values that have ':' in
them, something like:

_values foo a::b c::d

Backslashes:

% _f() { _values desc 'foo\:\:FOO' 'bar\:\:BAR' }

Or don't use _values:

   _wanted foos expl foo compadd a::b c::d

Which particular feature of _values do you want? For lists, you can use
_sequence, e.g.:
   _wanted foos expl foo _sequence compadd - a::b c::d

and if you want descriptions, _describe might do the job but probably
still needs colons to be quoted. _values is usually not the best choice
when the list of matches are generated somehow.

Oliver


I guess I don't know which is most appropriate, there are many options and _values seemed to fit the bill.

I pared things down for my question, but to be more exact I want completion for an option. Something like:

_arguments : '--foo[Which foo to use]:foo:_values whatever 'a\:\:b' 'c\:\:d'

i.e. the --foo option has a limited number of legal values. What would you suggest I use here?

Scott



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