refactor: make early-init.el Doom's universal bootstrapper
This centralizes Doom's core startup optimizations and, as a side-effect, reduces the runtime of bin/doom commands substantially. This also simplifies the user story for loading Doom remotely (for batch sessions or doomscripts).
This commit is contained in:
parent
3853dff5e1
commit
c05e61536e
2 changed files with 29 additions and 28 deletions
42
bin/doom
42
bin/doom
|
@ -74,19 +74,20 @@
|
|||
;; - The user may have a noexec flag set on /tmp, so pass the exit script to
|
||||
;; /bin/sh rather than executing them directly.
|
||||
|
||||
;; Ensure Doom runs out of this file's parent directory (or $EMACSDIR), where
|
||||
;; Doom is presumably installed.
|
||||
(setq user-emacs-directory
|
||||
(if (getenv-internal "EMACSDIR")
|
||||
(file-name-as-directory
|
||||
(file-truename (getenv-internal "EMACSDIR")))
|
||||
(expand-file-name
|
||||
"../" (file-name-directory (file-truename load-file-name)))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Sanity checks
|
||||
;; Doom's core sets up everything we need; including `doom-*-dir' variables,
|
||||
;; universal defaults, and autoloads for doom-*-initialize functions.
|
||||
(condition-case e
|
||||
(let ((load-prefer-newer t))
|
||||
(load (expand-file-name
|
||||
"../early-init" (file-name-directory (file-truename load-file-name)))
|
||||
nil 'nomessage))
|
||||
;; Prevent ugly backtraces for trivial errors
|
||||
(user-error (message "Error: %s" (cadr e))
|
||||
(kill-emacs 2)))
|
||||
|
||||
;; UX: Abort if the user is using 'doom' as root, unless ~/.emacs.d is owned by
|
||||
;; root, in which case we assume the user genuinely wants root to be their
|
||||
;; primary user account for Emacs.
|
||||
(when (equal (user-real-uid) 0)
|
||||
;; If ~/.emacs.d is owned by root, assume the user genuinely wants root to be
|
||||
;; their primary user, otherwise complain.
|
||||
|
@ -104,16 +105,6 @@
|
|||
(kill-emacs 2)))
|
||||
|
||||
|
||||
;;
|
||||
;;; Load Doom's CLI framework
|
||||
|
||||
(require 'doom-cli (expand-file-name "lisp/doom-cli" user-emacs-directory))
|
||||
|
||||
;; Load $DOOMDIR/init.el, to read the user's `doom!' block, and so users can
|
||||
;; customize things early, if they like.
|
||||
(load! doom-module-init-file doom-user-dir t)
|
||||
|
||||
|
||||
;;
|
||||
;;; Entry point
|
||||
|
||||
|
@ -237,7 +228,12 @@ SEE ALSO:
|
|||
|
||||
|
||||
;;
|
||||
;;; Commands
|
||||
;;; Load user config + commands
|
||||
|
||||
;; Load $DOOMDIR/init.el, to read the user's `doom!' block and give users an
|
||||
;; opportunity to customize the CLI environment, if they like. Otherwise, they
|
||||
;; can do so in .doomrc or .doomproject.
|
||||
(load! doom-module-init-file doom-user-dir t)
|
||||
|
||||
(let ((dir (doom-path doom-core-dir "cli")))
|
||||
;; It'd be simple to just load these files directly, but because there could
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue