refactor: how Doom starts up
Restructures Doom's primary core files and entry points to prepare for
backports (from the new CLI) coming soon.
- Removes $EMACSDIR/init.el.
- Doom configures Emacs to ignore ~/.emacs and ~/_emacs files.
- Doom's bootstrapper for interactive sessions was moved out of core.el
and doom-initialize into doom-start.el. This change is preparation for
Doom's new profile system (coming soon™️), where this bootstrapper
will be dynamically generated.
- core.el and early-init.el have been reorganized, comment headers moved
around, and comments updated to reflect these changes.
This commit is contained in:
parent
76431f699e
commit
1402db5129
5 changed files with 400 additions and 365 deletions
|
@ -1,23 +1,23 @@
|
|||
;;; early-init.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; 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.
|
||||
;; package and UI initialization happens, and before site files are loaded. This
|
||||
;; is the best time to make all our changes (though any UI work will have to be
|
||||
;; deferred).
|
||||
;;
|
||||
;; This file is the entry point into Doom Emacs for your standard, interactive
|
||||
;; Emacs session, and houses our most pressing and hackiest startup
|
||||
;; optimizations. That said, only the "bootstrap" section at the bottom is
|
||||
;; required for Doom to function.
|
||||
;;
|
||||
;;; Code:
|
||||
|
||||
;; 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)
|
||||
|
||||
;; 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.
|
||||
(setq native-comp-deferred-compilation nil)
|
||||
|
||||
;; 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!
|
||||
(setq package-enable-at-startup nil)
|
||||
|
||||
;; 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.
|
||||
|
@ -69,15 +69,33 @@
|
|||
;;
|
||||
;;; 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")
|
||||
|
||||
;; set-language-enviornment sets default-input-method, which is unwanted
|
||||
(setq default-input-method nil)
|
||||
|
||||
;; 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)
|
||||
|
||||
;; We hijack Emacs' initfile resolver to inject our own entry point. Why do
|
||||
;; this? Because:
|
||||
;;
|
||||
;; - It spares Emacs the effort of looking for/loading useless initfiles, like
|
||||
;; ~/.emacs and ~/_emacs. And skips ~/.emacs.d/init.el, which won't exist if
|
||||
;; you're using Doom (fyi: doom hackers or chemacs users could then use
|
||||
;; $EMACSDIR as their $DOOMDIR, if they wanted).
|
||||
;; - Later, 'doom sync' will dynamically generate its bootstrap file, which is
|
||||
;; important for Doom's soon-to-be profile system (which can replace Chemacs).
|
||||
;; Until then, we'll use core/core-start.el.
|
||||
;; - A "fallback" initfile can be trivially specified, in case the bootstrapper
|
||||
;; is missing (if the user hasn't run 'doom sync' or is a first-timer). This
|
||||
;; is an opportunity to display a "safe mode" environment that's less
|
||||
;; intimidating and more helpful than the broken state errors would've left
|
||||
;; Emacs in, otherwise.
|
||||
;; - A generated config allows for a file IO optimized startup.
|
||||
(define-advice startup--load-user-init-file (:filter-args (args) init-doom)
|
||||
"Initialize Doom Emacs in an interactive session."
|
||||
(list (lambda ()
|
||||
(expand-file-name "core-start" doom-core-dir))
|
||||
nil ; TODO Replace with safe mode initfile
|
||||
(caddr args)))
|
||||
|
||||
;;; early-init.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue