Subject: Re: undo-only bugs

From: Stefan Monnier <[email-masked]>
Date: Thu, 15 May 2014 09:00:24 -0400

>> If anything should be done with it, I think it'd be to *cut* the
>> extra undo/redo pairs.
> No complaint from me.   That would change the behavior of ordinary undo
> command,

Yes.  And I think that's what we want: as a user, having to wade through
N repetitions of redo/undo is a pain.  Those that suffer often from it
probably switched to undo-tree.

The idea of cutting the extra undo-redo pairs follows the following
principle: an undo-redo pair gives you access to 1 past buffer state,
but if the earlier undo elements already made you go through an
identical state, then this undo-redo pair is superfluous.

I'm sure this can be generalized for undo-in-region (where an undo-redo
pair may not bring you exactly to the same state, but still gives you
access to a change you've already seen earlier in the undo list), but
I'm sure you can define it more easily than I.

> which you just said you don't want to change.

So far there was no discussion of changing behavior: only fixing bugs
and changing implementation.

>> I'm not completely convinced that this generator is worthwhile
> Ok, I'll lose it then.

We may want to (re)introduce it later, tho.

>>> I originally set out to do this, but making the weak references
>>> work seemed overly tricky to me. The value stored in
>>> undo-redo-table would need to be non weak with weak references to
>>> undo elements. I supposed this would mean many one element weak
>>> hash tables. That seems dodgy.
>> Hmm... that's a very good point. Worth mentioning in a comment.
> You actually want me to do that? That is: wrap every referenced
> element in a size 1 weak hash table.

God no!  I'm saying that I agree with your justification for the design of
undo-redo-table keeping mappings for every undo-element rather than one
per undo group; but that you need to put a comment in the code
explaining why it's done this way.

        Stefan