Emacs: Undo/Redo Saga

By Xah Lee. Date: . Last updated: .

To redo, press Ctrl+g then do a undo Ctrl+_. Further undo will all be redo. Press Ctrl+g to reverse direction again.

Emacs Undo/Redo Packages up to 2011

There are a few packages for redo. Of the ones i've used are:

The redo.el works ok, but occasionally it corrupts your undo, meaning that you know there's more undo/redo but wasn't able to get to it. This happens perhaps once a month.

The redo+.el is supposed to update/modernize the code. Unfortunately, i didn't have luck with it. These Kyle based redo modes are ~200 lines of elisp, each.

The undo-tree.el i installed in 2011 and stopped using it around 2015. It also has corruption problem.

Undo/Redo Corruption Problem

After using about 3 or 4 redo packages for 10 years, i gave them all up. They all have corruption problem. (i stopped using any undo/redo package since about 2015.)

When a corruption happens, it's really nasty. You undo but got a surprise that there's no undo (because the package bug). It's like losing your work. (e.g. When you move chucks of text between buffers, or, just did lots of experimental stuff, expecting you can go back by undo.)

So, now i don't use any undo/redo package, just plain emacs, and like it.

in plain emacs, to redo, just press Ctrl+g first then undo. Further undo will be redo. Press Ctrl+g again to reverse direction. If you are careful, one can avoid the undo/redo roller-coaster confusion.

2018-03-20 reddit discussion https://www.reddit.com/r/emacs/comments/85t95p/undo_tree_unrecognized_entry_in_undo_list/dw0bqvv/

See also: Emacs Undo and Emacs Cult Problem

redo-fu package

redo-fu, a new emacs redo package since 2019-12-04, by Campbell Barton (aka ideasman42), written specifically to avoid undo corruption problem.


XahTV 2021-03-27 Emacs Undo Drama, Emacs Lore, Lisp Warr, rms, and Who's Who in Gnu Emacs

emacs undo saga

following is from ideasman42, author of emacs undo-fu:

Regarding some of the undo discussion here:

  • Agree undo-tree post is not especially helpful, of course maybe in some technical sense it's not a bug in undo-tree, whatever - users run into bugs when using undo-tree that's a problem.
  • Undo-tree bug is NOT fixed, although there has been some investigation on this and progress. See thread for details: https://github.com/emacs-evil/evil/issues/1074#issuecomment-768653730 . TL;DR it turns out evil-mode does some undo data manipulation that undo-tree doesn't support. ... personally I think undo-tree logic is too complex to be relied on.
  • emacs28 doesn't include undo-fu, it just has similar functionality - a new command undo-redo which over ever redoes. See the commit: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=2645ae1222db1df270276b227e5102884466ecb0
  • undo-fu still has a few additional features - mainly the ability to easily access emacs full non-linear history, so in the rare cases you need access to some branch of a past state - you can always traverse the full tree.

One other thing, there is work on an undo visualization tool that represents undo data as a tree - working with emacs default undo: https://www.reddit.com/r/emacs/comments/m7bgjt/visualizer_for_emacs_native_undo ... so people who want tree navigation could get it, without having to buy into a complicated package that manipulates their undo data in a non-standard way.

Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial