Compress/compact undo-tree history (and shut up)
This commit is contained in:
parent
b12944fddb
commit
261aa7c944
|
@ -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))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue
Block a user