From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@zsh.org>
Subject: Re: Undo is also confused with narrow-to-region
Date: Wed, 08 Jul 2015 16:57:33 +0200 [thread overview]
Message-ID: <17928.1436367453@thecus.kiddle.eu> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2015-07-08 15:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 15:26 Oliver Kiddle
2015-07-03 18:12 ` Mikael Magnusson
2015-07-06 8:39 ` Peter Stephenson
2015-07-06 11:46 ` Oliver Kiddle
2015-07-06 19:25 ` Peter Stephenson
2015-07-08 14:57 ` Oliver Kiddle [this message]
2015-07-09 18:32 ` Peter Stephenson
2015-07-10 9:34 ` Peter Stephenson
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=17928.1436367453@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--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).