Compress/compact undo-tree history (and shut up)

This commit is contained in:
Henrik Lissner 2018-08-03 18:34:51 +02:00
parent b12944fddb
commit 261aa7c944
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -219,7 +219,31 @@ savehist file."
undo-tree-enable-undo-in-region nil
undo-tree-history-directory-alist
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
(global-undo-tree-mode +1))
(global-undo-tree-mode +1)
;; compress undo with xz
(advice-add #'undo-tree-make-history-save-file-name :filter-return
(cond ((executable-find "zstd") (lambda (file) (concat file ".zst")))
((executable-find "gzip") (lambda (file) (concat file ".gz")))))
(advice-add #'undo-tree-load-history :around #'doom*shut-up)
(defun doom*strip-text-properties-from-undo-history (orig-fn &rest args)
(dolist (item buffer-undo-list)
(and (consp item)
(stringp (car item))
(setcar item (substring-no-properties (car item)))))
(apply orig-fn args))
(advice-add 'undo-list-transfer-to-tree :around #'doom*strip-text-properties-from-undo-history)
(defun doom*compress-undo-tree-history (orig-fn &rest args)
(cl-letf* ((jka-compr-verbose nil)
(old-write-region (symbol-function #'write-region))
((symbol-function #'write-region)
(lambda (start end filename &optional append _visit &rest args)
(apply old-write-region start end filename append 0 args))))
(apply orig-fn args)))
(advice-add #'undo-tree-save-history :around #'doom*compress-undo-tree-history))
;;