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

Re: Possible to use _arguments with _regex_arguments?



"Ronan Pigott" wrote:
> I've since found that _arguments itself has the ability to transform the
> words and CURRENT special parameters by specifying the argument like:
> '*::message:action', but unfortunately it still does not produce the
> desired result when 'action' is a function generated by
> _regex_arguments. Can anyone explain the behavior I see?

Both _arguments and _regex_arguments like the words array to start with
an initial element for the command. With '*:message:action', the -o
options get left in $words. With the '*::... form, they are stripped but
there is no initial element left. Try using
    '*::positional arguments:= _myfunc'

More specifically:

  _regex_arguments _myfunc /$'*\0[ \t\n]#'/ \
    '/[]/' ':args:arg:(one two three)'

  _arguments -S -s \
    {-o+,--option}'[an option]:tag:(some values)' \
    '*::positional arguments:= _myfunc'

The = causes it to add back an initial element in $words.
_regex_arguments is then ignoring this with the /$'*\0[ \t\n]#'/ pattern
so this is all fairly pointless but _regex_arguments was somehow
designed for handling the whole command-line.

If you'd like to see a real example that combines _arguments with
_regex_arguments see _sed from a relatively recent zsh. 

Oliver



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