2018-03-21 15:21:18 -04:00
|
|
|
;;; early-init.el -*- lexical-binding: t; -*-
|
|
|
|
|
2021-01-03 22:56:36 -05:00
|
|
|
;; Emacs 27.1 introduced early-init.el, which is run before init.el, before
|
|
|
|
;; package and UI initialization happens, and before site files are loaded.
|
2018-03-28 00:41:57 -04:00
|
|
|
|
2021-01-03 22:56:36 -05: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 by
|
|
|
|
;; enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
|
2019-07-21 03:01:15 +02:00
|
|
|
(setq gc-cons-threshold most-positive-fixnum)
|
2018-09-19 00:25:17 +01:00
|
|
|
|
2021-05-06 15:54:10 -04:00
|
|
|
;; Prevent unwanted runtime compilation for gccemacs (native-comp) users;
|
|
|
|
;; packages are compiled ahead-of-time when they are installed and site files
|
|
|
|
;; are compiled when gccemacs is installed.
|
2021-10-09 19:31:21 +02:00
|
|
|
(setq native-comp-deferred-compilation nil)
|
2021-01-03 22:56:36 -05:00
|
|
|
|
2019-07-21 03:01:15 +02:00
|
|
|
;; In Emacs 27+, package initialization occurs before `user-init-file' is
|
|
|
|
;; loaded, but after `early-init-file'. Doom handles package initialization, so
|
|
|
|
;; we must prevent Emacs from doing it early!
|
2018-08-31 23:40:54 +02:00
|
|
|
(setq package-enable-at-startup nil)
|
2021-10-09 19:31:21 +02:00
|
|
|
|
|
|
|
;; In noninteractive sessions, prioritize non-byte-compiled source files to
|
|
|
|
;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time
|
|
|
|
;; to skip the mtime checks on every *.elc file.
|
|
|
|
(setq load-prefer-newer noninteractive)
|
2018-06-16 11:38:19 +02:00
|
|
|
|
2021-04-20 22:34:59 -04:00
|
|
|
(unless (or (daemonp) noninteractive)
|
|
|
|
(let ((old-file-name-handler-alist file-name-handler-alist))
|
|
|
|
;; `file-name-handler-alist' is consulted on each `require', `load' and
|
|
|
|
;; various path/io functions. You get a minor speed up by unsetting this.
|
|
|
|
;; Some warning, however: this could cause problems on builds of Emacs where
|
|
|
|
;; its site lisp files aren't byte-compiled and we're forced to load the
|
|
|
|
;; *.el.gz files (e.g. on Alpine).
|
|
|
|
(setq-default file-name-handler-alist nil)
|
|
|
|
;; ...but restore `file-name-handler-alist' later, because it is needed for
|
|
|
|
;; handling encrypted or compressed files, among other things.
|
|
|
|
(defun doom-reset-file-handler-alist-h ()
|
|
|
|
(setq file-name-handler-alist
|
|
|
|
;; Merge instead of overwrite because there may have bene changes to
|
|
|
|
;; `file-name-handler-alist' since startup we want to preserve.
|
|
|
|
(delete-dups (append file-name-handler-alist
|
|
|
|
old-file-name-handler-alist))))
|
2021-10-09 19:31:21 +02:00
|
|
|
(add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h 101))
|
|
|
|
|
2021-12-12 22:26:16 +01:00
|
|
|
;; Premature redisplays can substantially affect startup times and produce
|
|
|
|
;; ugly flashes of unstyled Emacs.
|
2021-10-18 00:38:36 +02:00
|
|
|
(setq-default inhibit-redisplay t
|
|
|
|
inhibit-message t)
|
|
|
|
(add-hook 'window-setup-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq-default inhibit-redisplay nil
|
|
|
|
inhibit-message nil)
|
2021-11-25 01:17:42 +01:00
|
|
|
(redisplay)))
|
|
|
|
|
|
|
|
;; Site files tend to use `load-file', which emits "Loading X..." messages in
|
|
|
|
;; the echo area, which in turn triggers a redisplay. Redisplays can have a
|
|
|
|
;; substantial effect on startup times and in this case happens so early that
|
|
|
|
;; Emacs may flash white while starting up.
|
|
|
|
(define-advice load-file (:override (file) silence)
|
|
|
|
(load file nil 'nomessage))
|
|
|
|
|
|
|
|
;; Undo our `load-file' advice above, to limit the scope of any edge cases it
|
|
|
|
;; may introduce down the road.
|
|
|
|
(define-advice startup--load-user-init-file (:before (&rest _) init-doom)
|
|
|
|
(advice-remove #'load-file #'load-file@silence)))
|
2021-10-09 19:31:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Bootstrap
|
|
|
|
|
|
|
|
;; Contrary to what many Emacs users have in their configs, you don't need
|
|
|
|
;; more than this to make UTF-8 the default coding system:
|
|
|
|
(set-language-environment "UTF-8")
|
2019-03-02 03:54:04 -05:00
|
|
|
|
2021-10-30 18:16:39 +03:00
|
|
|
;; set-language-enviornment sets default-input-method, which is unwanted
|
|
|
|
(setq default-input-method nil)
|
|
|
|
|
2021-01-03 22:56:36 -05:00
|
|
|
;; Ensure Doom is running out of this file's directory
|
|
|
|
(setq user-emacs-directory (file-name-directory load-file-name))
|
2019-09-06 15:40:38 -04:00
|
|
|
|
2021-01-03 22:56:36 -05:00
|
|
|
;; Load the heart of Doom Emacs
|
|
|
|
(load (concat user-emacs-directory "core/core") nil 'nomessage)
|