From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 11722 invoked from network); 27 Apr 2020 18:53:35 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 27 Apr 2020 18:53:35 -0000 Received: (qmail 5657 invoked by alias); 27 Apr 2020 18:53:28 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45727 Received: (qmail 24608 invoked by uid 1010); 27 Apr 2020 18:53:28 -0000 X-Qmail-Scanner-Diagnostics: from mail-qv1-f45.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25793. spamassassin: 3.4.4. Clear:RC:0(209.85.219.45):SA:0(-1.9/5.0):. Processed in 2.756348 secs); 27 Apr 2020 18:53:28 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.219.45 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=M18nAZ97fD2BjguB8mYnXVtUYoQdIGxtGJjGwiZUAHk=; b=scLfRg56LsO6i1VL1bqLOFE84bMAAKr8zNI6Ooy1T5v8WsGVK23A4rBHU+MxtdtDk1 HMjpHhhcRCZAAF55Ht+P7fLtzCFGKVlw3x3mNcbyOWc3D7k5qG8TG3AO5P0xyL+YWpy2 Ys3IRhDFV9gtjPTN7PNyICVGwZGjPp1v5Ywe6JBZXnvgr4QCaSSs1mbwYkSWtmiyb6c/ 86BcZBlt+M4HsOneqHkjVVLBwepkAcveRcuRcLZcldCvctKsadLd2IqONRnuIASYUoPp OuFfpdTl8MFtdIqYlUIT3WlMxoxiNTFOxFfZhQxnzx3pMROCTZnqbtxesSuLPhuJpEvP OG5A== X-Gm-Message-State: AGi0Pua/AjPm+Mm5+Z0tlHsvhb6L/KILNlUaqDt4YXf23F9ohmurPP7S i5Jio6XpONZj/PfFQdJCwhl/bA== X-Google-Smtp-Source: APiQypK1mCS+OJ4pAqVn0vMrrwmCLaco6ALH9+DClCMqeuFMEZrzO7FgRZ9f4tllsIgY2yfwDgvfEw== X-Received: by 2002:a0c:ef05:: with SMTP id t5mr23065051qvr.113.1588013570736; Mon, 27 Apr 2020 11:52:50 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: zstyle: "more specific" patterns and *-components From: dana In-Reply-To: <20200427101430.447e2a21@tarpaulin.shahaf.local2> Date: Mon, 27 Apr 2020 13:54:30 -0500 Cc: zsh-workers@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200427101430.447e2a21@tarpaulin.shahaf.local2> To: Daniel Shahaf X-Mailer: Apple Mail (2.3608.60.0.2.5) On 27 Apr 2020, at 05:14, Daniel Shahaf 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 =E2=80=94 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