Move init.el to early-init.el
Our first step toward dropping 26.x support. Allows our optimizations to reach a little further into the startup.
This commit is contained in:
parent
39deb6aedb
commit
5da3641aad
3 changed files with 44 additions and 62 deletions
|
@ -289,14 +289,13 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||||
;; where we resize windows too quickly.
|
;; where we resize windows too quickly.
|
||||||
(setq window-resize-pixelwise nil)
|
(setq window-resize-pixelwise nil)
|
||||||
|
|
||||||
(unless (assq 'menu-bar-lines default-frame-alist)
|
;; We do this in early-init.el too, but in case the user is on Emacs 26 we do it
|
||||||
;; We do this in early-init.el too, but in case the user is on Emacs 26 we do
|
;; here too: disable tool and scrollbars, as Doom encourages keyboard-centric
|
||||||
;; it here too: disable tool and scrollbars, as Doom encourages
|
;; workflows, so these are just clutter (the scrollbar also impacts
|
||||||
;; keyboard-centric workflows, so these are just clutter (the scrollbar also
|
;; performance).
|
||||||
;; impacts performance).
|
(push '(menu-bar-lines . 0) default-frame-alist)
|
||||||
(add-to-list 'default-frame-alist '(menu-bar-lines . 0))
|
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||||
(add-to-list 'default-frame-alist '(tool-bar-lines . 0))
|
(push '(vertical-scroll-bars) default-frame-alist)
|
||||||
(add-to-list 'default-frame-alist '(vertical-scroll-bars)))
|
|
||||||
|
|
||||||
;; These are disabled directly through their frame parameters, to avoid the
|
;; These are disabled directly through their frame parameters, to avoid the
|
||||||
;; extra work their minor modes do, but we have to unset these variables
|
;; extra work their minor modes do, but we have to unset these variables
|
||||||
|
@ -592,8 +591,8 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
|
||||||
(when doom-variable-pitch-font
|
(when doom-variable-pitch-font
|
||||||
(set-face-attribute 'variable-pitch nil :font doom-variable-pitch-font))
|
(set-face-attribute 'variable-pitch nil :font doom-variable-pitch-font))
|
||||||
(when (fboundp 'set-fontset-font)
|
(when (fboundp 'set-fontset-font)
|
||||||
(dolist (font (append doom-unicode-extra-fonts (doom-enlist doom-unicode-font)))
|
(dolist (font (cons doom-unicode-font doom-unicode-extra-fonts))
|
||||||
(set-fontset-font t 'unicode font nil 'prepend)))
|
(set-fontset-font t nil font nil 'prepend)))
|
||||||
(run-hooks 'after-setting-font-hook))
|
(run-hooks 'after-setting-font-hook))
|
||||||
((debug error)
|
((debug error)
|
||||||
(if (string-prefix-p "Font not available: " (error-message-string e))
|
(if (string-prefix-p "Font not available: " (error-message-string e))
|
||||||
|
|
|
@ -1,28 +1,43 @@
|
||||||
;;; early-init.el -*- lexical-binding: t; -*-
|
;;; early-init.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Emacs HEAD (27+) introduces early-init.el, which is run before init.el,
|
;; Emacs 27.1 introduced early-init.el, which is run before init.el, before
|
||||||
;; before package and UI initialization happens.
|
;; package and UI initialization happens, and before site files are loaded.
|
||||||
|
|
||||||
;; Defer garbage collection further back in the startup process
|
;; 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.
|
||||||
(setq gc-cons-threshold most-positive-fixnum)
|
(setq gc-cons-threshold most-positive-fixnum)
|
||||||
|
|
||||||
|
;; 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)
|
||||||
|
|
||||||
;; In Emacs 27+, package initialization occurs before `user-init-file' is
|
;; In Emacs 27+, package initialization occurs before `user-init-file' is
|
||||||
;; loaded, but after `early-init-file'. Doom handles package initialization, so
|
;; loaded, but after `early-init-file'. Doom handles package initialization, so
|
||||||
;; we must prevent Emacs from doing it early!
|
;; we must prevent Emacs from doing it early!
|
||||||
(setq package-enable-at-startup nil)
|
(setq package-enable-at-startup nil)
|
||||||
(fset #'package--ensure-init-file #'ignore) ; DEPRECATED Removed in 28
|
(fset #'package--ensure-init-file #'ignore) ; DEPRECATED Removed in 28
|
||||||
|
|
||||||
;; Prevent the glimpse of un-styled Emacs by disabling these UI elements early.
|
;; `file-name-handler-alist' is consulted on every `require', `load' and various
|
||||||
(push '(menu-bar-lines . 0) default-frame-alist)
|
;; path/io functions. You get a minor speed up by nooping this. However, this
|
||||||
(push '(tool-bar-lines . 0) default-frame-alist)
|
;; may cause problems on builds of Emacs where its site lisp files aren't
|
||||||
(push '(vertical-scroll-bars) default-frame-alist)
|
;; byte-compiled and we're forced to load the *.el.gz files (e.g. on Alpine)
|
||||||
|
(unless (daemonp)
|
||||||
|
(defvar doom--initial-file-name-handler-alist file-name-handler-alist)
|
||||||
|
(setq file-name-handler-alist nil)
|
||||||
|
;; 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 ()
|
||||||
|
;; Re-add rather than `setq', because changes to `file-name-handler-alist'
|
||||||
|
;; since startup ought to be preserved.
|
||||||
|
(dolist (handler file-name-handler-alist)
|
||||||
|
(add-to-list 'doom--initial-file-name-handler-alist handler))
|
||||||
|
(setq file-name-handler-alist doom--initial-file-name-handler-alist))
|
||||||
|
(add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h))
|
||||||
|
|
||||||
;; Resizing the Emacs frame can be a terribly expensive part of changing the
|
;; Ensure Doom is running out of this file's directory
|
||||||
;; font. By inhibiting this, we easily halve startup times with fonts that are
|
(setq user-emacs-directory (file-name-directory load-file-name))
|
||||||
;; larger than the system default.
|
|
||||||
(setq frame-inhibit-implied-resize t)
|
|
||||||
|
|
||||||
;; Prevent unwanted runtime builds in gccemacs (native-comp); packages are
|
;; Load the heart of Doom Emacs
|
||||||
;; compiled ahead-of-time when they are installed and site files are compiled
|
(load (concat user-emacs-directory "core/core") nil 'nomessage)
|
||||||
;; when gccemacs is installed.
|
|
||||||
(setq comp-deferred-compilation nil)
|
|
||||||
|
|
42
init.el
42
init.el
|
@ -27,43 +27,11 @@
|
||||||
;;
|
;;
|
||||||
;;; License: MIT
|
;;; License: MIT
|
||||||
|
|
||||||
(when (< emacs-major-version 26)
|
;; In the strange case that early-init.el wasn't loaded (e.g. you're using
|
||||||
(error "Detected Emacs v%s. Doom only supports Emacs 26 and newer"
|
;; Chemacs 1? Or you're loading this file directly?), we do it explicitly:
|
||||||
emacs-version))
|
(unless (boundp 'doom-version)
|
||||||
|
(load (concat (file-name-directory load-file-name) "early-init")
|
||||||
;; A big contributor to startup times is garbage collection. We up the gc
|
nil t))
|
||||||
;; threshold to temporarily prevent it from running, then reset it later by
|
|
||||||
;; enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
|
|
||||||
(setq gc-cons-threshold most-positive-fixnum)
|
|
||||||
|
|
||||||
;; 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)
|
|
||||||
|
|
||||||
;; `file-name-handler-alist' is consulted on every `require', `load' and various
|
|
||||||
;; path/io functions. You get a minor speed up by nooping this. However, this
|
|
||||||
;; may 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)
|
|
||||||
(unless (daemonp)
|
|
||||||
(defvar doom--initial-file-name-handler-alist file-name-handler-alist)
|
|
||||||
(setq file-name-handler-alist nil)
|
|
||||||
;; 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 ()
|
|
||||||
;; Re-add rather than `setq', because changes to `file-name-handler-alist'
|
|
||||||
;; since startup ought to be preserved.
|
|
||||||
(dolist (handler file-name-handler-alist)
|
|
||||||
(add-to-list 'doom--initial-file-name-handler-alist handler))
|
|
||||||
(setq file-name-handler-alist doom--initial-file-name-handler-alist))
|
|
||||||
(add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h))
|
|
||||||
|
|
||||||
;; Ensure Doom is running out of this file's directory
|
|
||||||
(setq user-emacs-directory (file-name-directory load-file-name))
|
|
||||||
|
|
||||||
;; Load the heart of Doom Emacs
|
|
||||||
(load (concat user-emacs-directory "core/core")
|
|
||||||
nil 'nomessage)
|
|
||||||
|
|
||||||
;; And let 'er rip!
|
;; And let 'er rip!
|
||||||
(doom-initialize)
|
(doom-initialize)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue