bug#81286: [PATCH] Support undo-in-region for 'apply entries

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]> Thu, 06 Aug 2026 17:05:39 -0400
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> I pushed a branch scratch/undo-apply which does this.  See the attached
> patch.

Looks OK to me.

In `combine-change-calls-1` I think the test (/= beg-delta end-delta)
shouldn't signal "Not yet implemented" but some other error that points
the finger at the undo code: I can't imagine how this could ever
be meaningful.  An alternative is to skip the `orig-end`.

> One issue that came up is: If the undo-list looks like
>
>   ((apply 0 (1 . 10) foo)
>    (5 . 6))
>
> and the active region is (2 . 8).  Then the apply entry is ignored
> (because it's outside of the active region) but the second entry is
> applied (because it's inside the active region).

That's a bug, indeed.  The apply entry is not "outside of the active
region" but instead covers it.  So we can either include the apply entry
in the filtered list (i.e. implicitly extend the
bounds) or not, but if we don't include it, it should be the end of the
filtered list, like when we bump into an insertion `(1 . 10)`.


=== Stefan