From 25619908a27c9ceba176553ffade2ee345dab913 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 7 Jan 2018 00:03:34 -0500 Subject: [PATCH] Narrow down the purpose of init & post-init hooks Essential hooks should be added to doom-init-hook. Non-essential and extra hooks should be added to doom-psot-init-hook. --- core/core-editor.el | 2 +- core/core-packages.el | 2 +- core/core.el | 5 +++-- modules/completion/ivy/config.el | 2 +- modules/feature/workspaces/config.el | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/core-editor.el b/core/core-editor.el index a53f9b254..4a882a67c 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -161,8 +161,8 @@ extension, try to guess one." ;; Auto-close delimiters and blocks as you type (def-package! smartparens - :hook (doom-init . smartparens-global-mode) :config + (smartparens-global-mode +1) (require 'smartparens-config) (setq sp-autowrap-region nil ; let evil-surround handle this diff --git a/core/core-packages.el b/core/core-packages.el index 812b8e440..d05ed10aa 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -318,7 +318,7 @@ MODULES is an malformed plist of modules to load." (require 'server) (unless (server-running-p) (server-start))) - (add-hook 'doom-init-hook #'doom-packages--display-benchmark t) + (add-hook 'doom-post-init-hook #'doom-packages--display-benchmark t) (message "Doom modules initialized")))) (defmacro def-package! (name &rest plist) diff --git a/core/core.el b/core/core.el index 61d222d76..ce7b07ea4 100644 --- a/core/core.el +++ b/core/core.el @@ -122,11 +122,12 @@ melodramatic ex-vimmer disappointed with the text-editor status quo." ;; Custom init hooks; clearer than `after-init-hook', `emacs-startup-hook', and ;; `window-setup-hook'. (defvar doom-init-hook nil - "A list of hooks run when DOOM is initialized, before `doom-post-init-hook'.") + "A list of hooks run when DOOM is initialized, before `doom-post-init-hook'. +Use this for essential functionality.") (defvar doom-post-init-hook nil "A list of hooks run after DOOM initialization is complete, and after -`doom-init-hook'.") +`doom-init-hook'. Use this for extra, non-essential functionality.") (defun doom-try-run-hook (fn hook) "Runs a hook wrapped in a `condition-case-unless-debug' block; its objective diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 139a7dbf0..d860a3a57 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -25,7 +25,7 @@ immediately runs it on the current candidate (ending the ivy session)." (def-package! ivy :init - (add-hook 'doom-post-init-hook #'ivy-mode) + (add-hook 'doom-init-hook #'ivy-mode) :config (setq ivy-height 12 ivy-do-completion-in-region nil diff --git a/modules/feature/workspaces/config.el b/modules/feature/workspaces/config.el index ecb41dd47..3e3cdcbd9 100644 --- a/modules/feature/workspaces/config.el +++ b/modules/feature/workspaces/config.el @@ -40,7 +40,7 @@ renamed.") persp-auto-save-opt (if noninteractive 0 1)) ;; Bootstrap - (add-hook 'doom-post-init-hook #'+workspaces|init) + (add-hook 'doom-init-hook #'+workspaces|init) (add-hook 'after-make-frame-functions #'+workspaces|init) (add-hook 'persp-mode-hook #'+workspaces|init-persp-mode) ;; only auto-save when real buffers are present