2018-04-03 19:48:20 -04:00
|
|
|
;;; 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
|
|
|
|
|
2018-09-03 01:18:52 +02:00
|
|
|
(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.")
|
|
|
|
|
2019-05-13 19:28:51 -04:00
|
|
|
(defvar doom-gc-cons-upper-limit 536870912 ; 512mb
|
2018-09-03 01:18:52 +02:00
|
|
|
"The temporary value for `gc-cons-threshold' to defer it.")
|
2018-09-02 17:28:04 +02:00
|
|
|
|
2018-06-15 14:10:06 +02:00
|
|
|
|
2018-09-02 17:28:04 +02:00
|
|
|
(defvar doom--file-name-handler-alist file-name-handler-alist)
|
2018-09-03 01:18:52 +02:00
|
|
|
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun doom-restore-startup-optimizations-h ()
|
2018-09-03 01:18:52 +02:00
|
|
|
"Resets garbage collection settings to reasonable defaults (a large
|
|
|
|
`gc-cons-threshold' can cause random freezes otherwise) and resets
|
|
|
|
`file-name-handler-alist'."
|
2018-09-07 21:43:32 -04:00
|
|
|
(setq file-name-handler-alist doom--file-name-handler-alist)
|
|
|
|
;; Do this on idle timer to defer a possible GC pause that could result; also
|
|
|
|
;; allows deferred packages to take advantage of these optimizations.
|
2018-09-03 23:52:14 +02:00
|
|
|
(run-with-idle-timer
|
2019-05-15 18:30:20 -04:00
|
|
|
3 nil
|
|
|
|
(lambda ()
|
|
|
|
(setq-default gc-cons-threshold doom-gc-cons-threshold)
|
|
|
|
;; To speed up minibuffer commands (like helm and ivy), we defer garbage
|
|
|
|
;; collection while the minibuffer is active.
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun doom-defer-garbage-collection-h ()
|
2019-05-15 18:30:20 -04:00
|
|
|
(setq gc-cons-threshold doom-gc-cons-upper-limit))
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun doom-restore-garbage-collection-h ()
|
2019-05-15 18:30:20 -04:00
|
|
|
;; Defer it so that commands launched from the minibuffer can enjoy the
|
|
|
|
;; benefits.
|
|
|
|
(run-at-time 1 nil (lambda () (setq gc-cons-threshold doom-gc-cons-threshold))))
|
2019-07-18 15:27:20 +02:00
|
|
|
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h)
|
|
|
|
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h)
|
2019-05-15 18:30:20 -04:00
|
|
|
;; GC all sneaky breeky like
|
|
|
|
(add-hook 'focus-out-hook #'garbage-collect))))
|
2018-09-03 01:18:52 +02:00
|
|
|
|
|
|
|
|
2019-04-24 13:09:33 -04:00
|
|
|
(if (ignore-errors (or after-init-time noninteractive))
|
2018-09-03 01:18:52 +02:00
|
|
|
(setq gc-cons-threshold doom-gc-cons-threshold)
|
2018-09-07 21:43:32 -04:00
|
|
|
;; A big contributor to startup times is garbage collection. We up the gc
|
|
|
|
;; threshold to temporarily prevent it from running, then reset it later in
|
2019-07-18 15:27:20 +02:00
|
|
|
;; `doom-restore-startup-optimizations-h'.
|
2018-09-03 23:52:14 +02:00
|
|
|
(setq gc-cons-threshold doom-gc-cons-upper-limit)
|
2018-10-01 18:53:34 -04:00
|
|
|
;; This is consulted on every `require', `load' and various path/io functions.
|
|
|
|
;; You get a minor speed up by nooping this.
|
2018-09-03 01:18:52 +02:00
|
|
|
(setq file-name-handler-alist nil)
|
2018-09-03 23:52:14 +02:00
|
|
|
;; Not restoring these to their defaults will cause stuttering/freezes.
|
2019-07-18 15:27:20 +02:00
|
|
|
(add-hook 'after-init-hook #'doom-restore-startup-optimizations-h))
|
2018-08-31 23:40:54 +02:00
|
|
|
|
2018-08-25 23:49:30 +02:00
|
|
|
|
2018-09-07 21:43:32 -04:00
|
|
|
;; Ensure Doom is running out of this file's directory
|
2018-09-02 17:28:04 +02:00
|
|
|
(setq user-emacs-directory (file-name-directory load-file-name))
|
2018-09-07 21:43:32 -04:00
|
|
|
;; In noninteractive sessions, prioritize non-byte-compiled source files to
|
|
|
|
;; prevent stale, byte-compiled code from running. However, if you're getting
|
|
|
|
;; recursive load errors, it may help to set this to nil.
|
2018-09-02 17:28:04 +02:00
|
|
|
(setq load-prefer-newer noninteractive)
|
2018-08-31 23:40:54 +02:00
|
|
|
|
2018-09-03 01:18:52 +02:00
|
|
|
|
2018-08-31 23:40:54 +02:00
|
|
|
;; Let 'er rip!
|
|
|
|
(require 'core (concat user-emacs-directory "core/core"))
|