Closed ghost closed 9 years ago
You could actually set the light variant by setting the variable (setq frame-background-mode 'light)
before loading the solarized theme.
I'm now trying to do the opposite, enable dark mode on all buffers. The relevant section of my .emacs is:
(add-to-list 'custom-theme-load-path "~/.emacs.d/emacs-color-theme-solarized/")
(setq frame-background-mode 'dark)
(load-theme 'solarized t)
Which still results in a 'light' color theme:
What am I missing?
Update: If I reload my .emacs, it works. I'm entirely lost as to why.
@ddaygold, would you try adding (set-frame-parameter nil 'background-mode 'dark)
?
replacing (setq frame-background-mode 'dark)
with (set-frame-parameter nil 'background-mode 'dark)
worked, thank you.
@visualisierte Did this work for you?
@sellout I want to set 'light' theme as default, too. I put the following code in my init.el:
(require 'color-theme-solarized)
(color-theme-solarized)
(set-frame-parameter nil 'background-mode 'light)
(load-theme 'solarized t)
But my emacs is still dark
You’re using GUI emacs, right? Not in a term? (It looks that way in the screenshot, but just want to make sure.)
A couple things here – you don’t need (require 'color-theme)
, (require 'color-theme-solarized)
, or (color-theme-solarized)
unless you’re on Emacs 23 or older, and it seems like you’re not, because if you were, (load-theme 'solarized t)
wouldn’t work.
Try getting rid of those first three lines and see if it’s any better – I wouldn’t be surprised if the old color-themes stuff is trampling over the newer Emacs 24 themes stuff.
Also, I’m not a fan of (set-frame-parameter nil 'background-mode 'light)
(although I think it’s what the readme currently recommends) because it operates only on the current frame. I prefer adding (background-mode . light)
to the default-frame-alist
so that it affects all frames.
@sellout Thanks for you help! I succeed. I use Emacs 25.0.50.1 with OSX 10.10.3.
I still find that Aquamacs (version 3.3) gets stuck with a dark background. I can evaluate the following form to attempt to set the background to light:
(set-frame-parameter nil 'background-mode 'light)
Afterward, evaluating
(frame-parameter nil 'background-mode)
yields light
, but evaluating neither (load-theme 'solarized t)
nor (enable-theme 'solarized)
will honor the newly requested light background-mode
value. I've tried interspersing (frame-set-background-mode nil)
at various stages too, but it doesn't seem to change anything.
Another point: Though this doesn't happen every time, often even when frame-parameter nil 'background-mode)
evaluates to light
before evaluating (enable-theme 'solarized)
, afterward it will evaluate to dark
again. In other words, enable-theme
changes the mode back to dark
.
Do you have any other advice to force Emacs to honor the current backrgound-mode
value?
I currently have a function that does:
(set-terminal-parameter frame 'background-mode mode)
(setq frame-background-mode mode)
(frame-set-background-mode frame)
Relative to the README, this eliminates the annoying flash of the other theme at emacsclient
startup and is honoured immediately if I re-run it and change mode
. I'm not sure if the terminal parameter is still needed or which versions of Emacs this supports.
@seh: I think that frame-set-background-mode
looks at frame-background-mode
but not the background-mode
property of the frame (it sets this property). It does indeed sound like default-frame-alist
might be the more proper way. Would be great if the README reflected current best practice.
@sambrightman, trying it again today, with frame-set-background-mode
called right after setting frame-background-mode
, I find that it works better.
The weird thing is that frame-background-mode
is not "frame-local", but the effect of frame-set-background-mode
is. It's quite difficult to arrange for one frame to have a light background and one to have a dark background without remembering which frames last saw which frame-background-mode
value.
I have put the following code in my init.el: (add-to-list 'custom-theme-load-path "~/.emacs.d/emacs-color-theme-solarized") (load-theme 'solarized t)
When i start emacs (in a terminal) the dark theme is set. How is it possible to always set the light theme as default?