0

I wanted to know if undo-tree has a feature that saves the undo-tree of a file, and automatically restore it when opened in another session.
I went to the undo-tree doc page, and of course the feature exists, it is called undo-tree-auto-save-history.

My questions are: How should I modify my init.el file in order to have the feature enabled for all kinds of files ? And is it going to auto-restore the undo-tree when opening a file ?

1

Emacs is self-documenting in the sense that public variables functions and macros have documentation strings.

You get this string for undo-tree-auto-save-history by typing C-h v undo-tree-auto-save-history RET.

Your question

And is it going to auto-restore the undo-tree when opening a file ?

is answered in the doc-string:

When non-nil, `undo-tree-mode' will save undo history to file when a buffer is saved to file.

It will automatically load undo history when a buffer is loaded from file, if an undo save file exists.

By default, undo-tree history is saved to a file called "..~undo-tree~" in the same directory as the file itself. To save under a different directory, customize `undo-tree-history-directory-alist' (see the documentation for that variable for details).

Two possibilities to adjust that behavior:

  1. Customize the variable undo-tree-auto-save-history with M-x customize-option RET undo-tree-auto-save-history RET. Note that TAB-completion works.
  2. Insert (setq undo-tree-auto-save-history t) in your init file.
  • Ok, the save works fine now :-), it just gives an error upon load (Error reading undo-tree history from "/home/mraynal/Desktop/.test.py.~undo-tree~") – m.raynal Jul 9 at 12:27

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.