Defer evaluation of custom-set-faces!'s arguments

...until the theme has first loaded.

You'll need to set `doom-theme` to nil if you want to use this macro
without a theme!
This commit is contained in:
Henrik Lissner 2019-10-24 19:42:07 -04:00
parent a940d07e4b
commit ee80ed680c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 23 additions and 16 deletions

View file

@ -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