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

From: Gerd Möllmann <[email-masked]>
Date: Thu, 14 Aug 2025 13:05:00 +0200

Alan Mackenzie <[email-masked]> writes:

> I more wonder why those limits are so low.  It's a long time since PCs'
> RAM capacity was measured in mere megabytes.

That, and then the fact that I can produce very long undo list, as long
as they don't exceed the size in bytes limits. And these lists can
contain a lot of markers.

(defun my-test-undo-list ()
  (interactive)
  (with-current-buffer (get-buffer-create "undo-list-test.txt")
    (erase-buffer)
    (setf buffer-undo-list nil)
    (dotimes (i 1000)
      (dotimes (j 10)
	(insert "abcd")
	(dotimes (i 5) (point-marker))
	(backward-delete-char 1)
	(undo-boundary)
	(insert "\n")))
    '(igc-collect)
    (message "undo-list length %d (%d)" (length buffer-undo-list) n-compacted)
    '(kill-buffer (current-buffer))))

The above produces an undo list with length 80000.

I think it might make sense to limit that to some reasonable number.