fix(lib): avoid writing customized faces to custom.el
`custom-theme-set-faces!` calls `custom-theme-set-faces`, which will mark the customizations for saving to custom.el. But `custom-theme-set-faces!` is not intended for permanent customizations. I fix this by setting `custom--inhibit-theme-enable` to prevent some of the extra work `custom-theme-set-faces` does around changing faces, and call face-spec-set manually. Also renames doom--custome-theme-set-face to doom--normalize-face-space, to better reflect what it does. Close: #7929 Co-authored-by: real-or-random <real-or-random@users.noreply.github.com>
This commit is contained in:
parent
b4b1b48e26
commit
68771150ba
1 changed files with 12 additions and 9 deletions
|
@ -6,13 +6,17 @@
|
||||||
(add-hook! 'doom-load-theme-hook
|
(add-hook! 'doom-load-theme-hook
|
||||||
(defun doom-apply-customized-faces-h ()
|
(defun doom-apply-customized-faces-h ()
|
||||||
"Run `doom-customize-theme-hook'."
|
"Run `doom-customize-theme-hook'."
|
||||||
(run-hooks 'doom-customize-theme-hook)))
|
(letf! (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)))
|
||||||
|
(let ((custom--inhibit-theme-enable t))
|
||||||
|
(run-hooks 'doom-customize-theme-hook)))))
|
||||||
|
|
||||||
(defun doom--custom-theme-set-face (spec)
|
(defun doom--normalize-face-spec (spec)
|
||||||
(cond ((listp (car spec))
|
(cond ((listp (car spec))
|
||||||
(cl-loop for face in (car spec)
|
(cl-loop for face in (car spec)
|
||||||
collect
|
collect
|
||||||
(car (doom--custom-theme-set-face (cons face (cdr spec))))))
|
(car (doom--normalize-face-spec (cons face (cdr spec))))))
|
||||||
((keywordp (cadr spec))
|
((keywordp (cadr spec))
|
||||||
`((,(car spec) ((t ,(cdr spec))))))
|
`((,(car spec) ((t ,(cdr spec))))))
|
||||||
(`((,(car spec) ,(cdr spec))))))
|
(`((,(car spec) ,(cdr spec))))))
|
||||||
|
@ -27,13 +31,12 @@ all themes. It will apply to all themes once they are loaded."
|
||||||
(let ((fn (gensym "doom--customize-themes-h-")))
|
(let ((fn (gensym "doom--customize-themes-h-")))
|
||||||
`(progn
|
`(progn
|
||||||
(defun ,fn ()
|
(defun ,fn ()
|
||||||
(let (custom--inhibit-theme-enable)
|
|
||||||
(dolist (theme (ensure-list (or ,theme 'user)))
|
(dolist (theme (ensure-list (or ,theme 'user)))
|
||||||
(when (or (eq theme 'user)
|
(if (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--normalize-face-spec
|
||||||
(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 the theme has already loaded. This allows you to evaluate these
|
;; or the theme has already loaded. This allows you to evaluate these
|
||||||
;; macros on the fly and customize your faces iteratively.
|
;; macros on the fly and customize your faces iteratively.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue