all repos — nixfiles @ a6c3b48a7bac0b52778a39d95f04a5f6d3ac84ba

System and user configuration, managed by nix and home-manager

Emacs: optimise GC during minibuffer usage
Alan Pearce alan@alanpearce.eu
Mon, 02 Mar 2020 15:39:51 +0100
commit

a6c3b48a7bac0b52778a39d95f04a5f6d3ac84ba

parent

018c4cbf631cb86b765c6ef40dd33c94105d5e0a

1 files changed, 8 insertions(+), 5 deletions(-)

jump to
M user/emacs/.emacs.d/init.eluser/emacs/.emacs.d/init.el
@@ -7,11 +7,14 @@ package-enable-at-startup nil       evil-want-keybinding nil
       frame-inhibit-implied-resize t)
 
-(setq gc-cons-threshold most-positive-fixnum
-      gc-cons-percentage 0.6)
-(add-hook 'after-init-hook (lambda ()
-                             (setq gc-cons-threshold (* 16 1024 1024)
-                                   gc-cons-percentage 0.1)))
+(let ((default-gc-cons-threshold (* 16 1024 1024)))
+  (setq gc-cons-threshold most-positive-fixnum
+        gc-cons-percentage 0.6)
+  (add-hook 'minibuffer-setup-hook (lambda () (setq gc-cons-threshold most-positive-fixnum)))
+  (add-hook 'minibuffer-exit-hook (lambda () (setq gc-cons-threshold default-gc-cons-threshold)))
+  (add-hook 'after-init-hook (lambda ()
+                               (setq gc-cons-threshold default-gc-cons-threshold
+                                     gc-cons-percentage 0.1))))
 
 (package-initialize)