Minimize custom-set-faces! clobbering doom-load-theme-hook

Evaluating custom-set-faces! calls would add setter functions to
doom-load-theme-hook indefinitely, which could add up each time you M-x
doom/reload. Now it adds them to a subhook, which is reset whenever Doom
is reloaded.
This commit is contained in:
Henrik Lissner 2020-05-28 17:36:16 -04:00
parent d502c7c06a
commit 95eb2989dc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -9,6 +9,13 @@
`((,(car spec) ((t ,(cdr spec)))))) `((,(car spec) ((t ,(cdr spec))))))
(`((,(car spec) ,(cdr spec)))))) (`((,(car spec) ,(cdr spec))))))
;;;###autoload
(defconst doom-customize-theme-hook nil)
(add-hook! 'doom-load-theme-hook :append
(defun doom-apply-customized-faces-h ()
(run-hooks 'doom-customize-theme-hook)))
;;;###autoload ;;;###autoload
(defmacro 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. "Apply a list of face SPECS as user customizations for THEME.
@ -16,19 +23,19 @@
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-")))
(fset `(progn
fn (lambda () (defun ,fn ()
(let (custom--inhibit-theme-enable) (let (custom--inhibit-theme-enable)
(dolist (theme (doom-enlist (or ,theme 'user))) (dolist (theme (doom-enlist (or ,theme 'user)))
(when (or (eq theme 'user) (when (or (eq theme 'user)
(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)))))))
(when (or doom-init-theme-p (null doom-theme)) (when (or doom-init-theme-p (null doom-theme))
(funcall fn)) (funcall #',fn))
(add-hook 'doom-load-theme-hook fn 'append))) (add-hook 'doom-customize-theme-hook #',fn 'append))))
;;;###autoload ;;;###autoload
(defmacro custom-set-faces! (&rest specs) (defmacro custom-set-faces! (&rest specs)