Summary: bug-fix release: fix minor bug which spammed the *Messages* buffer
< The undo-tree package is available from GNU [[ELPA]] in recent Emacsen. The latest "stable" version (version 0.6.2, released November 2012) can also be downloaded from:
> The undo-tree package is available from GNU [[ELPA]] in recent Emacsen. The latest "stable" version (version 0.6.3, released December 2012) can also be downloaded from:
Emacs has a powerful undo system. Unlike the standard undo/redo system in most software, it allows you to recover any past state of a buffer (whereas the standard undo/redo system can lose past states as soon as you redo). However, this power comes at a price: many people find Emacs’ undo system confusing and difficult to use, spawning a number of packages that replace it with the less powerful but more intuitive undo/redo system (see CategoryUndo).
Both the loss of data with standard undo/redo, and the confusion of Emacs’ undo, stem from trying to treat undo history as a linear sequence of changes. It’s not. The
undo-tree-mode provided by this package replaces Emacs’ undo system with a system that treats undo history as what it is: a branching tree of changes. This simple idea allows the more intuitive behaviour of the standard undo/redo system to be combined with the power of never losing any history. An added side bonus is that undo history can in some cases be stored more efficiently, allowing more changes to accumulate before Emacs starts discarding history.
It gets better. You don’t have to imagine the undo tree, because
undo-tree-mode includes an undo-tree visualizer which draws it for you, and lets you browse around the undo history. It also sports various other nifty features: persistent saving of undo history across sessions (only works with sufficiently recent Emacsen), storing and restoring past buffer states in registers, a diff view of the changes that will be made by undoing, and probably more besides.
The only downside to this more advanced yet simpler undo system is that it was inspired by Vim. But, after all, most successful religions steal the best ideas from their competitors!
For more information, see the Commentary at the top of the
The undo-tree package is available from GNU ELPA in recent Emacsen. The latest “stable” version (version 0.6.3, released December 2012) can also be downloaded from:
If you want to live on the bleeding edge, the latest “development” version can be found in a git repository located at:
This is a git repository, not a web page. You cannot view it in a web browser. To grab the latest development version, clone the repository using:
git clone http://www.dr-qubit.org/git/undo-tree.git
Please send bug reports and suggestions to email@example.com (you can post them here as well if you like, of course). I don’t check this page regularly, so anything not emailed to me is likely to languish here unnoticed for some time.
If you have code you would like to contribute to undo-tree, either send a patch against the latest development version to firstname.lastname@example.org, or better still, use git, rebase your work against the latest git master, and let me know where to find your clone of the undo-tree repository so that I can pull your changes.
Showing the undo-tree visualizer, with some undo states stored in registers, and the visualizer’s diff view:
Hi Toby! Long time no see ;) This is a very interesting package, at least from the viewpoint of cool factor. As someone who is kind of used to the standard undo (or undo/redo as some would call it) I wonder what the main benefits would be for me. Is there any real-world use cases in particular where this shines?
Nice to hear from you, Mathias!
The Commentary section at the top of the undo-tree.el package file discusses this at some length, and I recommend reading it. To sumarise briefly…
Emacs’ undo system is definitely not the standard impoverished undo/redo system used in lesser software, which loses history as soon as you “redo”. Emacs’ undo system instead treats undos as just another type of change that can be undone. So redoing becomes simply “undoing an undo”. This is very powerful, as it preserves the complete undo history. The disadvantage is that calling any command whilst in the middle of undoing multiple changes “breaks the undo chain”, and makes it a pain to get back to where you were. (You have to undo all the undos you just did, then undo all the changes you’d already undone before, and only then can you continue undoing from where you left off. If this sounds confusing, it’s because it is! For some people, at least.)
Undo-tree-mode instead treats undo history as what it is: a branching tree of changes. This preserves all the power of Emacs’ undo system vis-a-vis not losing any undo history. But it makes it substantially easier and more intuitive to undo and redo the changes you want (for some people, at least). Note that this matches the undo system that Vim has had for some time now. The undo-tree visualizer in the screenshot above is just the icing on the cake. The bigger thing is the fundamental change to how the undo system works.
Apparently quite a few people do find this useful. It’s by far the most popular of my Emacs packages.
Do read the Commentary for a more detailed discussion. It even has diagrams :)