Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to update modeline when switching themes? #63

Open
SophieBosio opened this issue Oct 9, 2023 · 9 comments
Open

[Question] How to update modeline when switching themes? #63

SophieBosio opened this issue Oct 9, 2023 · 9 comments

Comments

@SophieBosio
Copy link

Hi,

I have an issue where the colour of the modeline does not update when switching themes.

Here is a screenshot of the theme I use on start-up, the doom-nord theme.

image

And here is a screenshot after switching to ef-maris-light, where the modeline retains the doom-nord colours.

image

This problem is persistent with all themes. For instance, if I use ef-maris-light on start-up and switch to doom-nord, then doom-nord will have a ef-maris-light-coloured modeline.

I had some issues with lingering borders when switching themes, so in my configuration, I have this code snippet that advices load-theme to always disable the current theme when switching themes. This has resolved the issue for borders and other UI elements, such as source code blocks in Org-documents, but does not seem to affect nano-modeline. Removing this snippet also does not resolve the nano-modeline issue.

(defadvice load-theme
  (before disable-before-load (theme &optional no-confirm no-enable) activate)
  (mapc 'disable-theme custom-enabled-themes))

I would really appreciate any help! My full config is also available https://github.com/SophieBosio/.emacs.d.

@rougier
Copy link
Owner

rougier commented Oct 13, 2023

I think the problem is quite generic and the solution you've found seems to be the "official" one:

The reason might be that some theme do not modify everything (nor does nano-modeline) such that if a theme modify something that is not overwritten by the new theme, it will remains as it is (i.e. from previous theme)

@SophieBosio
Copy link
Author

Thank you for the response! Seems like it is indeed a question of what things the new theme modifies when switching.

I also noticed that the nano themes do in fact change the colour of the modeline, so when I want to switch to a theme that doesn't update the modeline colour, so a hacky solution is to always change to a nano theme before changing to a different theme. E.g., to change from doom-nord to ef-maris-light, I can first change to nano-light and then to ef-maris-light. Then the modeline colour is fitting even if it's not the exact colour of the theme I'm using.

@rougier
Copy link
Owner

rougier commented Oct 13, 2023

Did you try (disable-theme 'nano-theme)? (never tested though)

@SophieBosio
Copy link
Author

That's interesting! When I switch from doom-nord to nano-light everything including the modeline updates. Then, if I run M-x disable-theme RET nano-theme RET, the theme switches to the Emacs default but the doom-nord modeline colours come back. So somehow, it seems that the theme used at startup is the modeline's "fallback" colours.

Putting (disable-theme 'nano-theme) in the load-theme advice didn't seem to have any effect, unfortunately.

@rougier
Copy link
Owner

rougier commented Oct 13, 2023

Hum, maybe I set some settings without using the custom machinery, that may explain things. I need to have a closer look at the sources.

@SophieBosio
Copy link
Author

Thank you for looking into this, I appreciate it!

@rougier
Copy link
Owner

rougier commented Oct 13, 2023

Ok, now I remember: #54
This means I need to remove the indirect mechanism in favor of regular faces.
I'll re-open the issue since I'm not too sure when I can make the change.
Don't hesitate to ping me here to enquiry about any advance.

@rougier rougier reopened this Oct 13, 2023
@PavelNovichkov
Copy link

PavelNovichkov commented Sep 6, 2024

A workaround that works for me is to explicitly reset nano-modeline-active face to its default value after switching themes:

(defun my/nano-modeline-update (&rest _)
    "Update nano-modeline active face."
    (custom-set-faces
     `(nano-modeline-active
       ((t (:foreground ,(face-foreground 'default)
            :background ,(face-background 'header-line nil t)
            :box (:line-width 1 :color ,(face-background 'default))))))))
(add-hook 'enable-theme-functions #'my/nano-modeline-update)

@rougier
Copy link
Owner

rougier commented Oct 21, 2024

Thanks for the fix. By the way, I've been working on a new branch (rewrite) that simplify things but in the meantime there is no more active/inactive faces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants