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: 0b13525252
Ref: #7929
Close: #7933
Co-authored-by: real-or-random <real-or-random@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2024-07-10 15:28:15 -04:00
parent 0b13525252
commit afb9773d7c
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -3,14 +3,18 @@
;;;###autoload
(defconst doom-customize-theme-hook nil)
(add-hook! 'doom-load-theme-hook
(defun doom-apply-customized-faces-h ()
"Run `doom-customize-theme-hook'."
(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))))
(run-hooks 'doom-customize-theme-hook))))
(funcall fn)))
(add-hook! 'doom-load-theme-hook
(defun doom-apply-customized-faces-h ()
"Run `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))))