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

From: Óscar Fuentes <[email-masked]>
Date: Thu, 14 Aug 2025 18:57:39 +0200

Gerd Möllmann <[email-masked]> writes:

* src/undo.c (truncate_undo_list): Use undo_group_limit.
(syms_of_undo): Add DEFVAR_INT.

[snip]

Thank you for the detailed explanation. I'm running it now on one of the
two machines that I use daily. Apart from reporting obvious problems, do
you want other info that requires inspecting buffer-undo-list or
anything else from time to time?

BTW, saying "No one would do 1000 undos" sounds very sensible. But on
some circunstances I've seen how almost every character produced an undo
boundary (time ago with Evil, now it seems better.) Also, some packages
allow you to navigate the undo history on a way that is easy to restore
the state of the buffer when its content's met certain criteria, like
some text was added or removed, which could happened long time ago on
the session. Having a limit of 200 (or 2000) undo steps may be
constraining for the users of those packages. Also, it would be
interesting to see how much memory the average undo step consumes
(without the pathological marker adjustment elements.) That way we could
know if your change is significantly reducing the amount of undo info
that Emacs traditionally stored.

While writing this e-mail the associated buffer-undo-list grew to 6000+
elements, almost all of them marker adjustments. Executing igc-collect
made no difference, but IIUC this is expected, the effects of your patch
should begin after exceeding undo-group-limit. While writing English
prose I make *lots* of corrections, maybe that's one of the main reasons
why the problem affects me on a larger way.

Just before finishing this e-mail, buffer-undo-list went down to 3000+
elements, almost all of them markers.