diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index 93a451b0b..327ac581c 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -123,7 +123,7 @@ all hooks after it are ignored.") (defalias 'undefine-key! #'general-unbind) :config ;; Prevent "X starts with non-prefix key Y" errors except at startup. - (add-hook 'doom-after-init-modules-hook #'general-auto-unbind-keys)) + (add-hook 'doom-after-modules-config-hook #'general-auto-unbind-keys)) ;; HACK: `map!' uses this instead of `define-leader-key!' because it consumes @@ -203,7 +203,7 @@ localleader prefix." ;; Bind `doom-leader-key' and `doom-leader-alt-key' as late as possible to give ;; the user a chance to modify them. -(add-hook! 'doom-after-init-modules-hook +(add-hook! 'after-init-hook (defun doom-init-leader-keys-h () "Bind `doom-leader-key' and `doom-leader-alt-key'." (let ((map general-override-mode-map)) diff --git a/lisp/doom-modules.el b/lisp/doom-modules.el index e3262e713..e693d76a8 100644 --- a/lisp/doom-modules.el +++ b/lisp/doom-modules.el @@ -21,13 +21,13 @@ Init files are loaded early, just after Doom core, and before modules' config files. They are always loaded, even in non-interactive sessions, and before -`doom-before-init-modules-hook'. Related to `doom-module-config-file'.") +`doom-before-modules-init-hook'. Related to `doom-module-config-file'.") (defvar doom-module-config-file "config" "The basename of config files for modules. Config files are loaded later, and almost always in interactive sessions. These -run before `doom-init-modules-hook'. Relevant to `doom-module-init-file'.") +run before `doom-after-modules-config-hook'. Relevant to `doom-module-init-file'.") (defconst doom-obsolete-modules '((:feature (version-control (:emacs vc) (:ui vc-gutter)) @@ -75,15 +75,25 @@ your `doom!' block, a warning is emitted before replacing it with :emacs vc and "If non-nil, don't emit deprecated or missing module warnings at startup.") ;;; Custom hooks -(defvar doom-before-init-modules-hook nil - "A list of hooks to run before Doom's modules' config.el files are loaded, but -after their init.el files are loaded.") +(defcustom doom-before-modules-init-hook nil + "Hooks run before module init.el files are loaded." + :group 'doom + :type 'hook) -(defvar doom-init-modules-hook nil - "A list of hooks to run after Doom's modules' config.el files have loaded, but -before the user's private module.") +(defcustom doom-after-modules-init-hook nil + "Hooks run after module init.el files are loaded." + :group 'doom + :type 'hook) -(defvaralias 'doom-after-init-modules-hook 'after-init-hook) +(defcustom doom-before-modules-config-hook nil + "Hooks run before module config.el files are loaded." + :group 'doom + :type 'hook) + +(defcustom doom-after-modules-config-hook nil + "Hooks run after module config.el files are loaded (but before the user's)." + :group 'doom + :type 'hook) (defvar doom--current-module nil) (defvar doom--current-flags nil) @@ -120,11 +130,13 @@ of Dooming. Will noop if used more than once, unless FORCE-P is non-nil." (doom-initialize-core-modules)) (when-let (init-p (load! doom-module-init-file doom-user-dir t)) (doom-log "Initializing user config") + (doom-run-hooks 'doom-before-module-init-hook) (maphash (doom-module-loader doom-module-init-file) doom-modules) - (doom-run-hooks 'doom-before-init-modules-hook) + (doom-run-hooks 'doom-after-module-init-hook) (unless no-config-p + (doom-run-hooks 'doom-before-module-config-hook) (maphash (doom-module-loader doom-module-config-file) doom-modules) - (doom-run-hooks 'doom-init-modules-hook) + (doom-run-hooks 'doom-after-module-config-hook) (load! "config" doom-user-dir t) (when custom-file (load custom-file 'noerror (not doom-debug-mode))))))) @@ -457,21 +469,6 @@ packages are installed, `doom-autoloads-file' is loaded, `doom-packages-file' cache exists (and is loaded) and, finally, loads your private init.el (which should contain your `doom!' block). -The overall load order of Doom is as follows: - - ~/.emacs.d/init.el - ~/.emacs.d/lisp/doom.el - $DOOMDIR/init.el - {$DOOMDIR,~/.emacs.d}/modules/*/*/init.el - `doom-before-init-modules-hook' - {$DOOMDIR,~/.emacs.d}/modules/*/*/config.el - `doom-init-modules-hook' - $DOOMDIR/config.el - `doom-after-init-modules-hook' - `after-init-hook' - `emacs-startup-hook' - `window-setup-hook' - 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)." diff --git a/lisp/doom.el b/lisp/doom.el index 49d5d3507..e693fd3c0 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -36,12 +36,13 @@ ;; $EMACSDIR/lisp/doom.el ;; $EMACSDIR/lisp/doom-start.el ;; $DOOMDIR/init.el +;; `doom-before-modules-init-hook' ;; {$DOOMDIR,~/.emacs.d}/modules/*/*/init.el -;; `doom-before-init-modules-hook' +;; `doom-after-modules-init-hook' +;; `doom-before-modules-config-hook' ;; {$DOOMDIR,~/.emacs.d}/modules/*/*/config.el -;; `doom-init-modules-hook' +;; `doom-after-modules-config-hook' ;; $DOOMDIR/config.el -;; `doom-after-init-modules-hook' ;; `after-init-hook' ;; `emacs-startup-hook' ;; `doom-init-ui-hook' diff --git a/lisp/lib/sandbox.el b/lisp/lib/sandbox.el index 86d728e84..e55f87920 100644 --- a/lisp/lib/sandbox.el +++ b/lisp/lib/sandbox.el @@ -109,9 +109,12 @@ :path (doom-module-locate-path (car key) (cdr key)))) doom-modules) (--run--) + (doom-run-hooks 'doom-before-modules-init-hook) (maphash (doom-module-loader doom-module-init-file) doom-modules) + (doom-run-hooks 'doom-after-modules-init-hook) + (doom-run-hooks 'doom-before-modules-config-hook) (maphash (doom-module-loader doom-module-config-file) doom-modules) - (doom-run-hooks 'doom-init-modules-hook))) + (doom-run-hooks 'doom-after-modules-config-hook))) (`vanilla-doom ; only Doom core `(progn (load-file ,(expand-file-name "doom.el" doom-core-dir)) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index 3b6802c00..e99caec42 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -29,7 +29,7 @@ directives. By default, this only recognizes C directives.") (defvar evil-respect-visual-line-mode nil) (use-package! evil - :hook (doom-init-modules . evil-mode) + :hook (doom-after-modules-config . evil-mode) :demand t :preface (setq evil-ex-search-vim-style-regexp t @@ -77,7 +77,7 @@ directives. By default, this only recognizes C directives.") (advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1))) ;; Done in a hook to ensure the popup rules load as late as possible - (add-hook! 'doom-init-modules-hook + (add-hook! 'doom-after-modules-config-hook (defun +evil--init-popup-rules-h () (set-popup-rules! '(("^\\*evil-registers" :size 0.3) @@ -85,7 +85,7 @@ directives. By default, this only recognizes C directives.") ;; Change the cursor color in emacs state. We do it this roundabout way ;; to ensure changes in theme doesn't break these colors. - (add-hook! '(doom-load-theme-hook doom-init-modules-hook) + (add-hook! '(doom-load-theme-hook doom-after-modules-config-hook) (defun +evil-update-cursor-color-h () (put 'cursor 'evil-emacs-color (face-foreground 'warning)) (put 'cursor 'evil-normal-color (face-background 'cursor)))) diff --git a/modules/editor/god/config.el b/modules/editor/god/config.el index 60d692ab2..ea80836f9 100644 --- a/modules/editor/god/config.el +++ b/modules/editor/god/config.el @@ -1,7 +1,7 @@ ;;; editor/god/config.el -*- lexical-binding: t; -*- (use-package! god-mode - :hook (doom-after-init-modules . god-mode-all) + :hook (doom-after-modules-init . god-mode-all) :config (add-hook 'post-command-hook #'+god--configure-cursor-and-modeline-h) (add-hook 'overwrite-mode-hook #'+god--toggle-on-overwrite-h) diff --git a/modules/input/layout/config.el b/modules/input/layout/config.el index 004fa4098..5cea76d1e 100644 --- a/modules/input/layout/config.el +++ b/modules/input/layout/config.el @@ -1,6 +1,6 @@ ;;; input/layout/config.el -*- lexical-binding: t; -*- -(add-hook! 'doom-init-modules-hook +(add-hook! 'doom-after-modules-config-hook (defun +layout-init-h () (cond ((modulep! +bepo) (load! "+bepo")) diff --git a/modules/lang/common-lisp/config.el b/modules/lang/common-lisp/config.el index 91a0f5727..39a6f65cd 100644 --- a/modules/lang/common-lisp/config.el +++ b/modules/lang/common-lisp/config.el @@ -33,8 +33,7 @@ ;; HACK Ensures that sly's contrib modules are loaded as soon as possible, but ;; also as late as possible, so users have an opportunity to override ;; `sly-contrib' in an `after!' block. - (add-hook! 'doom-after-init-modules-hook - (after! sly (sly-setup))) + (add-hook! 'after-init-hook (after! sly (sly-setup))) :config (setq sly-mrepl-history-file-name (concat doom-cache-dir "sly-mrepl-history")