Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Undo is also confused with narrow-to-region
- X-seq: zsh-workers 35737
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: Undo is also confused with narrow-to-region
- Date: Wed, 08 Jul 2015 16:57:33 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1436367454; bh=eZzORZnWDuIvo06vOQ6YCrpzwKpfmzcJr6d7jvGeu0E=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=V48b35EAsHKZIg9xcwDePstF0TXXie2noxp95MBVI2YRwVHOdHPg3jCCSb5tHyBD+lGhWziFv4rP6XwOIyuJ5RvXTkcD3cmU0Hpr0Bfyg+36VKB/mF7bSPI2YDn1XGlDSrnFO08MYU/LATjLS9Hw4fp+ERq3FBr7/uWlpUy+gM/s8QpjzBo3oqANjApkIIE80lD2bAoUUnZhytFxc1bW08FOFtrHDVV2A5ajHa/MCxB4nuV4OHGeqtYxnZuYZOch8irz+JhvJ7a48oPBfSFAWtkGs7wUG6RJdicV9EjGFmwO/L2W9ughhKXdnkgXOUdIQMcGAJHKz9foYP5AP6i/Sw==
- In-reply-to: <20150706202554.02d6c73a@ntlworld.com>
- 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: <8242.1435937191@thecus.kiddle.eu> <CAHYJk3T_a=TAjVr6e79x8bOh6u+vWO9aDXS=fNNHbm7XejLP_A@mail.gmail.com> <20150706093957.33d9cb25@pwslap01u.europe.root.pri> <4900.1436183185@thecus.kiddle.eu> <20150706202554.02d6c73a@ntlworld.com>
Peter wrote:
>
> The example I've given shows an explicit save and restore. It should
> also be possible to use the double function scope trick, though I didn't
> actually try.
>
> I haven't imposed any arbitrary limits on the value in UNDO_LIMIT_NO as,
> on thinking about it, it seemed to create hostages to fortune for no
> obvious gain.
Thanks. Trying to apply this in read-from-minibuffer, I found that it
was necessary to add a split-undo in after the BUFFER etc were setup,
otherwise it was possible to do one initial undo. Also, I wonder if the
if condition should do a return 1 rather than break so that it beeps -
consistently with an undo that has reached the very first change. Or is
the setlastline() call needed?
Oliver
diff --git a/Functions/Zle/read-from-minibuffer b/Functions/Zle/read-from-minibuffer
index 8fec110..2b96a36 100644
--- a/Functions/Zle/read-from-minibuffer
+++ b/Functions/Zle/read-from-minibuffer
@@ -20,7 +20,7 @@ done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
local readprompt="$1" lbuf_init="$2" rbuf_init="$3"
-integer changeno=$UNDO_CHANGE_NO
+integer savelim=$UNDO_LIMIT_NO changeno=$UNDO_CHANGE_NO
{
# Use anonymous function to make sure special values get restored,
@@ -43,6 +43,8 @@ integer changeno=$UNDO_CHANGE_NO
else
local NUMERIC
unset NUMERIC
+ zle split-undo
+ UNDO_LIMIT_NO=$UNDO_CHANGE_NO
zle recursive-edit -K main
stat=$?
(( stat )) || REPLY=$BUFFER
@@ -52,6 +54,7 @@ integer changeno=$UNDO_CHANGE_NO
# This removes the edits relating to the read from the undo history.
# These aren't useful once we get back to the main editing buffer.
zle undo $changeno
+ UNDO_LIMIT_NO=save_limit
}
return $stat
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 198c0ba..8b55403 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1587,7 +1587,7 @@ undo(char **args)
if (prev->changeno < last_change)
break;
if (prev->changeno < undo_limitno && !*args)
- break;
+ return 1;
if (unapplychange(prev))
curchange = prev;
else
Messages sorted by:
Reverse Date,
Date,
Thread,
Author