Last active
May 30, 2020 13:18
-
-
Save hlissner/1ace77658c772cf150a43dc9396fa2ed to your computer and use it in GitHub Desktop.
Convenience macro for additively setting face attributes in Doom Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro custom-theme-set-faces! (theme &rest specs) | |
"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 | |
all themes. It will apply to all themes once they are loaded. | |
(custom-theme-set-faces! '(doom-one doom-one-light) | |
`(mode-line :foreground ,(doom-color 'blue)) | |
`(mode-line-buffer-id :foreground ,(doom-color 'fg) :background \"#000000\") | |
'(mode-line-success-highlight :background \"#00FF00\") | |
'(org-tag :background \"#4499FF\") | |
'(org-ellipsis :inherit org-tag) | |
'(which-key-docstring-face :inherit font-lock-comment-face))" | |
`(let* ((themes (doom-enlist (or ,theme 'user))) | |
(fn (gensym (format "doom|customize-%s-" (mapconcat #'symbol-name themes "-"))))) | |
(fset fn | |
(lambda () | |
(dolist (theme themes) | |
(when (or (eq theme 'user) | |
(custom-theme-enabled-p theme)) | |
(apply #'custom-theme-set-faces 'user | |
(cl-loop for (face . spec) in (list ,@specs) | |
if (keywordp (car spec)) | |
collect `(,face ((t ,spec))) | |
else collect `(,face ,spec))))))) | |
(funcall fn) | |
(add-hook 'doom-load-theme-hook fn))) | |
(defmacro custom-set-faces! (&rest specs) | |
"Apply a list of face specs as user customizations. | |
SPECS is a list of face specs. | |
This is a drop-in replacement for `custom-set-face' that allows for a simplified | |
face format, e.g. | |
(custom-set-faces! | |
`(mode-line :foreground ,(doom-color 'blue)) | |
`(mode-line-buffer-id :foreground ,(doom-color 'fg) :background \"#000000\") | |
'(mode-line-success-highlight :background \"#00FF00\") | |
'(org-tag :background \"#4499FF\") | |
'(org-ellipsis :inherit org-tag) | |
'(which-key-docstring-face :inherit font-lock-comment-face))" | |
`(custom-theme-set-faces! 'user ,@specs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These depend on
doom-load-theme-hook
, which is implemented like so: