From: dana <dana@dana.is>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: zstyle: "more specific" patterns and *-components
Date: Mon, 27 Apr 2020 13:54:30 -0500 [thread overview]
Message-ID: <A7FAC567-AB94-45C2-85C6-5808EA91291E@dana.is> (raw)
In-Reply-To: <20200427101430.447e2a21@tarpaulin.shahaf.local2>
On 27 Apr 2020, at 05:14, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> However, going by the documentation I expected ':foo:*:baz:*' to be
> considered more specific than ':foo:bar:*' (because it contains more
> components: 'three literal strings and two asterisks' is more than
> 'three literal strings and one asterisk'), and therefore, 'hello' to be
> printed regardless of the order of the first two lines.
I've actually had something about this in my drafts for a few months now.
Pasting here in full:
Re: workers/45413, i was going to change ":completion:${curcontext%}:*" to
":completion:*:${service}:*", reasoning that that would be the best way to
ensure that the fall-back style doesn't override the user's.
But that isn't actually guaranteed — when calculating the weight of a style,
zstyle adds 0 for each component consisting of only *, such that
:foo:*:bar and :foo:*:*:*:bar are equally weighted, and which one wins
depends on the order they were defined.
The documentation says:
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)
I suppose * isn't really a 'substring' in this context, but it still seems
like the pattern with more :*: should win based on there being more
components, doesn't it?
I'm guessing that * is weighted 0 so that :foo:* doesn't have more weight
than :foo:, but could it work better? For example, might it work to change
the weighting to this:
0 First consecutive *-only component (first * in :foo:*:*:bar*)
1 Subsequent consecutive *-only component (second * in :foo:*:*:bar*)
2 Pattern component (bar* in :foo:*:*:bar*)
3 Literal component (foo in :foo:*:*:bar*)
?
But i don't think my suggested change will fix the case you described. Maybe
give each *-only component a weight of 1 unless it's at the very end? Haven't
really thought about it since i wrote that, so there might be other
considerations
dana
prev parent reply other threads:[~2020-04-27 18:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 10:14 Daniel Shahaf
2020-04-27 16:10 ` Roman Perepelitsa
2020-04-27 17:38 ` Mikael Magnusson
2020-04-28 19:06 ` Daniel Shahaf
2020-04-28 19:30 ` dana
2020-04-28 20:20 ` Daniel Shahaf
2020-04-27 18:54 ` dana [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=A7FAC567-AB94-45C2-85C6-5808EA91291E@dana.is \
--to=dana@dana.is \
--cc=d.s@daniel.shahaf.name \
--cc=zsh-workers@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).