Possibly restore undo persistence
This commit is contained in:
parent
1d961563c0
commit
8edba65504
1 changed files with 21 additions and 1 deletions
|
@ -205,12 +205,32 @@ fundamental-mode) for performance sake."
|
||||||
(def-package! undo-tree
|
(def-package! undo-tree
|
||||||
:demand t
|
:demand t
|
||||||
:config
|
:config
|
||||||
|
(global-undo-tree-mode +1)
|
||||||
|
|
||||||
;; persistent undo history is known to cause undo history corruption, which
|
;; persistent undo history is known to cause undo history corruption, which
|
||||||
;; can be very destructive! So disable it!
|
;; can be very destructive! So disable it!
|
||||||
(setq undo-tree-auto-save-history nil
|
(setq undo-tree-auto-save-history t
|
||||||
undo-tree-history-directory-alist
|
undo-tree-history-directory-alist
|
||||||
(list (cons "." (concat doom-cache-dir "undo-tree-hist/"))))
|
(list (cons "." (concat doom-cache-dir "undo-tree-hist/"))))
|
||||||
|
|
||||||
|
(defun doom|save-undo-history ()
|
||||||
|
(when (and (bound-and-true-p undo-tree-mode)
|
||||||
|
buffer-file-name
|
||||||
|
(file-writable-p buffer-file-name)
|
||||||
|
(not (eq buffer-undo-list t))
|
||||||
|
(not revert-buffer-in-progress-p))
|
||||||
|
(quiet!
|
||||||
|
(undo-tree-save-history nil t))))
|
||||||
|
|
||||||
|
(defun doom|save-all-undo-history ()
|
||||||
|
(dolist (buffer (buffer-list))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(doom|save-undo-history))))
|
||||||
|
|
||||||
|
(remove-hook 'write-file-functions #'undo-tree-save-history-hook)
|
||||||
|
(add-hook 'kill-emacs-hook #'doom|save-all-undo-history)
|
||||||
|
(add-hook 'kill-buffer-hook #'doom|save-undo-history)
|
||||||
|
|
||||||
(defun doom*silence-undo-tree-load (orig-fn &rest args)
|
(defun doom*silence-undo-tree-load (orig-fn &rest args)
|
||||||
"Silence undo-tree load errors."
|
"Silence undo-tree load errors."
|
||||||
(quiet! (apply orig-fn args)))
|
(quiet! (apply orig-fn args)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue