Subject: bug#79200: 31.0.50; Duplicated elements for '#<marker at' in buffer-undo-list

From: Helmut Eller <[email-masked]>
Date: Tue, 12 Aug 2025 10:48:08 +0200

On Tue, Aug 12 2025, Gerd Möllmann wrote:

[...]
>> For a time we had weak-ref Lisp objects.  I suppose putting such
>> weak-refs in the undo list would still break some code.  Instead of
>> weak-refs one could also use another layer of indirection, e.g. put a
>> fixnum in the undo list and the fixnum is a key in a weak hashtable that
>> holds markers weakly.
>
> Yes. Or one could give markers a unique integer id, store that instead
> of the marker itself in the marker adjustment entries. Then,
> primitive-undo could iterate over the buffer's markers and only do
> something for those markers it has an id entry for.
>
> If that would work, we wouldn't need to employ weakness, which I think
> might be a win. It's of course fiddly again. How to find all places
> relying on the fact that markers are in the entries, with some
> certainty?

Maybe we could create a new kind of entry, e.g

  (adjust-marker MARKER-ID ADJUSTMENT)

instead of (MARKER . ADJUSTMENT).  Or create (apply FUN . ARGS).

> What breakage are you thinking of?

Code in the wild that is inspecting the undo list.

>> Even better would be if we could put positions instead of markers in the
>> undo list.  After undoing, positions should be correct again; in an
>> ideal world anyway.
>
> After Stef reminded me: All markers in the deleted range get the same
> position (ignoring details) after the deletion, so I think a position
> alone wouldn't suffice. 

Ah, I see.

Helmut