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
|
||||
;; reload it with `noninteractive' set to nil to force them to.
|
||||
(quiet! (doom-reload-autoloads))
|
||||
(doom-initialize 'force t)
|
||||
(doom-initialize-modules 'force)
|
||||
(let ((target-paths
|
||||
;; Convert targets into a list of string paths, pointing to the root
|
||||
;; directory of modules
|
||||
(cond ((stringp (car modules)) ; command line
|
||||
(save-match-data
|
||||
(cl-loop for arg in modules
|
||||
if (string= arg ":core") collect doom-core-dir
|
||||
else if (string-match-p "/" arg)
|
||||
nconc (mapcar (apply-partially #'expand-file-name arg)
|
||||
doom-modules-dirs)
|
||||
else
|
||||
nconc (cl-loop for dir in doom-modules-dirs
|
||||
for path = (expand-file-name arg dir)
|
||||
if (file-directory-p path)
|
||||
nconc (doom-files-in path :type 'dirs :depth 1 :full t))
|
||||
finally do (setq argv nil))))
|
||||
(let ((doom-modules (doom-modules))
|
||||
noninteractive)
|
||||
(let ((target-paths
|
||||
;; Convert targets into a list of string paths, pointing to the root
|
||||
;; directory of modules
|
||||
(cond ((stringp (car modules)) ; command line
|
||||
(save-match-data
|
||||
(cl-loop for arg in modules
|
||||
if (string= arg ":core") collect doom-core-dir
|
||||
else if (string-match-p "/" arg)
|
||||
nconc (mapcar (apply-partially #'expand-file-name arg)
|
||||
doom-modules-dirs)
|
||||
else
|
||||
nconc (cl-loop for dir in doom-modules-dirs
|
||||
for path = (expand-file-name arg dir)
|
||||
if (file-directory-p path)
|
||||
nconc (doom-files-in path :type 'dirs :depth 1 :full t))
|
||||
finally do (setq argv nil))))
|
||||
|
||||
(modules ; cons-cells given to MODULES
|
||||
(cl-loop for (module . submodule) in modules
|
||||
if (doom-module-locate-path module submodule)
|
||||
collect it))
|
||||
(modules ; cons-cells given to MODULES
|
||||
(cl-loop for (module . submodule) in modules
|
||||
if (doom-module-locate-path module submodule)
|
||||
collect it))
|
||||
|
||||
((append (list doom-core-dir)
|
||||
(doom-module-load-path))))))
|
||||
;; Load all the unit test files...
|
||||
(require 'buttercup)
|
||||
(mapc (lambda (file) (load file :noerror (not doom-debug-mode)))
|
||||
(doom-files-in (mapcar (apply-partially #'expand-file-name "test/")
|
||||
target-paths)
|
||||
:match "\\.el$" :full t))
|
||||
;; ... then run them
|
||||
(when doom-debug-mode
|
||||
(setq buttercup-stack-frame-style 'pretty))
|
||||
(let ((split-width-threshold 0)
|
||||
(split-height-threshold 0)
|
||||
(window-min-width 0)
|
||||
(window-min-height 0))
|
||||
(buttercup-run))))
|
||||
((append (list doom-core-dir)
|
||||
(doom-module-load-path))))))
|
||||
;; Load all the unit test files...
|
||||
(require 'buttercup)
|
||||
(mapc (lambda (file) (load file :noerror (not doom-debug-mode)))
|
||||
(doom-files-in (mapcar (apply-partially #'expand-file-name "test/")
|
||||
target-paths)
|
||||
:match "\\.el$" :full t))
|
||||
;; ... then run them
|
||||
(when doom-debug-mode
|
||||
(setq buttercup-stack-frame-style 'pretty))
|
||||
(let ((split-width-threshold 0)
|
||||
(split-height-threshold 0)
|
||||
(window-min-width 0)
|
||||
(window-min-height 0))
|
||||
(buttercup-run)))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
;;; core-lib.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Built-in packages we use a lot of
|
||||
(require 'subr-x)
|
||||
(require 'cl-lib)
|
||||
|
||||
(eval-and-compile
|
||||
(unless EMACS26+
|
||||
(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
|
||||
|
||||
(defun doom-initialize (&optional force-p force-load-core-p)
|
||||
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).
|
||||
(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))))))
|
||||
|
||||
Loads Doom core files if in an interactive session or FORCE-LOAD-CORE-P is
|
||||
non-nil.
|
||||
(defun doom-initialize (&optional force-p)
|
||||
"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,
|
||||
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'
|
||||
for a list of all recognized module trees. Order defines precedence (from most
|
||||
to least)."
|
||||
;; Built-in packages we use a lot of
|
||||
(require 'subr-x)
|
||||
(require 'cl-lib)
|
||||
|
||||
(when (or force-p (not doom-init-p))
|
||||
(setq doom-init-p t) ; Prevent infinite recursion
|
||||
|
||||
|
@ -447,24 +458,16 @@ to least)."
|
|||
noninteractive)
|
||||
(user-error "Your package autoloads are missing! Run `bin/doom refresh' to regenerate them"))))
|
||||
|
||||
(require 'core-lib)
|
||||
(require 'core-modules)
|
||||
(require 'core-os)
|
||||
(when (or force-load-core-p (not noninteractive))
|
||||
(if noninteractive
|
||||
(require 'core-cli)
|
||||
(add-hook 'window-setup-hook #'doom|display-benchmark)
|
||||
|
||||
(require 'core-keybinds)
|
||||
(require 'core-ui)
|
||||
(require 'core-editor)
|
||||
(require 'core-projects)
|
||||
(require 'core-keybinds)))
|
||||
|
||||
(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))))))
|
||||
(require 'core-editor)))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -472,16 +475,12 @@ in interactive sessions, nil otherwise (but logs a warning)."
|
|||
|
||||
(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)
|
||||
(unless noninteractive
|
||||
(doom-initialize-modules))
|
||||
(after! package
|
||||
(require 'core-packages)
|
||||
(doom-initialize-packages))
|
||||
|
||||
(provide 'core)
|
||||
;;; core.el ends here
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/test-core-keybinds.el
|
||||
|
||||
(require 'core-keybinds)
|
||||
|
||||
(buttercup-define-matcher :to-expand-into (src result)
|
||||
(let ((src (funcall src))
|
||||
(result (funcall result)))
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/test-core-lib.el
|
||||
|
||||
(require 'core-lib)
|
||||
|
||||
(describe "core/lib"
|
||||
;; --- Helpers ----------------------------
|
||||
(describe "doom-unquote"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/test-core-modules.el
|
||||
|
||||
;; (require 'core-modules)
|
||||
|
||||
(describe "core-modules")
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ../core/test/test-core-ui.el
|
||||
|
||||
(require 'core-ui)
|
||||
|
||||
(describe "core/ui"
|
||||
(describe "doom|protect-visible-buffer"
|
||||
:var (kill-buffer-query-functions wconf a b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue