Eli Zaretskii writes: >> From: Markus Triska >> Cc: Eli Zaretskii , 23871@debbugs.gnu.org >> Date: Fri, 01 Jul 2016 08:31:10 +0200 >> >> phillip.lord@russet.org.uk (Phillip Lord) writes: >> >> > I believe the following patch fixes #21722. >> >> I tried it, and can still reproduce both #21722 and #23871 also with the >> patch applied to the current emacs-25 branch. > > Which doesn't surprise me, since point is at the insertion position > just before the insertion, which is when record_insert is called, > AFAIU. > > I think the question here is why does undo record the position of > point at the end of the sexp, and not where point was when C-M-x was > invoked. It doesn't record point at all. It doesn't end up at the end of the sexp, rather at the beginning of the insertion (which happen to be the same place). > This has something to do with code that runs off C-M-x, I presume. I think it's because I forgot to call record_point when calling record_insert. The patch I sent yesterday put that back, but did it wrong. The following patch (attempts) to address the issue which is, unfortunately, a bit more extensive than the last.