Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: $ZLE_LINE_ABORTED
- X-seq: zsh-workers 28254
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: PATCH: $ZLE_LINE_ABORTED
- Date: Sun, 12 Sep 2010 21:49:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=3/KiPD1L/deaKXAb0vUWFfyDZT8i9ps+LhTtKPwvGh4=; b=cmGV/ALi3j+9q2pP/plUwqi036aWK4hBnhMrVqNDoIg5izxBOLv0tVBb+D/3OUqz4I xTKCOzO+u6lNHXtmuDh0K2KHNbOUiKUtk2OjvGwaLlG5u4D+clzuFpasOci6QgvjERTt Q9yT/chAu+VMLbA60nRMGvRyqeQtnAqO7r3ws=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Khh1ULKrGW4OdEIRYCaeqZmAbByVVY/3nRrXMHKEi56Tbc2tH/WR/44fbHEzAFb0qe gGOxuv0V/sPybD3kotpAg8qmMGncQSx/E1J6kqW3OdPAKPMZH2Aq+MPJaArekWWgUwE7 8Vui4t/+vfHKuXbQUOS3PEJbeDhdZtc07ufic=
- In-reply-to: <m3eid5sj32.fsf@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20100907114403.0e526e9c@xxxxxxxxxxxxxxxxxxxxxxxxx> <AANLkTinjkD7F53shp+vWZu01J-a48MxhbvFGpDrZshhC@xxxxxxxxxxxxxx> <20100907130231.49dcf737@xxxxxxxxxxxxxxxxxxxxxxxxx> <m3hbi1sjzm.fsf@xxxxxxxxxxxxxx> <20100907154418.479be919@xxxxxxxxxxxxxxxxxxxxxxxxx> <m3eid5sj32.fsf@xxxxxxxxxxxxxx>
On 7 September 2010 16:51, Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
>
> Wow that was fast! Seems to be working here, will continue to play
> with it..
I played with it a bit now, and came up with this
#the intent here is to insert syntax errors back on the command line, since
#those aren't saved in history, for example entering "do;"
function _zle_line_init() {
if [[ -n $ZLE_LINE_SAVED && $ZLE_LINE_SAVED[1] != " " &&
$ZLE_LINE_SAVED != $history[$((HISTCMD-1))] ]]; then
LBUFFER=$ZLE_LINE_SAVED
zle -R
fi
unset ZLE_LINE_SAVED
}
#like pws said, if we accept a line, we don't need the aborted one anymore
function _zle_line_finish() {
ZLE_LINE_SAVED=$BUFFER
unset ZLE_LINE_ABORTED
}
#this puts back the aborted line when you try to go up history, can be
bound to other
#things too but haven't got around to that yet (ie up-line-or-search).
should probably
#also check the current line is empty first too.
function _recover_line_or_else() {
if [[ -n $ZLE_LINE_SAVED ]]; then
LBUFFER+=$ZLE_LINE_SAVED
unset ZLE_LINE_SAVED
elif [[ -n $ZLE_LINE_ABORTED ]]; then
LBUFFER+=$ZLE_LINE_ABORTED
unset ZLE_LINE_ABORTED
else
zle .$WIDGET
fi
}
zle -N up-history _recover_line_or_else
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author