Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prompt expansion on signals
- X-seq: zsh-workers 49618
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Prompt expansion on signals
- Date: Mon, 29 Nov 2021 18:42:48 +0100
- Archived-at: <https://zsh.org/workers/49618>
- In-reply-to: <CAN=4vMqF3ErOQ_afFHm488AnyGVUzNP-4BduKZiBoUBeL6-LKA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAN=4vMoLqgFjKnWUCH0ZxzEfszpO0ccOEneed9B3aNC_+t3HXg@mail.gmail.com> <CAH+w=7at6wN1VfWA7=_HEuaHkCREBfES=Z5sTrHrBY4n2SR9YA@mail.gmail.com> <CAN=4vMr8=AZWn0dte_UGJX2vRxkeAQMzVfVx1vvjEAp8h2q_Uw@mail.gmail.com> <CAH+w=7b_fp6Smky_p=ZhUPNDvhTsD4pLL8Q1LWtjHEZibWj5rQ@mail.gmail.com> <CAN=4vMqF3ErOQ_afFHm488AnyGVUzNP-4BduKZiBoUBeL6-LKA@mail.gmail.com>
On Mon, Nov 29, 2021 at 12:36 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author