Zsh Mailing List Archive
Messages sorted by:
Re: Append cancelled commands to history
- X-seq: zsh-users 14947
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Append cancelled commands to history
- Date: Sat, 20 Mar 2010 10:50:27 -0700
- In-reply-to: <20100315164237.GA23224@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <c16a574a0809181450t61a5b5ddq2e80797fde37636e@xxxxxxxxxxxxxx> <20080919162045.GA22435@xxxxxxxxxxxx> <20090706151644.6BF508027106@xxxxxxxxxxxxxxxxxx> <20090706154309.GA15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20090706155337.GB15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20100315164237.GA23224@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Mar 15, 6:42pm, Nadav Har'El wrote:
> Does anyone know why zsh saves interrupted partial multiline commands,
> but without their last line?
Every time a new prompt is printed -- even if it's the PS2 prompt rather
than the top-level prompt -- is a new "instance" of the line editor.
Looked at another way, as soon as you hit "enter" (accept-line) the
current $BUFFER is stored in the "pending history". You can't yet
scroll back to it from the following PS2 prompt, but it has been
remembered as something you input and might want to revisit later.
Conversely, if you hit the interrupt key or ctrl-g (send-break), the
current buffer has not been stored and ZLE presumes that interruption
means you DON'T want to revisit this later. You can subvert the latter
behavior, but because a new ZLE instance started at accept-line, it's
already too late to subvert the former.
> Can this be avoided? And what was the rationale to save the beginning
> of a multiline command and not everything - or not at all for a single
> line command?
There's a reason the widget is called "accept-line". If the line has
been accepted (even if it doesn't form a complete command yet), it's
something you want; if you "send-break" or do an interrupt, it's not
accepted and therefore something you don't want.
> I thought this would be simple - just replace the print line with
> print -s -r -- "$PREBUFFER$BUFFER"
Hmm. When I use TRAPINT, $PREBUFFER is always empty.
torch% print $ZSH_VERSION $ZSH_PATCHLEVEL
Messages sorted by: