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

Re: When to use _arguments -C and when to only use _arguments.



"Nikolai Weibull" wrote:
> I can't deduce from the documentation, or any of the uses, when you
> would want to pass the -C option to _arguments and when you wouldn't,
> assuming that you're actually going to use a state.

If you're not using states then there's no point passing -C. It'll
effectively do nothing.

If you are using states then it comes down to whether it is ever
possible that you will be generating matches for more than one state.
This is very rare but can occur, for example if a flag takes an
optional argument so you need to complete the optional argument along
with the normal arguments.

Note that state and context are arrays where the elements correspond.
This means that if you don't use -C, you need to take care to select the
correct context when generating matches. This is what the -C option to
_tags, _wanted etc is for.

If you use states, you should also make sure that you are consistent
between your use of -C and the variables declared local in your
function. With -C, it should be:
  local curcontext="$curcontext" state line
and without:
  local context state line

There's more details on p385 of "From Bash to Z Shell" if you have it.

Oliver



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