Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Undo is also confused with narrow-to-region



On Fri, 3 Jul 2015 20:12:13 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On Fri, Jul 3, 2015 at 5:26 PM, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> > Within narrow-to-region, undo will put back the full BUFFER that is then
> > duplicated from PREDISPLAY/POSTDISPLAY. After narrow-to-region, the
> > opposite problem occurs with the part that was not part of the BUFFER
> > being lost.
> >
> > This isn't that easy to solve. recursive-edit could save and restore the
> > undo structures but for some uses of recursive-edit, such as that shown
> > for it in the manual, that might not be the right thing anyway.
> 
> Would it be possible to implement some kind of 'zle push-undo-stack'
> and 'zle pop-undo-stack'? If you push it you would get a whole new
> instance of undo, and popping it then throws all those entries away
> again. I can't really think of an instance outside recursive-edit
> where it would be useful, though.

You can already basically do this: see read-from-minibuffer.

integer changeno=$UNDO_CHANGE_NO

remembers the current undo (the undo numbers are unique up to integer
wrap, which isn't supposed to happen unless you're editing infinite
numbers of editions of Shakespeare using monkeys).

zle undo $changeno

then winds the undos back to that point.

pws



Messages sorted by: Reverse Date, Date, Thread, Author