zsh-users
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: problem with context specification
Date: Tue, 14 Jan 2020 18:50:32 +0000	[thread overview]
Message-ID: <2119475f-71ea-436e-ab89-5782e29f3341@www.fastmail.com> (raw)
In-Reply-To: <CAH+w=7aQ4HctYb81RuMVDb-AgzXPrccROx=pJtvWUTtWBs6xrw@mail.gmail.com>

Bart Schaefer wrote on Tue, 14 Jan 2020 18:34 +00:00:
> On Tue, Jan 14, 2020 at 10:06 AM Peter Stephenson
> <p.stephenson@samsung.com> wrote:
> >
> > On Tue, 2020-01-14 at 16:45 +0000, Daniel Shahaf wrote:
> > > > I assume the stars are for matching every possible value for that segment,
> > > No.  An asterisk matches zero or more characters, _including colons_.
> >
> > This can certainly be a right pain.
> 
> It's important to remember that the colons are strictly a completion
> system convention -- they have nothing to do with the semantics of
> zstyle itself,

That's not so.  A colon is hardcoded into the determination of which
pattern is more specific than another.  For example, consider this:

zstyle ':foo:*' key value
zstyle ':foo:bar:*' key value

This is two patterns.  The second one is more specific than the first
because it has more segments.  The order of definition of these two
patterns will not affect lookup results:

% zstyle ':foo:*' key value1 
% zstyle ':foo:bar:*' key value2 
% zstyle -s :foo:bar:baz key a 
% zstyle -d ':foo:*'
% zstyle -d ':foo:bar:*'
% zstyle ':foo:bar:*' key value2 
% zstyle ':foo:*' key value1 
% zstyle -s :foo:bar:baz key b 
% echo $a $b 
value2 value2
% 

Now, change the example to not use colons:

zstyle '/lorem/*' key value
zstyle '/lorem/ipsum/*' key value

This is two patterns that are *equally* specific — each of them consists
of one colon-separated segment that's neither a literal string nor the
pattern «*» — so the order of definition does matter: if you change the
order of definitions of these two patterns, lookup results will be
different:

% zstyle '/lorem/*' key value1 
% zstyle '/lorem/ipsum/*' key value2 
% zstyle -s /lorem/ipsum/dolor key a 
% zstyle -d '/lorem/*'
% zstyle -d '/lorem/ipsum/*'
% zstyle '/lorem/ipsum/*' key value2 
% zstyle '/lorem/*' key value1 
% zstyle -s /lorem/ipsum/dolor key b 
% echo $a $b 
value1 value2
% 

This is documented and tested.

      reply	other threads:[~2020-01-14 18:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200113164758eucas1p17ea364450eec705f49edaa8fb69fa65b@eucas1p1.samsung.com>
2020-01-13 16:46 ` Pier Paolo Grassi
2020-01-13 16:56   ` Peter Stephenson
2020-01-13 17:46     ` Mikael Magnusson
2020-01-14 11:52       ` Peter Stephenson
2020-01-13 17:53     ` Bart Schaefer
2020-01-13 17:06   ` Daniel Shahaf
2020-01-13 17:41     ` [PATCH] docs: Add an example of setting and querying zstyles (was: Re: problem with context specification) Daniel Shahaf
2020-01-14 15:59     ` problem with context specification Pier Paolo Grassi
2020-01-14 16:45       ` Daniel Shahaf
2020-01-14 17:55         ` Pier Paolo Grassi
2020-01-14 18:05         ` Peter Stephenson
2020-01-14 18:34           ` Bart Schaefer
2020-01-14 18:50             ` Daniel Shahaf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2119475f-71ea-436e-ab89-5782e29f3341@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).