Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to have Emacs save your undo history between sessions?

Tags:

emacs

Is there any way to have EMACS save your undo history between sessions?

I'm aware of the savehist lib, the saveplace lib, the desktop lib, and the windows lib, these all provide some session control but none seem to save the undo history.

like image 844
math0ne Avatar asked Jun 06 '10 17:06

math0ne


2 Answers

From version 0.4 onwards, undo-tree supports persistent storage of undo-tree data between sessions "out of the box". (Note that there are significant bug-fixes related to this feature in more recent versions; the latest version at the time of writing is 0.6.3.)

Simply enable the undo-tree-auto-save-history customization option to automatically save and load undo history in undo-tree buffers. Or use the undo-tree-save/load-history commands to save and load undo history manually.

You need at least Emacs version 24.3 for this to work reliably, but with a recent enough Emacs it works very well.

like image 133
Toby Cubitt Avatar answered Oct 07 '22 22:10

Toby Cubitt


Add the following to your .emacs file :

(global-undo-tree-mode) (setq undo-tree-auto-save-history t) (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))) 

Explanation

  • (global-undo-tree-mode) enables undo tree.

  • (setq undo-tree-auto-save-history t) enables auto save of undo history.

  • (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))) so that your project does not get littered with undo-history savefiles.

like image 38
meain Avatar answered Oct 07 '22 20:10

meain