GNU bug report logs - #79200
31.0.50; Duplicated elements for '#<marker at' in buffer-undo-list

Previous Next

Package: emacs;

Reported by: Óscar Fuentes <oscarfv <at> eclipso.eu>

Date: Fri, 8 Aug 2025 16:45:03 UTC

Severity: normal

Found in version 31.0.50

Full log


Message #56 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Óscar Fuentes <oscarfv <at> eclipso.eu>,
 Pip Cet <pipcet <at> protonmail.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 79200 <at> debbugs.gnu.org
Subject: Re: bug#79200: 31.0.50; Duplicated elements for '#<marker at' in
 buffer-undo-list
Date: Sat, 09 Aug 2025 12:18:15 +0200
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text
> editors" <bug-gnu-emacs <at> gnu.org> writes:
>
>> Well, compact_undo_list is a nop with HAVE_MPS:
>>
>> static Lisp_Object
>> compact_undo_list (Lisp_Object list)
>> {
>> #ifndef HAVE_MPS
>>   Lisp_Object tail, *prev = &list;
>>
>>   for (tail = list; CONSP (tail); tail = XCDR (tail))
>>     {
>>       if (CONSP (XCAR (tail))
>> 	  && MARKERP (XCAR (XCAR (tail)))
>> 	  && !vectorlike_marked_p (&XMARKER (XCAR (XCAR (tail)))->header))
>> 	*prev = XCDR (tail);
>>       else
>> 	prev = xcdr_addr (tail);
>>     }
>> #endif
>>   return list;
>> }
>>
>> We still truncate undo lists, but we don't "compact" them, i.e. treat
>> them as weak structures and remove markers that are referred to only in
>> undo lists. Correct?
>
> I think you are correct. buffer_step -> compact_buffer ->
> truncate_undo_list, but no compact.
>
>> The "obvious" fix would be to use a weak hash table to associate undo
>> information with markers rather than keeping them in the undo
>> list. However, that sounds quite hard to do, and it might make undo a
>> lot more expensive.
>
> Hm, yes that sounds hard. Hm.
>
> Do you think we could, in compact, locally keep track of markers already
> seen, and coalesce their entries somehow? My memory of the undo stuff is
> pretty hazy, alas, and probably outdated, too.

This is in primtive-undo for markers

simple.el:
 3758              ;; Adjust the valid marker adjustments
 3759              (dolist (adj valid-marker-adjustments)
 3760                ;; Insert might have invalidated some of the markers
 3761                ;; via modification hooks.  Update only the currently
 3762                ;; valid ones (bug#25599).
 3763                (if (marker-buffer (car adj))
 3764                    (set-marker (car adj)
 3765                                (- (car adj) (cdr adj)))))))

So, it would seem that one could do that. Famous last words :-).




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.