Refactor doom-initialize & bootstrap in core.el
This commit is contained in:
parent
8c701ef7d4
commit
9b180fda97
7 changed files with 70 additions and 67 deletions
|
@ -16,46 +16,46 @@ If neither is available, run all tests in all enabled modules."
|
||||||
;; Core libraries aren't fully loaded in a noninteractive session, so we
|
;; Core libraries aren't fully loaded in a noninteractive session, so we
|
||||||
;; reload it with `noninteractive' set to nil to force them to.
|
;; reload it with `noninteractive' set to nil to force them to.
|
||||||
(quiet! (doom-reload-autoloads))
|
(quiet! (doom-reload-autoloads))
|
||||||
(doom-initialize 'force t)
|
(let ((doom-modules (doom-modules))
|
||||||
(doom-initialize-modules 'force)
|
noninteractive)
|
||||||
(let ((target-paths
|
(let ((target-paths
|
||||||
;; Convert targets into a list of string paths, pointing to the root
|
;; Convert targets into a list of string paths, pointing to the root
|
||||||
;; directory of modules
|
;; directory of modules
|
||||||
(cond ((stringp (car modules)) ; command line
|
(cond ((stringp (car modules)) ; command line
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(cl-loop for arg in modules
|
(cl-loop for arg in modules
|
||||||
if (string= arg ":core") collect doom-core-dir
|
if (string= arg ":core") collect doom-core-dir
|
||||||
else if (string-match-p "/" arg)
|
else if (string-match-p "/" arg)
|
||||||
nconc (mapcar (apply-partially #'expand-file-name arg)
|
nconc (mapcar (apply-partially #'expand-file-name arg)
|
||||||
doom-modules-dirs)
|
doom-modules-dirs)
|
||||||
else
|
else
|
||||||
nconc (cl-loop for dir in doom-modules-dirs
|
nconc (cl-loop for dir in doom-modules-dirs
|
||||||
for path = (expand-file-name arg dir)
|
for path = (expand-file-name arg dir)
|
||||||
if (file-directory-p path)
|
if (file-directory-p path)
|
||||||
nconc (doom-files-in path :type 'dirs :depth 1 :full t))
|
nconc (doom-files-in path :type 'dirs :depth 1 :full t))
|
||||||
finally do (setq argv nil))))
|
finally do (setq argv nil))))
|
||||||
|
|
||||||
(modules ; cons-cells given to MODULES
|
(modules ; cons-cells given to MODULES
|
||||||
(cl-loop for (module . submodule) in modules
|
(cl-loop for (module . submodule) in modules
|
||||||
if (doom-module-locate-path module submodule)
|
if (doom-module-locate-path module submodule)
|
||||||
collect it))
|
collect it))
|
||||||
|
|
||||||
((append (list doom-core-dir)
|
((append (list doom-core-dir)
|
||||||
(doom-module-load-path))))))
|
(doom-module-load-path))))))
|
||||||
;; Load all the unit test files...
|
;; Load all the unit test files...
|
||||||
(require 'buttercup)
|
(require 'buttercup)
|
||||||
(mapc (lambda (file) (load file :noerror (not doom-debug-mode)))
|
(mapc (lambda (file) (load file :noerror (not doom-debug-mode)))
|
||||||
(doom-files-in (mapcar (apply-partially #'expand-file-name "test/")
|
(doom-files-in (mapcar (apply-partially #'expand-file-name "test/")
|
||||||
target-paths)
|
target-paths)
|
||||||
:match "\\.el$" :full t))
|
:match "\\.el$" :full t))
|
||||||
;; ... then run them
|
;; ... then run them
|
||||||
(when doom-debug-mode
|
(when doom-debug-mode
|
||||||
(setq buttercup-stack-frame-style 'pretty))
|
(setq buttercup-stack-frame-style 'pretty))
|
||||||
(let ((split-width-threshold 0)
|
(let ((split-width-threshold 0)
|
||||||
(split-height-threshold 0)
|
(split-height-threshold 0)
|
||||||
(window-min-width 0)
|
(window-min-width 0)
|
||||||
(window-min-height 0))
|
(window-min-height 0))
|
||||||
(buttercup-run))))
|
(buttercup-run)))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
;;; core-lib.el -*- lexical-binding: t; -*-
|
;;; core-lib.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Built-in packages we use a lot of
|
|
||||||
(require 'subr-x)
|
|
||||||
(require 'cl-lib)
|
|
||||||
|
|
||||||
(eval-and-compile
|
(eval-and-compile
|
||||||
(unless EMACS26+
|
(unless EMACS26+
|
||||||
(with-no-warnings
|
(with-no-warnings
|
||||||
|
|
49
core/core.el
49
core/core.el
|
@ -388,11 +388,18 @@ If RETURN-P, return the message as a string instead of displaying it."
|
||||||
;;
|
;;
|
||||||
;; Bootstrap functions
|
;; Bootstrap functions
|
||||||
|
|
||||||
(defun doom-initialize (&optional force-p force-load-core-p)
|
(defun doom-initialize-autoloads (file)
|
||||||
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).
|
"Tries to load FILE (an autoloads file). Return t on success, throws an error
|
||||||
|
in interactive sessions, nil otherwise (but logs a warning)."
|
||||||
|
(condition-case e
|
||||||
|
(load (file-name-sans-extension file) 'noerror 'nomessage)
|
||||||
|
((debug error)
|
||||||
|
(if noninteractive
|
||||||
|
(message "Autoload file warning: %s -> %s" (car e) (error-message-string e))
|
||||||
|
(signal 'doom-autoload-error (list (file-name-nondirectory file) e))))))
|
||||||
|
|
||||||
Loads Doom core files if in an interactive session or FORCE-LOAD-CORE-P is
|
(defun doom-initialize (&optional force-p)
|
||||||
non-nil.
|
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).
|
||||||
|
|
||||||
The bootstrap process involves making sure 1) the essential directories exist,
|
The bootstrap process involves making sure 1) the essential directories exist,
|
||||||
2) the core packages are installed, 3) `doom-autoload-file' and
|
2) the core packages are installed, 3) `doom-autoload-file' and
|
||||||
|
@ -420,6 +427,10 @@ The overall load order of Doom is as follows:
|
||||||
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
||||||
for a list of all recognized module trees. Order defines precedence (from most
|
for a list of all recognized module trees. Order defines precedence (from most
|
||||||
to least)."
|
to least)."
|
||||||
|
;; Built-in packages we use a lot of
|
||||||
|
(require 'subr-x)
|
||||||
|
(require 'cl-lib)
|
||||||
|
|
||||||
(when (or force-p (not doom-init-p))
|
(when (or force-p (not doom-init-p))
|
||||||
(setq doom-init-p t) ; Prevent infinite recursion
|
(setq doom-init-p t) ; Prevent infinite recursion
|
||||||
|
|
||||||
|
@ -447,24 +458,16 @@ to least)."
|
||||||
noninteractive)
|
noninteractive)
|
||||||
(user-error "Your package autoloads are missing! Run `bin/doom refresh' to regenerate them"))))
|
(user-error "Your package autoloads are missing! Run `bin/doom refresh' to regenerate them"))))
|
||||||
|
|
||||||
|
(require 'core-lib)
|
||||||
|
(require 'core-modules)
|
||||||
(require 'core-os)
|
(require 'core-os)
|
||||||
(when (or force-load-core-p (not noninteractive))
|
(if noninteractive
|
||||||
|
(require 'core-cli)
|
||||||
(add-hook 'window-setup-hook #'doom|display-benchmark)
|
(add-hook 'window-setup-hook #'doom|display-benchmark)
|
||||||
|
(require 'core-keybinds)
|
||||||
(require 'core-ui)
|
(require 'core-ui)
|
||||||
(require 'core-editor)
|
|
||||||
(require 'core-projects)
|
(require 'core-projects)
|
||||||
(require 'core-keybinds)))
|
(require 'core-editor)))
|
||||||
|
|
||||||
(defun doom-initialize-autoloads (file)
|
|
||||||
"Tries to load FILE (an autoloads file). Return t on success, throws an error
|
|
||||||
in interactive sessions, nil otherwise (but logs a warning)."
|
|
||||||
(condition-case e
|
|
||||||
(load (file-name-sans-extension file) 'noerror 'nomessage)
|
|
||||||
((debug error)
|
|
||||||
(if noninteractive
|
|
||||||
(message "Autoload file warning: %s -> %s" (car e) (error-message-string e))
|
|
||||||
(signal 'doom-autoload-error (list (file-name-nondirectory file) e))))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -472,16 +475,12 @@ in interactive sessions, nil otherwise (but logs a warning)."
|
||||||
|
|
||||||
(add-to-list 'load-path doom-core-dir)
|
(add-to-list 'load-path doom-core-dir)
|
||||||
|
|
||||||
(require 'core-lib)
|
|
||||||
(require 'core-modules)
|
|
||||||
(when noninteractive
|
|
||||||
(require 'core-cli))
|
|
||||||
(after! package
|
|
||||||
(require 'core-packages))
|
|
||||||
|
|
||||||
(doom-initialize noninteractive)
|
(doom-initialize noninteractive)
|
||||||
(unless noninteractive
|
(unless noninteractive
|
||||||
(doom-initialize-modules))
|
(doom-initialize-modules))
|
||||||
|
(after! package
|
||||||
|
(require 'core-packages)
|
||||||
|
(doom-initialize-packages))
|
||||||
|
|
||||||
(provide 'core)
|
(provide 'core)
|
||||||
;;; core.el ends here
|
;;; core.el ends here
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; core/test/test-core-keybinds.el
|
;;; core/test/test-core-keybinds.el
|
||||||
|
|
||||||
|
(require 'core-keybinds)
|
||||||
|
|
||||||
(buttercup-define-matcher :to-expand-into (src result)
|
(buttercup-define-matcher :to-expand-into (src result)
|
||||||
(let ((src (funcall src))
|
(let ((src (funcall src))
|
||||||
(result (funcall result)))
|
(result (funcall result)))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; core/test/test-core-lib.el
|
;;; core/test/test-core-lib.el
|
||||||
|
|
||||||
|
(require 'core-lib)
|
||||||
|
|
||||||
(describe "core/lib"
|
(describe "core/lib"
|
||||||
;; --- Helpers ----------------------------
|
;; --- Helpers ----------------------------
|
||||||
(describe "doom-unquote"
|
(describe "doom-unquote"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; core/test/test-core-modules.el
|
;;; core/test/test-core-modules.el
|
||||||
|
|
||||||
|
;; (require 'core-modules)
|
||||||
|
|
||||||
(describe "core-modules")
|
(describe "core-modules")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
;; -*- no-byte-compile: t; -*-
|
;; -*- no-byte-compile: t; -*-
|
||||||
;;; ../core/test/test-core-ui.el
|
;;; ../core/test/test-core-ui.el
|
||||||
|
|
||||||
|
(require 'core-ui)
|
||||||
|
|
||||||
(describe "core/ui"
|
(describe "core/ui"
|
||||||
(describe "doom|protect-visible-buffer"
|
(describe "doom|protect-visible-buffer"
|
||||||
:var (kill-buffer-query-functions wconf a b)
|
:var (kill-buffer-query-functions wconf a b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue