zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh-workers@zsh.org, Oliver Kiddle <opk@zsh.org>, dana <dana@dana.is>
Subject: Re: [PATCH] prompt: support generic non-visible regions
Date: Thu, 11 Aug 2022 09:26:30 -0500	[thread overview]
Message-ID: <CAMP44s1bD1AEhKxT+a358V37zh_vdMWv+b=qqL9m6t=JEVdOVQ@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3TgnBE7s2DA3MpOkECFdXngmYCdMb5zO0mOzB5B61mHpA@mail.gmail.com>

On Thu, Aug 11, 2022 at 9:02 AM Mikael Magnusson <mikachu@gmail.com> wrote:
> On 8/10/22, Felipe Contreras <felipe.contreras@gmail.com> wrote:
> > On Wed, Aug 10, 2022 at 1:59 PM Mikael Magnusson <mikachu@gmail.com> wrote:

> >> The commit message seems a bit confused, %F has nothing to do with
> >> marking characters as 0-width, rather everything between %{ and %}
> >> will be treated as such. You can use %{%} (or \001 https://www.logicallyfallacious.com/logicalfallacies/Slippery-Slopeand \002) to set
> >> colors via the specific \e [ Ps m code, but also to send any other
> >> codes handled by the terminal.
> >
> > If I do PS1='%F{red}foo' putpromptchar() will call
> > set_colour_attribute(), which eventually calls this:
> >
> >   if (!bv->dontcount) {
> >       addbufspc(1);
> >       *bv->bp++ = Inpar;
> >   }
> >   tputs(tgoto(tcstr[tc], colour, colour), 1, putstr);
> >   if (!bv->dontcount) {
> >       addbufspc(1);
> >       *bv->bp++ = Outpar;
> >   }
> >
> > I can do the same thing fputs() is doing with PS1=$'\e[31mfoo', but
> > now zsh will think my prompt is bigger than it actually is and the
> > shell will be screwed. So I have to put that inside %{%}.
> >
> > Therefore "%F{red}" = $'%{\e[31m%}'
>
> Sure, this agrees 100% with what I was saying, but the statement in
> the commit still doesn't make sense. You've proven that you can use %{
> or \001 to do what %F{} does, but the commit message states the
> opposite which is not true.

The commit message says:

1. We do readline $'\001\e[31m\002' as zsh '%F{red}'.

This is true.

2. We could support $'\001\e[31m\002'.

This is also true.

> >> That aside, I don't really see a reason to add support for
> >> bash-specific prompt sequences that are more cumbersome to use than
> >> the already existing zsh ones. Bash prompts are already completely
> >> incompatible anyway.
> >
> > The prompts are not compatible, but the functions used in those prompts can
> > be.
> >
> >   __git_ps1_test () {
> >     local branch='master'
> >     local red=$'\001\e[31m\002'
> >     local clear=$'\001\e[m\002'
> >     echo "${red}${branch}${clear}"
> >   }
> >
> > The function above works perfectly fine in bash and zsh with my patch,
> > and I can add $(__git_ps1_test) to both of my prompts.
>
> You could also have a $START_INVIS and $END_INVIS parameter depending
> on what shell you're in.

Yes, and I can do red=$'\001\e[31m\002' or red='%F{red}' depending
what shell I'm in, which is what I was doing.

But *why* would I do that when zsh is perfectly capable of
interpreting \001 and \002? (with my patch)

> Well, I don't have a strong opinion either
> way, but it doesn't seem worth it to me. If we support this, people
> might ask "but you support \001, why not this other xyz prompt feature
> from bash?"

Slippery slope fallacy [1]. Yes, they might ask that, and you might
answer "no, unline \001, xyz requires too much effort".

This doesn't require too much effort.

[1] https://www.logicallyfallacious.com/logicalfallacies/Slippery-Slope

-- 
Felipe Contreras


  reply	other threads:[~2022-08-11 14:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 11:51 Felipe Contreras
2022-08-10 18:59 ` Mikael Magnusson
2022-08-10 19:56   ` Felipe Contreras
2022-08-11 14:02     ` Mikael Magnusson
2022-08-11 14:26       ` Felipe Contreras [this message]
2022-08-11 18:32         ` Mikael Magnusson
2022-08-11 18:47           ` Felipe Contreras
2022-08-11 18:54             ` Mikael Magnusson
2022-08-11 19:46               ` Felipe Contreras
2022-08-11 20:38                 ` Bart Schaefer
2022-08-11 23:22                   ` Felipe Contreras
2022-08-11 14:37 ` Roman Perepelitsa
2022-08-11 15:21   ` Bart Schaefer
2022-08-11 16:20     ` Felipe Contreras
2022-08-11 16:49       ` Bart Schaefer
2022-08-11 18:48         ` Felipe Contreras
2022-08-11 17:24   ` Roman Perepelitsa
2022-08-11 18:55     ` Roman Perepelitsa
2022-08-11 19:23     ` Felipe Contreras
2022-08-11 19:35       ` Roman Perepelitsa
2022-08-11 19:44         ` Felipe Contreras

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='CAMP44s1bD1AEhKxT+a358V37zh_vdMWv+b=qqL9m6t=JEVdOVQ@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=dana@dana.is \
    --cc=mikachu@gmail.com \
    --cc=opk@zsh.org \
    --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).