emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: disabling undo boundaries


From: Stefan Monnier
Subject: Re: disabling undo boundaries
Date: Thu, 21 May 2015 11:44:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> Yes, you are right, the second buffer is an issue, although I am not
> convinced that the behaviour is worse.

Worse than the ideal or worse than the current one?
Right now, I'm trying to understand what the ideal behavior should be.

After that, we can try to figure out how to get this ideal behavior, or
how close we can get to it, and which part of the work can be made
generic in undo.c and which part of the work has to be done manually by
each and every particular command/package.

> ** Conclusion
> All of the insertion events have been amalgamated, so the undo is much
> too "lumpy".  Again, I can add this logic in, but I have to duplicate
> the "add an undo-boundary after a command" logic from the
> command loop.

[ You only used self-insert-command in your examples, which gives
  a slightly twisted view of what's going on in general.  ]

But ideally, we could have undo.c do most of that for you.
E.g. instead of adding a boundary every time we switch buffer, undo.c
could simply keep track of which buffers have seen changes during the
current command, and then push undo-boundaries on all of them at the end
of the command.

Except for self-insert-command, I think this would give you the ideal
behavior (without any manual work on your side) *and* it would mostly
preserve the existing behavior.

For self-insert-command, it's more tricky, and you'd probably need to do
the extra manual work.  E.g. add a post-self-insert-hook which checks if
this self-insert-command removed the previous undo-boundary and then
remove it as well in the sibling buffer.  I can't see how undo.c could
do that for you magically, since it doesn't know that the insertions in
the sibling buffer are "clones" of the insertions in the main buffer,
nor that it's done by self-insert-command.  Another approach would be
for you to arrange such that your a-f-c uses self-insert-command rather
than `insert' when cloning the insertion from a self-insert-command, but
that's probably just as hard if not harder.



        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]