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

Re: PATCH: Re: _arguments questions



Alexandre Duret-Lutz wrote:

> >>> "Sven" == Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
>  Sven> Alexandre Duret-Lutz wrote:
> 
> [...]
> 
>  >> 1) is there a simplier way to nest `_arguments' ?
> 
>  Sven> I don't see any. Sorry. Adding more syntactic sugar to the
>  Sven> _argument specs to support this doesn't seem worth it unless we put 
>  Sven> it into the <action>. Then it's quite simple (making _arguments
>  Sven> insert the dummy, probably using the option name for it).
> 
> Isn't the `*pattern::message' spec quite the same ? 
>                                                        The `*' or
>                      the  pattern  may also be separated from the
>                      message by two or  three  colons.  With  two
>                      colons  the words special array and the CUR­
>                      RENT special parameter are modified to refer
>                      only to the words after the option (with two
>                      colons) 
> 
> What we want here is that `words' and `CURRENT' refer to the
> words after the option, *including the option*.  
> Why not a four colons separator ?
> 
> _arguments -a -b '-c:*::::blah: _arguments -c -d -e'
> 
> Horrible !

Because of that (;-) and because it isn't quite the same (but I
confess, I had the same idea...). Especially, adding this dummy
element might be useful to combine with both `::' and `:::'.

>  Sven> Should we?
> 
> I would find this helpfull, since it prevent from writting intermediate
> functions (and since _argument is *the* easy way to write completion
> functions, it should better nest without requiring the user to dig the
> completion system).

Hm, yes. I guess many people won't use $words and friends directly...

> Another idea: Isn't there a way to make _arguments detect whether it has
> been nested or not ?  (I don't know, maybe when the <argument> part
> of the context is already set ?).  Of course this solve only the 
> _arguments nesting problem, not the more general "words and CURRENT 
> include the current option" behaviour.

This could be easily done by looking at $funcstack. But it would be
wrong to do that, I think, because there may be cases where one
doesn't want this dummy element and if the nested call to _arguments
inserts it automatically one has no way to circumvent it. Unless we
add a option to _aguments, but that would be more obscure than adding
it to the action of the outer _arguments. Also, only in the outer
_arguments can it be decided if we need a dummy element.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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