In a shell window, make a backup of your files (now), including the autosave files.
After backup. You can probably copy the autosave file over the empty file.
However, and this is very important, make a backup, before you start trying to fix it.
Then when all is good (or not), you need to create a backup strategy, for all of your important data.
(advice-add #'undo-tree :filter-return #'undo-tree-advice-history-save-file-name)
This advises the function undo-tree, whereas the defadvice form advises undo-tree-make-history-save-file-name. The equivalent advice-add would be
(advice-add 'undo-tree-make-history-save-file-name :filter-return #'undo-tree-advice-history-save-file-name)
I like to do two things with undo. I turn off the amalgamation stuff (which by doing so permits undo one keystroke at a time); and, I get rid of the timer (because timers affect performance and drive me absolutely bonkers, unless they are idle-timers).
(when (timerp undo-auto-current-boundary-timer)
There are two (2) likely suspects:
I. undo-tree-enable-undo-in-region is at its default non-nil setting and the O.P. has an active region; i.e., there are no more available undos in that active region. In such a case, try:
(setq undo-tree-enable-undo-in-region nil)
The above-mentioned setting will also avoid the O.P. encountering a different long-...
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.
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-...
To avoid performance issues, it is not recommended to run undo-tree-update-visualization-buffer on the post-command-hook -- thus, here we use run-with-idle-timer instead. To try this out, place undo-tree.el/elc in the load-path, then paste the following code in a *scratch* buffer and type M-x eval-buffer
This is a problem with undo-tree. At the time of this writing there is no workaround nor a fix on the horizon. The last update to the package was August 8, 2013. Apparently no one has a reliable way to even reproduce the problem.
To quote a related SE post:
The author of undo-tree.el, Toby Cubitt, is presently too busy to fix
this particular bug. ...