Convert custom-{,theme-}set-faces! to functions

They didn't need to be macros.
This commit is contained in:
Henrik Lissner 2021-05-09 01:18:32 -04:00
parent 9ef708796c
commit cab8f03a51

View file

@ -18,41 +18,41 @@
(`((,(car spec) ,(cdr spec)))))) (`((,(car spec) ,(cdr spec))))))
;;;###autoload ;;;###autoload
(defmacro custom-theme-set-faces! (theme &rest specs) (defun custom-theme-set-faces! (theme &rest specs)
"Apply a list of face SPECS as user customizations for THEME. "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 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." all themes. It will apply to all themes once they are loaded."
(declare (indent defun)) (declare (indent defun))
(let ((fn (gensym "doom--customize-themes-h-"))) (let ((fn (gensym "doom--customize-themes-h-")))
`(progn (fset
(defun ,fn () fn (lambda ()
(let (custom--inhibit-theme-enable) (let (custom--inhibit-theme-enable)
(dolist (theme (doom-enlist (or ,theme 'doom))) (dolist (theme (doom-enlist (or ,theme 'doom)))
(when (or (memq theme '(user doom)) (when (or (memq theme '(user doom))
(custom-theme-enabled-p theme)) (custom-theme-enabled-p theme))
(apply #'custom-theme-set-faces theme (apply #'custom-theme-set-faces theme
(mapcan #'doom--custom-theme-set-face (mapcan #'doom--custom-theme-set-face
(list ,@specs))))))) (list ,@specs))))))))
;; Apply the changes immediately if the user is using the default theme ;; Apply the changes immediately if the user is using the default theme or
;; or the theme has already loaded. This allows you to evaluate these ;; the theme has already loaded. This allows you to evaluate these macros on
;; macros on the fly and customize your faces iteratively. ;; the fly and customize your faces iteratively.
(when (or (get 'doom-theme 'previous-themes) (when (or (get 'doom-theme 'previous-themes)
(null doom-theme)) (null doom-theme))
(funcall #',fn)) (funcall fn))
;; TODO Append to `doom-load-theme-hook' with DEPTH instead when Emacs ;; TODO Append to `doom-load-theme-hook' with DEPTH instead when Emacs 26.x
;; 26.x support is dropped. ;; support is dropped.
(add-hook 'doom-customize-theme-hook #',fn 'append)))) (add-hook 'doom-customize-theme-hook fn 'append)))
;;;###autoload ;;;###autoload
(defmacro custom-set-faces! (&rest specs) (defun custom-set-faces! (&rest specs)
"Apply a list of face SPECS as user customizations. "Apply a list of face SPECS as user customizations.
This is a convenience macro alternative to `custom-set-face' which allows for a This is a convenience macro alternative to `custom-set-face' which allows for a
simplified face format, and takes care of load order issues, so you can use simplified face format, and takes care of load order issues, so you can use
doom-themes' API without worry." doom-themes' API without worry."
(declare (indent defun)) (declare (indent defun))
`(custom-theme-set-faces! 'doom ,@specs)) (apply #'custom-theme-set-faces! 'doom specs))
;;;###autoload ;;;###autoload
(defun doom/reload-theme () (defun doom/reload-theme ()