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.
This commit is contained in:
Henrik Lissner 2018-01-07 00:03:34 -05:00
parent c0680e6fa3
commit 25619908a2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 7 additions and 6 deletions

View file

@ -161,8 +161,8 @@ extension, try to guess one."
;; Auto-close delimiters and blocks as you type ;; Auto-close delimiters and blocks as you type
(def-package! smartparens (def-package! smartparens
:hook (doom-init . smartparens-global-mode)
:config :config
(smartparens-global-mode +1)
(require 'smartparens-config) (require 'smartparens-config)
(setq sp-autowrap-region nil ; let evil-surround handle this (setq sp-autowrap-region nil ; let evil-surround handle this

View file

@ -318,7 +318,7 @@ MODULES is an malformed plist of modules to load."
(require 'server) (require 'server)
(unless (server-running-p) (unless (server-running-p)
(server-start))) (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")))) (message "Doom modules initialized"))))
(defmacro def-package! (name &rest plist) (defmacro def-package! (name &rest plist)

View file

@ -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 ;; Custom init hooks; clearer than `after-init-hook', `emacs-startup-hook', and
;; `window-setup-hook'. ;; `window-setup-hook'.
(defvar doom-init-hook nil (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 (defvar doom-post-init-hook nil
"A list of hooks run after DOOM initialization is complete, and after "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) (defun doom-try-run-hook (fn hook)
"Runs a hook wrapped in a `condition-case-unless-debug' block; its objective "Runs a hook wrapped in a `condition-case-unless-debug' block; its objective

View file

@ -25,7 +25,7 @@ immediately runs it on the current candidate (ending the ivy session)."
(def-package! ivy (def-package! ivy
:init :init
(add-hook 'doom-post-init-hook #'ivy-mode) (add-hook 'doom-init-hook #'ivy-mode)
:config :config
(setq ivy-height 12 (setq ivy-height 12
ivy-do-completion-in-region nil ivy-do-completion-in-region nil

View file

@ -40,7 +40,7 @@ renamed.")
persp-auto-save-opt (if noninteractive 0 1)) persp-auto-save-opt (if noninteractive 0 1))
;; Bootstrap ;; 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 'after-make-frame-functions #'+workspaces|init)
(add-hook 'persp-mode-hook #'+workspaces|init-persp-mode) (add-hook 'persp-mode-hook #'+workspaces|init-persp-mode)
;; only auto-save when real buffers are present ;; only auto-save when real buffers are present