zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Prompt expansion on signals
Date: Sun, 28 Nov 2021 17:38:48 -0800	[thread overview]
Message-ID: <CAH+w=7b_fp6Smky_p=ZhUPNDvhTsD4pLL8Q1LWtjHEZibWj5rQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMr8=AZWn0dte_UGJX2vRxkeAQMzVfVx1vvjEAp8h2q_Uw@mail.gmail.com>

On Sun, Nov 28, 2021 at 12:32 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Sun, Nov 28, 2021 at 8:50 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > On Sun, Nov 28, 2021 at 2:01 AM Roman Perepelitsa
> > <roman.perepelitsa@gmail.com> wrote:
> > >
> > > For this to work correctly, prompt_subst must be set when prompt is
> > > expanded. However, this requirement can be violated when prompt is
> > > expanded in a signal handler.

To clarify this point (in part for Oliver), the question is not what
happens when the signal handler is a zsh function and that function
expands prompts.  The problem occurs when a default (C-implementation)
signal handler causes ZLE to redraw the prompt as a side-effect.  "...
when prompt is expanded in a signal handler" confused me for a while
the first time I read through this.

> > A more egregious example might be when the global settings have
> > "unsetopt promptpercent".
>
> I can control these in my config.

I'm not understanding the distinction ... you can control prompt_subst
in your config as well.  I'm just pointing out another case where a
user might want a particular global config that is messed with by
"emulate -R".

> I cannot control options that are
> active when zsh processes SIGCHLD though (unless I never change
> options in zle widgets).

For SIGCHLD in particular you could try "setopt nonotify" in your zle
widgets.  That doesn't help with SIGWINCH, but it might give us an
idea of whether there's a problem with delaying those signals.

I haven't followed the logic through very thoroughly, but what if
instead of delaying the signal handling, we delayed reprinting the
prompt?  Is there a reason an in-progress widget would want the prompt
redisplayed without an explicit call to reset-prompt?

> > Are prompts the only case where this is an issue, though?  The most
> > visible, certainly, but "zle -F" for example?
>
> As far as I'm aware, prompt expansion on signals is the only place
> where it's impossible to set options. Perhaps I'm misunderstanding
> what you mean by "zle -F" in this context?

Sorry, I got the question sort of inside-out (see above about "in a
signal handler" confusion).  The relevant bit is that, like a zle
widget, a zle -F handler might have changed local options and then be
hit with SIGWINCH.

> > What about the reverse situation, where the signal handler is a
> > function that changes options locally?
>
> What do you mean?

Ignore that, more confusion.


  parent reply	other threads:[~2021-11-29  1:39 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 [this message]
2021-11-29 11:36       ` Roman Perepelitsa
2021-11-29 17:42         ` Roman Perepelitsa

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='CAH+w=7b_fp6Smky_p=ZhUPNDvhTsD4pLL8Q1LWtjHEZibWj5rQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=roman.perepelitsa@gmail.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).