Closed domsch1988 closed 1 month ago
From: domsch1988 @.***> Date: Thu, 25 Jul 2024 04:19:25 -0700
I have some custom faces defined for my modeline. To make them fit the modus themes, i'm using modus-themes-get-color-value to assigne foreground and background colors:
(defface domline-highlight `((t :height 120 :foreground ,(modus-themes-get-color-value 'bg-main) :background ,(modus-themes-get-color-value 'modeline-info))) "Domline Highlight Face")
Since you are using 'modus-themes-get-color-value' multiple times, it is probably simpler to wrap your code in the 'modus-themes-with-colors' macro.
Here is the idea:
(defface domline-highlight
(modus-themes-with-colors
`((t :height 120 :foreground ,bg-main :background ,modeline-info)))
"Domline Highlight Face")
[... 6 lines elided]
But the colors don't update on toggeling the theme. Running load-file on my init file after changing theme also doesn't work. I have to specifically go into the file where the defface statements are and run eval-defun on those. Even running eval-buffer on the file doesn't work.
There are two ways to go about it. Either you will expand the definition of your faces to include light and dark variants OR you will write a function that updates the colours after a new theme is loaded. I think the latter approach is easier to apply to more situations, so here it is:
(defun my-modus-themes-update-faces (&rest _)
(modus-themes-with-colors
(set-face-attribute 'domline-highlight nil
:foreground bg-main :background modeline-info)))
(add-hook 'enable-theme-functions 'my-modus-themes-update-faces)
There are examples like this one in the manual, but let me know if you need me to expand it further.
-- Protesilaos Stavrou https://protesilaos.com
Both of these work perfectly. Hooking the face update to the theme change was what i was looking at, but couldn't exactly figure out how to do that. This does the job, Thanks!
From: domsch1988 @.***> Date: Thu, 25 Jul 2024 22:57:28 -0700
Both of these work perfectly. Hooking the face update to the theme change was what i was looking at, but couldn't exactly figure out how to do that. This does the job, Thanks!
You are welcome!
-- Protesilaos Stavrou https://protesilaos.com
I have some custom faces defined for my modeline. To make them fit the modus themes, i'm using modus-themes-get-color-value to assigne foreground and background colors:
This works fine on initially loading emacs. But the colors don't update on toggeling the theme. Running load-file on my init file after changing theme also doesn't work. I have to specifically go into the file where the defface statements are and run eval-defun on those. Even running eval-buffer on the file doesn't work.
Is there any way to Update these values after a theme change? Or am i better of "repurposing" another face and changing that with overrides to what i want? My entire config is here if it helps: https://gitlab.com/domsch1988/minemacs