* Complete value from list with colons
@ 2019-08-24 12:43 Scott Frazer
2019-08-24 17:26 ` Daniel Shahaf
0 siblings, 1 reply; 6+ messages in thread
From: Scott Frazer @ 2019-08-24 12:43 UTC (permalink / raw)
To: zsh-users
I would like to do completion from a list of values that have ':' in
them, something like:
_values foo a::b c::d
and have it offer 'a::b' and 'c::d' as choices, but I can't figure out
how to escape the ':' in the completion system.
Thanks,
Scott
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Complete value from list with colons
2019-08-24 12:43 Complete value from list with colons Scott Frazer
@ 2019-08-24 17:26 ` Daniel Shahaf
2019-08-25 1:18 ` Oliver Kiddle
2019-08-26 13:28 ` Scott Frazer
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Shahaf @ 2019-08-24 17:26 UTC (permalink / raw)
To: Scott Frazer, zsh-users
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
>
> and have it offer 'a::b' and 'c::d' as choices, but I can't figure out
> how to escape the ':' in the completion system.
Backslashes:
[[[
% _f() { _values desc 'foo\:\:FOO' 'bar\:\:BAR' }
% f <TAB>
> desc
bar::BAR foo::FOO
%
]]]
Cheers,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Complete value from list with colons
2019-08-24 17:26 ` Daniel Shahaf
@ 2019-08-25 1:18 ` Oliver Kiddle
2019-08-26 13:34 ` Scott Frazer
2019-08-26 13:28 ` Scott Frazer
1 sibling, 1 reply; 6+ messages in thread
From: Oliver Kiddle @ 2019-08-25 1:18 UTC (permalink / raw)
To: Scott Frazer, zsh-users
"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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Complete value from list with colons
2019-08-24 17:26 ` Daniel Shahaf
2019-08-25 1:18 ` Oliver Kiddle
@ 2019-08-26 13:28 ` Scott Frazer
1 sibling, 0 replies; 6+ messages in thread
From: Scott Frazer @ 2019-08-26 13:28 UTC (permalink / raw)
To: zsh-users
On 8/24/2019 1:26 PM, 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
>>
>> and have it offer 'a::b' and 'c::d' as choices, but I can't figure out
>> how to escape the ':' in the completion system.
>
> Backslashes:
>
> [[[
> % _f() { _values desc 'foo\:\:FOO' 'bar\:\:BAR' }
> % f <TAB>
>> desc
> bar::BAR foo::FOO
> %
> ]]]
>
> Cheers,
>
> Daniel
>
Thanks, I thought I had tried all combinations of quotes and backslashes
but apparently not.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Complete value from list with colons
2019-08-25 1:18 ` Oliver Kiddle
@ 2019-08-26 13:34 ` Scott Frazer
2019-08-26 17:39 ` dana
0 siblings, 1 reply; 6+ messages in thread
From: Scott Frazer @ 2019-08-26 13:34 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Complete value from list with colons
2019-08-26 13:34 ` Scott Frazer
@ 2019-08-26 17:39 ` dana
0 siblings, 0 replies; 6+ messages in thread
From: dana @ 2019-08-26 17:39 UTC (permalink / raw)
To: Scott Frazer; +Cc: zsh-users
On 26 Aug 2019, at 08:34, Scott Frazer <frazer.scott@gmail.com> wrote:
> _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?
If you're using _arguments you can just do like:
'--foo[specify foo to use]:foo:(a\:\:b c\:\:d)'
You can also use this syntax to give each value a description:
'--foo[specify foo to use]:foo:((
a\\\:\\\:b\:"ab foo"
c\\\:\\\:d\:"cd foo"
))'
Though it gets somewhat confusing when you have colons in the values, as you
can see
dana
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-26 17:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-24 12:43 Complete value from list with colons Scott Frazer
2019-08-24 17:26 ` Daniel Shahaf
2019-08-25 1:18 ` Oliver Kiddle
2019-08-26 13:34 ` Scott Frazer
2019-08-26 17:39 ` dana
2019-08-26 13:28 ` Scott Frazer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).