Compress/compact undo-tree history (and shut up)
This commit is contained in:
parent
b12944fddb
commit
261aa7c944
1 changed files with 25 additions and 1 deletions
|
@ -219,7 +219,31 @@ savehist file."
|
||||||
undo-tree-enable-undo-in-region nil
|
undo-tree-enable-undo-in-region nil
|
||||||
undo-tree-history-directory-alist
|
undo-tree-history-directory-alist
|
||||||
`(("." . ,(concat doom-cache-dir "undo-tree-hist/"))))
|
`(("." . ,(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))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue