Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH v2] prompt: support generic non-visible regions
- X-seq: zsh-workers 50492
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [PATCH v2] prompt: support generic non-visible regions
- Date: Sun, 21 Aug 2022 19:15:19 -0500
- Archived-at: <https://zsh.org/workers/50492>
- In-reply-to: <CAH+w=7ZrUfQV6QRcfjCzJkdYM8bTgZkR3p0W4cWxJZEUOSS8CQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <20220811230901.471640-1-felipe.contreras@gmail.com> <CAH+w=7b2pn6=eXHxRRB8GR-yi6iH+fL8t0SO7Kka415O4g5wxQ@mail.gmail.com> <CAMP44s36=YoiT7Lt-_j6h-fc47z_RS2CexCR++PCZ7p1CXxfEA@mail.gmail.com> <CAH+w=7Y+RSQn-zVzNDPTJV13ZddnGxnwBC=P5E0RFEm4M+fPnw@mail.gmail.com> <CAMP44s0F-wz79s+ba3zA0BqOmobPP+jXbrrLNGse1mdwyLu3Kg@mail.gmail.com> <CAH+w=7ZrUfQV6QRcfjCzJkdYM8bTgZkR3p0W4cWxJZEUOSS8CQ@mail.gmail.com>
On Wed, Aug 17, 2022 at 5:31 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Aug 15, 2022 at 2:37 PM Felipe Contreras
> <felipe.contreras@xxxxxxxxx> wrote:
> >
> > Do we want something like "\001foo\002%\001bar%\002"?
>
> More on this below.
>
> > On Sun, Aug 14, 2022 at 8:00 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > >
> > > On Sun, Aug 14, 2022 at 3:47 PM Felipe Contreras
> > > <felipe.contreras@xxxxxxxxx> wrote:
> > > >
> > > > That would defeat the primary purpose of the patch, which is to be
> > > > able to write prompt helper functions which work in multiple shells.
> > >
> > > In that case I think the patch is incomplete, because it's not keeping
> > > track of bv->dontcount and will be confused if both \001 and %} are
> > > used (or %{ and \002). See lines 602 through 628 of Src/prompt.c
> > > (line numbers as of commit c5a891a2).
> >
> > Yes, I've seen that code, but in my view mixing \001 and %{ doesn't
> > seem to be a useful use case.
>
> Your point above about writing helper functions would seem to imply
> that someone might inadvertently use such a helper (e.g. via
> PROMPT_SUBST) inside a section that was already surrounded by %{ %}
> (or surrounded by \001 \002 though that does seem less likely). The
> purpose of bv->dontcount (or at least one purpose thereof) is to
> permit nesting zero-width sections. I agree it wouldn't make sense to
> (for example) begin a section with %{ and intentionally end it with
> \002.
Yeah, I guess that's possible, although I don't think very likely.
> > but how am I supposed to do a reasonable test?
>
> There isn't a Test/ case for it yet even now. How are we handling %}
> when there's no %{ before it? I think the answer is that we don't
> have a test for that either ...
I didn't mean a proper test case, I meant just to check that the code
actually works.
Anyway, this is how I decided to test it:
$' %{\e[31m\x01\e[31m\x01\e[31m\x02\e[31m\x02\e[31m%}master%{\e[m\x01\e[m\x01\e[m\x02\e[m\x02\e[m%}'
I've sent patch v3 and seems to work fine with all this nesting.
--
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author