diff --git a/core/autoload/themes.el b/core/autoload/themes.el index 6000e4c4c..e6f74c80a 100644 --- a/core/autoload/themes.el +++ b/core/autoload/themes.el @@ -10,31 +10,34 @@ (`((,(car spec) ,(cdr spec)))))) ;;;###autoload -(defun custom-theme-set-faces! (theme &rest specs) +(defmacro custom-theme-set-faces! (theme &rest specs) "Apply a list of face SPECS as user customizations for THEME. THEME can be a single symbol or list thereof. If nil, apply these settings to all themes. It will apply to all themes once they are loaded." - (let* ((themes (doom-enlist (or theme 'user))) - (fn (gensym (format "doom--customize-%s-h-" (mapconcat #'symbol-name themes "-"))))) - (fset fn - (lambda () - (dolist (theme themes) - (when (or (eq theme 'user) - (custom-theme-enabled-p theme)) - (apply #'custom-theme-set-faces 'user - (mapcan #'doom--custom-theme-set-face - specs)))))) - (funcall fn) - (add-hook 'doom-load-theme-hook fn))) + (declare (indent defun)) + `(let* ((themes (doom-enlist (or (list ,theme) 'user))) + (fn (gensym (format "doom--customize-%s-h-" (mapconcat #'symbol-name themes "-"))))) + (fset + fn (lambda () + (dolist (theme themes) + (when (or (eq theme 'user) + (custom-theme-enabled-p theme)) + (apply #'custom-theme-set-faces 'user + (mapcan #'doom--custom-theme-set-face + (list ,@specs))))))) + (when (or doom-init-theme-p (null doom-theme)) + (funcall fn)) + (add-hook 'doom-load-theme-hook fn 'append))) ;;;###autoload -(defun custom-set-faces! (&rest specs) +(defmacro custom-set-faces! (&rest specs) "Apply a list of face SPECS as user customizations. This is a drop-in replacement for `custom-set-face' that allows for a simplified face format." - (apply #'custom-theme-set-faces! 'user specs)) + (declare (indent defun)) + `(custom-theme-set-faces! 'user ,@specs)) (defvar doom--prefer-theme-elc) ;;;###autoload diff --git a/core/core-ui.el b/core/core-ui.el index c795e477e..0bb878b04 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -3,6 +3,9 @@ ;; ;;; Variables +(defvar doom-init-theme-p nil + "If non-nil, a theme as been loaded.") + (defvar doom-theme nil "A symbol representing the Emacs theme to load at startup. @@ -633,7 +636,8 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.") "Set up `doom-load-theme-hook' to run after `load-theme' is called." :after-while #'load-theme (unless no-enable - (setq doom-theme theme) + (setq doom-theme theme + doom-init-theme-p t) (run-hooks 'doom-load-theme-hook))) (defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args)