Bring back undo history compression

But only if zstd is available. Also strips text properties from the undo
list. This often provides a 30-50% size benefit, with a negligible
performance impact.
This commit is contained in:
Henrik Lissner 2019-05-13 14:31:49 -04:00
parent 3399580647
commit 646cba3f68
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -263,6 +263,20 @@ savehist file."
undo-tree-enable-undo-in-region nil
undo-tree-history-directory-alist
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
(when (executable-find "zstd")
(defun doom*undo-tree-make-history-save-file-name (file)
(concat file ".zst"))
(advice-add #'undo-tree-make-history-save-file-name :filter-return
#'doom*undo-tree-make-history-save-file-name))
(defun doom*strip-text-properties-from-undo-history (&rest _)
(dolist (item buffer-undo-list)
(and (consp item)
(stringp (car item))
(setcar item (substring-no-properties (car item))))))
(advice-add #'undo-list-transfer-to-tree :before #'doom*strip-text-properties-from-undo-history)
(global-undo-tree-mode +1))