 ;; Custom hooks
 ;;
 
+(defvar doom-load-theme-hook nil
+  "Hook run when the theme (and font) is initialized (or reloaded
+with `doom//reload-theme').")
+(define-obsolete-variable-alias 'doom-init-theme-hook 'doom-load-theme-hook "2.1.0")
+
+(defvar doom-before-switch-window-hook nil
+  "Hook run before `switch-window' or `switch-frame' are called. See
+`doom-after-switch-window-hook'.")
+
+(defvar doom-after-switch-window-hook nil
+  "Hook run after `switch-window' or `switch-frame' are called. See
+`doom-before-switch-window-hook'.")
+
+(defvar doom-before-switch-buffer-hook nil
+  "Hook run before `switch-to-buffer' and `display-buffer' are called. See
+`doom-after-switch-buffer-hook'.")
+
+(defvar doom-after-switch-buffer-hook nil
+  "Hook run before `switch-to-buffer' and `display-buffer' are called. See
+`doom-before-switch-buffer-hook'.")
+
 (defun doom*switch-window-hooks (orig-fn &rest args)
   (run-hook-with-args 'doom-before-switch-window-hook)
   (prog1 (apply orig-fn args)

(advice-add #'select-window    :around #'doom*switch-window-hooks)
(advice-add #'switch-to-buffer :around #'doom*switch-buffer-hooks)
(advice-add #'display-buffer   :around #'doom*switch-buffer-hooks)


;;

         (lwarn 'doom-ui :error
                "Unexpected error while initializing fonts: %s"
                (error-message-string ex)))))))

(defun doom|init-theme ()
  "Set the theme and load the font, in that order."
  (when doom-theme
    (load-theme doom-theme t))
  (add-hook 'after-make-frame-functions #'doom|init-theme-in-frame))

;; Getting themes to remain consistent across GUI Emacs, terminal Emacs and
;; daemon Emacs is hairy. `doom|init-theme' sorts out the initial GUI frame.
