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

Re: problem with context specification



thanks, this is very helpful in putting together many bits of information.
zsh has a very extensive documentation and sometimes it feels a bit
overwhelming

Pier Paolo Grassi
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO


Il giorno mar 14 gen 2020 alle ore 17:45 Daniel Shahaf <
d.s@xxxxxxxxxxxxxxxxxx> ha scritto:

> Pier Paolo Grassi wrote on Tue, 14 Jan 2020 15:59 +00:00:
> > to answer Daniel:
> >
> > > I take it the documentation of zstyle didn't make this clear, so could
> you
> > > suggest how to improve it?
> >
> > It's not clear to me what is the meaning of the various "sections"of the
> > pattern (the segments delimited by the colons)
>
> This, too, is explained in the manual (see zshcompsys(1), or online):
>
>        The context string always consists of a fixed set of fields,
> separated
>        by colons and with a leading colon before the first.  Fields which
> are
>        not yet known are left empty, but the surrounding colons appear
> anyway.
>        The fields are always in the order
>        :completion:function:completer:command:argument:tag.  These have the
>        following meaning:
>
> > what should I put in the first section?
>
> ":completion:", literally.  That's hard-coded.  See the patch I posted
> for another example, and Misc/vcs_info-examples in the source
> distribution.
>
> > is there a list of possible values and relative meaning?
>
> The manual does list the available completers and many tags and styles
> (the style
> is, e.g., "matcher-list" in your example), but it's possible some commands
> use custom
> ones.  Ctrl+X h is the standard recommendation for discovering these.
>
> > and so on for each section
> > why the number of sections is not the same for every pattern?
>
> Because asterisks can match colons.  The number of sections in the
> context _that is looked up_ (with zstyle -s/-t/-T/-b/-a) is always the
> same.  There's an example in the patch I posted.
>
> > How can I know how many pattern I should put in?
>
> One pattern per zstyle command in your zshrc.
>
> If you mean how many colon-separated parts, that's up to you.  It's
> basically a matter of coding style unless you set the same style in
> multiple contexts, in which case the colons directly affect precedence,
> as explained in the portion of the docs I quoted in my first answer
> (though in retrospect I'm not sure now if that was what you were asking
> about then).
>
> > I assume the stars are for matching every possible value for that
> segment,
>
> No.  An asterisk matches zero or more characters, _including colons_.
> (My patch said that explicitly.)
>
> > are there other globbing operators available?
>
> Yes, anything that works in «case $haystack in ‹needle›) …;; esac», or
> equivalently in «[[ ‹haystack› == ‹needle› ]]», can be used in zstyle
> settings.
>
> > can I use them for prefix/suffix matching? (eg someth* for
> > something etc)
>
> Yes, you could:
>
> % zstyle 'foob*' key value
> %
> % zstyle -s foobar key REPLY
> % typeset -p REPLY
> typeset REPLY=value
> %
>
> For example, I set:
>
> zstyle ':completion:*:*:git-*:*:hosts' ignored-patterns localhost
> ip6-localhost ip6-loopback
>
> and the style applies to git-push(1), git-pull(1), git-ls-remote(1), etc..
>
> > Not that I think it would be particularly useful, but the question
> > came to mind I assume also that the stars don't match multiple
> > segments, but this doesn't seem to be stated in the docs.
>
> See above.
>


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