From afb9773d7c14ffdb06b3d1b8a90d73f19e034d4f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 10 Jul 2024 15:28:15 -0400 Subject: [PATCH] fix(lib): avoid writing customized faces to custom.el (take 3) Wrap doom-customize-theme-hook and use that wrapper also when the local doom--customize-themes-h-* hook is called immediately, otherwise settings will be written to custom-file, which is what I've been trying to avoid with all these takes! Amend: 0b1352525233 Ref: #7929 Close: #7933 Co-authored-by: real-or-random --- lisp/lib/themes.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/lib/themes.el b/lisp/lib/themes.el index 262db832f..00f3655f6 100644 --- a/lisp/lib/themes.el +++ b/lisp/lib/themes.el @@ -3,14 +3,18 @@ ;;;###autoload (defconst doom-customize-theme-hook nil) +(defun doom--run-customize-theme-hook (fn) + "Run FN, but suppress any writes to `custom-file'." + (letf! ((#'custom--should-apply-setting #'ignore) + (defun custom-push-theme (prop symbol theme mode &optional value) + (funcall custom-push-theme prop symbol theme mode value) + (if (facep symbol) (face-spec-set symbol value t)))) + (funcall fn))) + (add-hook! 'doom-load-theme-hook (defun doom-apply-customized-faces-h () "Run `doom-customize-theme-hook'." - (letf! ((#'custom--should-apply-setting #'ignore) - (defun custom-push-theme (prop symbol theme mode &optional value) - (funcall custom-push-theme prop symbol theme mode value) - (if (facep symbol) (face-spec-set symbol value t)))) - (run-hooks 'doom-customize-theme-hook)))) + (run-hook-wrapped 'doom-customize-theme-hook #'doom--run-customize-theme-hook))) (defun doom--normalize-face-spec (spec) (cond ((listp (car spec)) @@ -42,7 +46,7 @@ all themes. It will apply to all themes once they are loaded." ;; macros on the fly and customize your faces iteratively. (when (or (get 'doom-theme 'previous-themes) (null doom-theme)) - (funcall #',fn)) + (doom--run-customize-theme-hook #',fn)) ;; FIXME Prevent clobbering this on-the-fly (add-hook 'doom-customize-theme-hook #',fn 100))))