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

background mode/color, foreground color incorrect after modus-themes-toggle #120

Open
shipmints opened this issue Nov 6, 2024 · 7 comments

Comments

@shipmints
Copy link

shipmints commented Nov 6, 2024

This is Emacs 29.4. I haven't yet tried it on an Emacs 30 build and latest ELPA modus-themes-20241028.849.

Starting with vivendi from a clean restart.

image

M-x modus-themes-toggle to operandi.

image

Now M-x make-frame with operandi in effect. The new frame is screwed up.

image

I've added this stanza to solve the issue.

    ;; these parameters are not correctly copied by make-frame.
    (add-to-list 'frame-inherited-parameters 'background-mode)
    (add-to-list 'frame-inherited-parameters 'background-color)
    (add-to-list 'frame-inherited-parameters 'foreground-color)

Now after the toggle, the new frame looks fine:

image

FYI, clone-frame works fine but not make-frame.

@protesilaos
Copy link
Owner

protesilaos commented Nov 7, 2024 via email

@shipmints
Copy link
Author

Did you try this on a Mac? If you can explain how theme-oriented frame variables are propagated when a new frame is created under normal circumstances, I can try to track down what's going on. If this turns out to be Mac (NS) specific, that might be a hint.

@protesilaos
Copy link
Owner

protesilaos commented Nov 8, 2024 via email

@shipmints
Copy link
Author

I've tracked it down to the below snippet, but it's not clear why this interferes with theme switching. Perhaps you have sufficient depth in this area to illuminate what Emacs is doing.

The below is executed before modus-themes are enabled (I have an option to run themeless, so sensible defaults make sense to set). If I comment out background and foreground (or set them explicitly to 'unspecified), theme switching works fine on new frames. Why would setting the default face interfere with themes only on new frames but not the current frame where the theme is enabled? Don't themes override the default face? If Emacs has a default face takes precedence over a theme default face, it should also appear to interfere on the first frame. There's nothing explicit that I can see to control this behavior.

(set-face-attribute 'default nil
                    :family "Inconsolata"
                    :height 200
                    :weight 'normal
                    :width 'normal
                    :slant 'normal
                    :background "#101010"
                    :foreground "white" ; use theme foreground
                    :inherit nil :extend nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil)

If this turns out to be interfering with theming for other people, it might make sense to add something to the documentation to suggest to avoid setting background and foreground if they want themes to take precedence on all frames. In my case, at least I can now set these conditionally on themes being enabled. But why...is this Mac/NS specific behavior? Thanks for your assistance in solving this mystery.

@shipmints
Copy link
Author

shipmints commented Nov 9, 2024

Related Emacs theme behavior differences GUI to tty of which to be aware since you're the de facto Emacs theme master: alphapapa/prism.el#32 (comment)

@protesilaos
Copy link
Owner

protesilaos commented Nov 10, 2024 via email

@shipmints
Copy link
Author

Seems like Eli thinks the "feature" is intended. Perhaps a user option, then, to control the behavior is a step toward normalizing it. That Emacs on tty resets the default face bg and fg to undefined is a bit unexpected as Adam has to guard against in prism and the documentation suggests that can not happen.

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

2 participants