Subject: bug#16411: undo-only bugs

From: Stefan Monnier <[email-masked]>
Date: Sat, 18 Jan 2014 22:18:54 -0500

> Where:
>   • delta, beg, end are as documented.
>   • undo-redo is a new function that copies undone-element, applies
>     undo-delta, then calls primitive-undo on it.
>   • undone-element is the undone element of buffer-undo-list.
>   • undo-delta is (position . offset) indicating how undo-redo should
>     modify a copy of undone-element in order to carry out the redo.

> When executing undo-only:
>   • Assume pending-undo-list can be lazily computed
>   • Let undo-skip-set be an empty set of undo elements to skip
>   • Iterate over pending-undo-list until prefix-arg undos complete:
>     • If the element is in undo-skip-set:
>       • Remove it from undo-skip-set
>       • Continue loop
>     • If the element is of the form for a redo element:
>       • Insert its undone-element in the undo-skip-set
>     • Else undo the element

In which way would this help fixing bug 2 (I thought we had already
understood how to fix bug 2, BTW)?

More problematic: the step "Insert its undone-element in the
undo-skip-set" means that we skip this "redo" element, which means that
all the subsequent elements (until the matching undone-element) may have
incorrect buffer positions.

Luckily, you probably won't bump into any problem because all these
intermediate elements will themselves be redo elements or be in
undo-skip-set.  But it's still dangerous and wasteful (why not skip all
these elements in one swoop as we currently do with undo-equiv-table).

        Stefan