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

Re: Problem with _arguments



On 11/22/06, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
"Nikolai Weibull" wrote:
> Say that I have
>
> #compdef craptastic
>
> _arguments \
>   '-s[omething]:with an argument' \
>   '*:directory:_directories'
>
> Then, at least with my setup, if I have the following command line and
> press <Tab> I get:
>
> % craptastic -s <Tab>
> ::: with an argument :::
>
> but if I have the following and press <Tab> I get:
>
> % craptastic src -s <Tab>
> ::: with an argument :::
> ::: directory :::
>
> Why is directory all of a sudden a viable option here?

   _arguments [ -nswWACRS ] [ -O name ] [ -M matchspec ] [ : ] spec ...
          This function can be used to give a complete  specification  for
          completion  for  a  command whose arguments follow standard UNIX
          option and argument conventions.

"Standard UNIX option and argument conventions" are that all options
come before all non-option arguments.  The GNU extension that they can
occur in any order is not supported.  So -s is an argument following the
argument src.  _arguments thinks src, -s and the argument you're now
completing are normal arguments and hence completes directories.

But it still offers the completion for -s, so it must have /some/ sort
of understanding of what's going on already.

Oh well, I guess I'll have to give up on this for the time being.

Actually, would there be a good way of tricking _arguments into only
seeing what you want it to see?  In this case, it would work fine if
one could trick it into only seeing the stuff after src, so that it
would continue completing options.

Thanks.

 nikolai



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