From 897d7ac91519a19f981c3bfc730cfa568ec2ce88 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Mon, 31 Dec 2018 11:51:50 -0500 Subject: [PATCH] Wrap startup optimizations --- emacs.d/init.el | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/emacs.d/init.el b/emacs.d/init.el index 7b68a78..b7fa3b6 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -2,31 +2,30 @@ ;; The below will increase the GC limits and remove the file name regex checker ;; for 5 seconds. This helps reduce the number of GC calls and the total time spent ;; per file loaded - -;; Set garbage collection threshold -;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ -(setq gc-cons-threshold-original gc-cons-threshold - gc-cons-percentage-original gc-cons-percentage) -(setq gc-cons-threshold (* 1024 1024 100) - gc-cons-percentage 0.6) - -;; Set file-name-handler-alist -;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ -(setq file-name-handler-alist-original file-name-handler-alist) -(setq file-name-handler-alist nil) - -;; Set deferred timer to reset them -;; https://emacs.stackexchange.com/a/34367 -(run-with-idle-timer - 5 nil - (lambda () - (setq gc-cons-threshold gc-cons-threshold-original) - (setq gc-cons-percentage gc-cons-percentage-original) - (setq file-name-handler-alist file-name-handler-alist-original) - (makunbound 'gc-cons-threshold-original) - (makunbound 'gc-cons-percentage-original) - (makunbound 'file-name-handler-alist-original) - (message "gc-cons-threshold and file-name-handler-alist restored"))) +(progn + ;; Set garbage collection threshold + ;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ + (setq gc-cons-threshold-original gc-cons-threshold + gc-cons-percentage-original gc-cons-percentage) + (setq gc-cons-threshold (* 1024 1024 100) + gc-cons-percentage 0.6) + + ;; Set file-name-handler-alist + ;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ + (setq file-name-handler-alist-original file-name-handler-alist) + (setq file-name-handler-alist nil) + + ;; Set deferred timer to reset them + ;; https://emacs.stackexchange.com/a/34367 + (run-with-idle-timer + 5 nil + (lambda () + (setq gc-cons-threshold gc-cons-threshold-original) + (setq gc-cons-percentage gc-cons-percentage-original) + (setq file-name-handler-alist file-name-handler-alist-original) + (makunbound 'gc-cons-threshold-original) + (makunbound 'gc-cons-percentage-original) + (makunbound 'file-name-handler-alist-original)))) ;; -- Core setup --