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

Re: problem with context specification

Pier Paolo Grassi wrote on Mon, Jan 13, 2020 at 17:46:09 +0100:
> if I substitute this as the general case, eg:
>   zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z} l:|=* r:|=*'
> then everything get this style, so the syntax is correct. it seem that what
> is wrong is the pattern.
> I tried some variations of it, with no success:
>   zstyle ':completion:*:*:episodes:*' ...
>   zstyle ':completion:*:episodes:*' ...
> my main problem is that I don't really understand the pattern syntax, and
> haven't been able to find a man page detailing it (the documentation on the
> zstyle builtin doesn't explain it), so I basically try random variations.

The documentation does explain it; quote:

              For ordering of comparisons, patterns are searched from most
              specific to least specific, and patterns that are equally
              specific keep the order in which they were defined.  A pattern
              is considered to be more specific than another if it contains
              more components (substrings separated by colons) or if the
              patterns for the components are more specific, where simple
              strings are considered to be more specific than patterns and
              complex patterns are considered to be more specific than the
              pattern `*'.

The upshot of this is that each of the patterns ':completion:*:*:episodes:*'
and ':completion:*:episodes:*' is considered to be more specific than
':completion:*'.  A style set under either of the former would have precedence
over a style set under the latter, _as far as zstyle is concerned_.  (See
pws's answer for the caveat.)

> Using ctrl-x h after episodes on the command line it gives:
> tags in context :completion::complete:episodes::
>     argument-rest  (_arguments _episodes)
> so I've tried:
>   zstyle ' :completion::complete:episodes::'
> but still to no effect, and also the lack of * seems a little suspicious

No, the lack of stars is expected.  What you put in zshrc is patterns; the
completion system then looks up specific strings that the patterns are matched
against.  The settings attached to the most specific pattern that matches are

Minimal example:

zshrc contains:

% zstyle ':foo:bar' lorem yes
% zstyle ':foo:*'   lorem no

Then the foo subsystem might run, for example:

% zstyle -t :foo:bar lorem && pwd
% zstyle -t :foo:baz lorem && pwd

I take it the documentation of zstyle didn't make this clear, so could you
suggest how to improve it?



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