Undo Tree

about | blog | config | notes | github

1. Visualize The Undo Tree

undo-tree provides a simple interface to visualize and traverse the GNU/Emacs undo tree.

2. Configuration

2.1. Package Install

Install undo-tree like any other package.

(use-package undo-tree)

2.2. Initialize the Tree


2.3. Improve Tree Visuals

Let's make sure by default when we see the tree, we also see the diff of each node.

(setq  undo-tree-visualizer-diff t)

Let's also see the timestamps of when the change was made

(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-relative-timestamps nil)

2.4. Autosave Undo History

We can confiure undo-tree to save the undo history to a file so that it can be persistant over sessions. By default undo-tree will attempt to save the history file alongside the file in question. This is messy so let's save it elsewhere as well like the ~/.cache folder.

(setq undo-tree-auto-save-history t)
(setq undo-tree-history-directory-alist '(("." . "~/.cache/undo-tree/")))

2.5. Feature Provide

(provide 'init-undo-tree)

Created: 2021-11-13

Emacs 26.1 (Org mode 9.5)