* _values and end of options
@ 2016-06-09 12:24 Marko Myllynen
2016-06-09 15:43 ` Oliver Kiddle
0 siblings, 1 reply; 3+ messages in thread
From: Marko Myllynen @ 2016-06-09 12:24 UTC (permalink / raw)
To: zsh workers
Hi,
Below is a minimal example created based on a larger completion:
#compdef foo
local -a opts
opts=( -a -b -c -1 -2 -3 )
_values -w opts $opts
Otherwise this works nicely (each of the options is completed only once)
but -1 -2 are missing from offered options (see _values). I can use --
to have them included as well (_values -w opts -- $opts) but then -- is
also offered.
Can _values be used reliably in cases where there might be options as
values? Or is there a better way to achieve this with compadd or such
for the above case?
Thanks,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: _values and end of options
2016-06-09 12:24 _values and end of options Marko Myllynen
@ 2016-06-09 15:43 ` Oliver Kiddle
2016-06-09 18:11 ` Marko Myllynen
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2016-06-09 15:43 UTC (permalink / raw)
To: zsh workers
Marko Myllynen wrote:
>
> Otherwise this works nicely (each of the options is completed only once)
> but -1 -2 are missing from offered options (see _values). I can use --
> to have them included as well (_values -w opts -- $opts) but then -- is
> also offered.
_values starts with a call to zparseopts to remove normal compadd
style options such as -1 and -2. In general these shouldn't occur after
(or mixed with) the values. It mostly occurs when _values is used
within an _arguments spec. In that case the unwanted options only appear
at the beginning. The following patch makes it only remove compadd style
options that occur at the beginning.
> Can _values be used reliably in cases where there might be options as
> values? Or is there a better way to achieve this with compadd or such
> for the above case?
Well, normally you'd use _arguments for options but I assume you have
some reason for not doing that. _values should work but may have some
differences - like not checking the prefix-needed style.
Oliver
diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values
index ab0e46a..c510b4c 100644
--- a/Completion/Base/Utility/_values
+++ b/Completion/Base/Utility/_values
@@ -3,7 +3,7 @@
local subopts opt usecc garbage
subopts=()
-zparseopts -D -E -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X:
+zparseopts -D -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X:
(( $#subopts )) && subopts=( "${(@P)subopts[2]}" )
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: _values and end of options
2016-06-09 15:43 ` Oliver Kiddle
@ 2016-06-09 18:11 ` Marko Myllynen
0 siblings, 0 replies; 3+ messages in thread
From: Marko Myllynen @ 2016-06-09 18:11 UTC (permalink / raw)
To: zsh-workers
Hi,
On 2016-06-09 18:43, Oliver Kiddle wrote:
> Marko Myllynen wrote:
>>
>> Otherwise this works nicely (each of the options is completed only once)
>> but -1 -2 are missing from offered options (see _values). I can use --
>> to have them included as well (_values -w opts -- $opts) but then -- is
>> also offered.
>
> _values starts with a call to zparseopts to remove normal compadd
> style options such as -1 and -2. In general these shouldn't occur after
> (or mixed with) the values. It mostly occurs when _values is used
> within an _arguments spec. In that case the unwanted options only appear
> at the beginning. The following patch makes it only remove compadd style
> options that occur at the beginning.
>
> -zparseopts -D -E -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X:
> +zparseopts -D -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X:
>
With this change all works here now as I hoped, thanks!
Cheers,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-09 18:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 12:24 _values and end of options Marko Myllynen
2016-06-09 15:43 ` Oliver Kiddle
2016-06-09 18:11 ` Marko Myllynen
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).