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

RE: zstyle problems

> but I still think this is a bit confusing. Typing 'cd' and then
> pressing ^Xh says 'tags in context :completion::complete:cd::', which
> made me think that this was the actual context...

That is correct for the time when actual completion for cd is done. 
But completion is a hierarchical process, and it looks up styles at
different steps, so in early stage some information is not yet

When completion starts, it knows only

- it is completion :-)
- actual command line contents
- whether it has been called as default, context sensitive, completion
or explicitly as special completion widget.

So at this stage it can just fill  in the first two fields, notably

:completion:     :
     ^        ^
     |        + default completion (for a widget here is a widget name)

     + completion (as opposed to e.g. styles for zftp function

The first step it does at this point (after some initialization) is to
decide what completer to use. It is completer that actually generates
matches. Because the above is the only available information, completion
looks up completer(s) using the context :completion:::::, for a
complete-history widget this would be (probably)

Then completer fills in next part of context, then it decides if we are
completing command, parameter etc and fills in next part of context etc.

I too wish it is better described in manuals. At least, those cases when
styles are looked up using non-standard context definitely must be made
clear. Unfortunately, most examples overuse wildcards thus hiding this.

> What would be the
> correct way of defining different (individual) completions for 'cd'
> other
> commands?

Mostly it is what you have done. For cd context is
:completion::complete:cd:: with optional specific tag names appended.
For completion based on _arguments you may add argument-N or option-N as
last part to modify completion for specific options/arguments. You may
also use :completion:*:... for both default context sensitive completion
and completion widgets.


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