>> Patch attached. > > Hmm... scary, even if this is intended for the master branch. Could you > at least keep the few comments which were in the original code, and > perhaps also add comments explaining all those tricky tests with consp, > equality to t and to old-bul, the significance of (car ptr) and (caar > ptr), etc.? This would make the code more maintainer-friendly, as the > need to constantly consult the spec of the various undo-list elements > (and hope the spec is complete and accurate ;-) would be avoided. > Is the attached patch better in that respect? > > I'd prefer to fix this in Emacs 29 if feasible, but unless the changes > are much simpler and/or more clearly documented, so that it becomes > possible to assess their risks, I don't see how that could happen. > I don't see how the changes could be made simpler, sorry, but now they are documented. Feel free to ask further questions if something is still unclear. > > I presume that all the undo tests we have still pass? > They do. > > If so, how about adding a test for this bug? > I'll see if I can do that, but it seems tricky.