undo-propose.el is a package for navigating through your undo history in a temporary buffer.
Emacs treats previous undo’s as ordinary changes that can themselves be undone, making it possible to revisit any point in your edit history. However, it’s easy to get turned around when moving through a chain of undo’s, undo’s of undo’s, and so forth, as the same edit will be traversed multiple times backwards and forwards. On top of that, trying to find an old edit can add many undo’s to the edit history, making the undo ring longer and more difficult to navigate later on.
undo-propose addresses this by letting you undo inside a temporary buffer. This has a few benefits:
- If you get lost, you can cancel the whole series of undo’s, without modifying the original buffer or undo history.
- The series of undo’s gets added as a single edit event, which makes the undo history simpler; you don’t have to individually redo each undo later on.
- You can search through your undo history for old snippets, and copy and paste them back in, without having to add many extra undo’s in your undo ring.
undo-propose is available on MELPA.
To use undo-propose, call
M-x undo-propose in the buffer you are editing. This will send you to a new temporary buffer, which is read-only except for allowing
undo commands. Cycle through the list of undo’s as normal. When you are finished, type
C-c C-c to add the chain of undo’s as a single edit to the undo history. To cancel, type
C-c C-k. You can also ediff the proposed chain of undo’s by typing
In the following gif, I enter some text, call
undo-propose, do a sequence of undo’s and redo’s within the
undo-propose buffer, compare against the original buffer with
ediff, commit the sequence of undo’s, and finally undo (redo) the change made by
See undo-tree for a more powerful undo navigation system. Unfortunately, many users experience corruption issues, leading to lost work (for example, see https://github.com/emacs-evil/evil/issues/1074 and http://ergoemacs.org/emacs/emacs_best_redo_mode.html).
In contrast, undo-propose is much smaller, and meant to complement native emacs’ undo rather than replace it. It tries to minimize direct interaction with undo internals, in order to reduce the likelihood of bugs that corrupt the undo history.