zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Should we be avoiding "zstyle -m" ?
Date: Mon, 8 Jan 2024 16:52:11 +0000 (GMT)	[thread overview]
Message-ID: <244348347.2089761.1704732731254@mail.virginmedia.com> (raw)
In-Reply-To: <CAH+w=7Y-_kT+pdSB7NYH1StF7_r50+Q1-JDMwLq=Bee5_FnU2A@mail.gmail.com>

> On 07/01/2024 20:06 GMT Bart Schaefer <schaefer@brasslantern.com> wrote:
> 
>  
> I'm the main culprit here, using zstyle -m to test whether a style
> exists before asserting a default, something I first did in
> url-quote-magic 20 years ago -- but recently while working on
> something else I realized that -m invokes code defined by zstyle -e,
> which may be inappropriate at the point where the test appears.
> 
> One alternative is to use zstyle -g, but that retrieves only a
> specific pattern rather than matching a context.  The other
> possibility is zstyle -L, which requires capturing stdout because -L
> always returns zero, and further it's uncertain whether the
> metapattern matched by -L is similar enough to a context match.  Based
> on a quick glance at the code I think they may be identical (that is,
> that
>   zstyle -L ":completion:$curcontext"
> would give the desired result), but there's a lot going on in there.
> 
> So what to do here?  Ideas that occur to me ...
> 
> 1) Allow -L and -g to be combined, to return the list in an array
> instead of printing it.
> 2) Add a -q option to -L, to exit 0 or 1 on found or not found,
> without printing.
> 3) Add an option to -m to only match the context, without interpreting
> the value.  Maybe -n ?  In every case where -m is currently used in
> Functions/ and Completion/, the value to match is '*'.
> 4) Variant of #3, which is to skip interpreting the value when
> searching for '*' ... but it's possible someone is depending on -e
> evaluating with -m.
> 5) Add an option to go along with -a/-b/-s that installs the style
> only if it's not already there.  This still runs the risk of adding a
> more-specific style that overrides a user's generic style covering the
> context ... unless this new option also takes a context as an
> argument?  Which gets ugly.

The -q and -L combination sounds like it ought to be reasonably easy
(pass through a flag to suppress output) and ought to be quite flexible
as -L already has a lot of search configurability built into it, maybe?

pws


  reply	other threads:[~2024-01-08 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07 20:06 Bart Schaefer
2024-01-08 16:52 ` Peter Stephenson [this message]
2024-01-09  4:22   ` [PATCH] " Bart Schaefer
2024-01-09  9:17     ` Mikael Magnusson
2024-01-09 18:30       ` Bart Schaefer

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=244348347.2089761.1704732731254@mail.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --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).