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

Re: completion

Ray Andrews wrote:
> In chapter 10 of 'the book', at one point you start doing this:
>      zstyle ':completion:::::' completer _complete _approximate
> ... I missed any leading explanation of what those five colons
> are doing.

See the grey box on p237.
The part with the colons is the context. The context is decribed using
a colon-separated list of components. This allows for things to be
configured in a context-sensitive manner.

The "completer"s are sort of top-level drivers and are selected very
early while the context is still empty.

The five colons are included because they prevent the completer style
from matching in other contexts where you might want a different

> Playing with matcher-list, you have some good ideas there.
> I currently have all that completion/matcher stuff copied in
> from some website of sample .zshrc's  and it was all taken on
> faith, since I hadn't the slightest clue how all that stuff works.
> Since I'm now trying to understand it, the current line I have
> contains this:
>      zstyle ':completion:*' matcher-list    ...   'r:|[._-]=* r:|=* l:|=*'
> ... at the risk of insanity, what is that incantation doing, and
> do I want it?  Gentle generalities are fine.

Matching is the part of the completion system that decides which of the
possibilities match what you have typed on the command-line. By default,
this is just an exact string match of the prefix so given:

  touch one two three
  : t<tab>

It sees that t is a prefix of two and three but not one.

The r:|[._-]=* is roughly saying put a wildcard (*) before . _ or -.
This allows something line w.z.o<tab> to complete to www.zsh.org

It's not unreasonable to use that style. You might want to further limit
the style, however. Matching control can make approximate completion too
aggressive so you might want ':completion:*:(^approximate):*'
Or you might want to restrict it to, e.g. filename completion.
Applicable matching controls are often defined in specific functions so
the one you quote is not that necessary.


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