Ignacio Casso <ignacioca...@hotmail.com> writes: >>> + (setq buffer-undo-list >>> + (seq-drop-while 'identity buffer-undo-list))))))) >> >> This looks fragile and can be disasterous when buffer-undo-list is >> large. > > I agree that it is very fragile, but could you explain why is it also > problematic with a large `buffer-undo-list'? I guess you mean > efficiency-wise, but it would only iterate through the few items added > since the call to (undo-boundary). Is there something else I'm not seeing?
Simply because I saw iteration over a potentially large list. Looking closer, you are indeed right and performance should not be a problem in this particular scenario. >> Maybe just use with-silent-modifications or some ideas from there (for >> example, wrapping modifications inside let-bound (buffer-undo-list t))? >> We should not inhibit modification hooks though. Otherwise, it will mess >> up with caching code. > > Done. I attach the new patch: LGTM! Applied onto main via aa789b89d. Best, Ihor