doomemacs/init.el
Henrik Lissner 937f118e6a
Reset gc-cons-threshold on idle timer
And remove reset from doom-reload-hook, as it is no longer necessary
anymore. ~/.emacs.d/init.el is no longer re-evaluated at any point.
2018-09-09 09:58:18 -04:00

74 lines
3.7 KiB
EmacsLisp

;;; init.el -*- lexical-binding: t; -*-
;;
;; Author: Henrik Lissner <henrik@lissner.net>
;; URL: https://github.com/hlissner/doom-emacs
;;
;; ================= =============== =============== ======== ========
;; \\ . . . . . . .\\ //. . . . . . .\\ //. . . . . . .\\ \\. . .\\// . . //
;; ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\/ . . .||
;; || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||
;; ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||
;; || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||
;; ||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\_ . .|. .||
;; || . _|| || || || || ||_ . || || . _|| || || || |\ `-_/| . ||
;; ||_-' || .|/ || || \|. || `-_|| ||_-' || .|/ || || | \ / |-_.||
;; || ||_-' || || `-_|| || || ||_-' || || | \ / | `||
;; || `' || || `' || || `' || || | \ / | ||
;; || .===' `===. .==='.`===. .===' /==. | \/ | ||
;; || .==' \_|-_ `===. .===' _|_ `===. .===' _-|/ `== \/ | ||
;; || .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \/ | ||
;; || .==' _-' '-__\._-' '-_./__-' `' |. /| | ||
;; ||.==' _-' `' | /==.||
;; ==' _-' \/ `==
;; \ _-' `-_ /
;; `'' ``'
;;
;; These demons are not part of GNU Emacs.
;;
;;; License: MIT
(defvar doom-gc-cons-threshold 16777216 ; 16mb
"The default value to use for `gc-cons-threshold'. If you experience freezing,
decrease this. If you experience stuttering, increase this.")
(defvar doom-gc-cons-upper-limit 268435456 ; 256mb
"The temporary value for `gc-cons-threshold' to defer it.")
(defvar doom--file-name-handler-alist file-name-handler-alist)
(defun doom|restore-startup-optimizations ()
"Resets garbage collection settings to reasonable defaults (a large
`gc-cons-threshold' can cause random freezes otherwise) and resets
`file-name-handler-alist'."
(setq-default file-name-handler-alist doom--file-name-handler-alist)
;; Do it on an idle timer to defer the possible GC pause, and to give deferred
;; packages the opportunity to take advantage of these optimizations.
(run-with-idle-timer
3 nil (lambda () (setq-default gc-cons-threshold doom-gc-cons-threshold))))
(if (or after-init-time noninteractive)
(setq gc-cons-threshold doom-gc-cons-threshold)
;; A big contributor to long startup times is the garbage collector, so we up
;; its memory threshold, temporarily and reset it later in
;; `doom|disable-startup-optimizations'.
(setq gc-cons-threshold doom-gc-cons-upper-limit)
;; This is consulted on every `require', `load' and various file reading
;; functions. You get a minor speed up by nooping this.
(setq file-name-handler-alist nil)
;; Not restoring these to their defaults will cause stuttering/freezes.
(add-hook 'emacs-startup-hook #'doom|restore-startup-optimizations))
;; Ensure Doom is always running out of this file's directory
(setq user-emacs-directory (file-name-directory load-file-name))
;; In noninteractive sessions, we hope that non-byte-compiled files will take
;; precedence over byte-compiled ones, however, if you're getting odd recursive
;; load errors, it may help to set this to nil.
(setq load-prefer-newer noninteractive)
;; Let 'er rip!
(require 'core (concat user-emacs-directory "core/core"))