zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Prompt expansion on signals
Date: Mon, 29 Nov 2021 18:42:48 +0100	[thread overview]
Message-ID: <CAN=4vMqfJpSD=hzmrqWaShB+erva_JLAX6AeyrynPNYPg6cJvQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMqF3ErOQ_afFHm488AnyGVUzNP-4BduKZiBoUBeL6-LKA@mail.gmail.com>

On Mon, Nov 29, 2021 at 12:36 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> I'm attaching a patch that implements it. Also
> available here:
> https://github.com/romkatv/zsh/commit/cdcb141c880799847f2b068fef5d097736d484d6

This works rather badly when a signal arrives during a long-running
widget like history-incremental-search-backward. Given that my patch
delays only zleredisplay but not "job done" messages, we end up in a
sorry state of having no prompt. Moreover, the next typed character
triggers zleredisplay that may cause prompt reexpansion with wrong
options.

Maybe the "job done" message should also be delayed? That would
probably be OK in practice but I'm not sure. And what about WINCH if
it arrives during history-incremental-search-backward? With my patch
it won't be processed until the widget is done. Doesn't seem ideal.

Maybe a different approach? Perhaps a new zle hook -- something like
zle-prompt-pre-expand -- that zle would invoke every time before
expanding prompt. The name of the prompt would be passed as an
argument ("PS1", "RPS1", etc.). The hook could set REPLY scalar (which
would be initially unset) to an alternative prompt value; it could
also set reply array (also initially unset) to the list of options
that zle must apply on top of the current options before expanding
prompt (alternatively, the hook itself could change options if zle
would guarantee that these changes will be reverted after prompt is
expanded). People who now set PS1 in precmd will be able to do that in
zle-prompt-pre-expand. It will allow their prompt-building code to
react to changes in TTY dimensions and background jobs. It would
simplify my zsh theme's implementation by quite a bit.

Roman.


      reply	other threads:[~2021-11-29 17:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28  9:59 Roman Perepelitsa
2021-11-28 19:50 ` Bart Schaefer
2021-11-28 20:31   ` Roman Perepelitsa
2021-11-28 21:10     ` Oliver Kiddle
2021-11-28 21:36       ` Roman Perepelitsa
2021-11-29  1:38     ` Bart Schaefer
2021-11-29 11:36       ` Roman Perepelitsa
2021-11-29 17:42         ` Roman Perepelitsa [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='CAN=4vMqfJpSD=hzmrqWaShB+erva_JLAX6AeyrynPNYPg6cJvQ@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=schaefer@brasslantern.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).