I use undo-tree mode in my emacs setup. Every once in a while, after writing a lot of text, I accidentally undo changes while I have some region selected. I am not 100% sure what undo-tree is doing and this is not 100% reproducible but there is high chance that this completely messes up my text. If I visualize the undo-tree I see a linear path but I cannot go up the tree even a single node (emacs just hangs).

Any idea why this is happening? I suspect that undo-tree is trying to undo the changes in the selected text as opposed to the whole buffer. If that's the case, can I disable this behavior?


To disable undo/redo-in-region as to the library undo-tree, set the variable undo-tree-enable-undo-in-region to nil:

(setq undo-tree-enable-undo-in-region nil)

The doc-string for the variable states:

When non-nil, enable undo-in-region.
When undo-in-region is enabled, undoing or redoing when the
region is active (in `transient-mark-mode') or with a prefix
argument (not in `transient-mark-mode') only undoes changes
within the current region."

The author of undo-tree (Dr. Toby Cubitt) admits that undo/redo-in-region has always been buggy and difficult to debug. He suggests disabling undo/redo in region until he has free time at some point in the future to work on this library again. To read about the most common bug with undo-in region, see the following two bug reports:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.