UNDO: Fix lag when doing C-/ (undo/undo-tree-undo)
undo-tree-undo calls undo-list-transfer-to-tree internally which does a lot of garbage-collect calls to make sure the GC won't run (to counter race conditions or something) So, define a hook that sets the GC threshold to maximum, does the undo (which should go fast now since the GC won't run), then restore the old GC threshold
This commit is contained in:
parent
4724e18f76
commit
673996444f
1 changed files with 20 additions and 0 deletions
20
config.org
20
config.org
|
|
@ -522,12 +522,32 @@ Some basic C-coding settings (style, indentation offset, ...).
|
||||||
* Undo-tree
|
* Undo-tree
|
||||||
|
|
||||||
Undo with =C-/=.
|
Undo with =C-/=.
|
||||||
|
|
||||||
|
The reason for the hook:
|
||||||
|
I had a lot of issues with undo lagging (taking literally seconds to complete...).
|
||||||
|
undo-tree-undo calls undo-list-transfer-to-tree internally which does
|
||||||
|
a lot of garbage-collect calls to make sure the GC won't run (to counter race
|
||||||
|
conditions where the GC would corrupt the undo-tree or something).
|
||||||
|
|
||||||
|
So, define a hook that sets the GC threshold to maximum,
|
||||||
|
does the undo (which should go fast now since the GC won't run)
|
||||||
|
and then restore the old GC threshold.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package undo-tree
|
(use-package undo-tree
|
||||||
:ensure t
|
:ensure t
|
||||||
:config
|
:config
|
||||||
(global-undo-tree-mode)
|
(global-undo-tree-mode)
|
||||||
|
(define-key undo-tree-map (kbd "C-/") 'undo-hook)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defun undo-hook (&optional arg)
|
||||||
|
(interactive)
|
||||||
|
(setq gc-cons-threshold most-positive-fixnum)
|
||||||
|
(undo-tree-undo arg)
|
||||||
|
(setq gc-cons-threshold 800000)
|
||||||
|
)
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Volatile highlights
|
* Volatile highlights
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue