Permanently override background colour of Emacs theme
I want to use the Emacs theme billw, except with a different background colour.
I have the following in my .emacs
file:
(require 'color-theme)
(color-theme-initialize)
(color-theme-billw)
(set-background-color "gray12")
However this doesn't seem to change the background colour on startup; I need to manually run set-background-color "gray12"
in the minibuffer at the beginning of each session.
Any help with this? I tried creating my own custom theme based on the output of color-theme-print
but this caused more problems than it's worth...
Solution 1:
The color-theme-billw
function internally uses the color-theme-install-frame-params
function to change frame parameters. So you can change frame parameters in the same way as follows:
(require 'color-theme)
(color-theme-initialize)
(color-theme-billw)
(color-theme-install-frame-params
'((background-color . "gray12")))
C-hfcolor-theme-install-frame-params
(color-theme-install-frame-params PARAMS)
Change frame parameters using alist
PARAMETERS
.If
color-theme-is-global
is non-nil, all frames are modified usingmodify-frame-parameters
and thePARAMETERS
are prepended todefault-frame-alist
. The value ofinitial-frame-alist
is not modified. Ifcolor-theme-is-global
is nil, only the selected frame is modified. Ifcolor-theme-is-cumulative
is nil, the frame parameters are restored fromcolor-theme-original-frame-alist
.If the current frame parameters have a parameter
minibuffer
with valueonly
, then the frame parameters are not installed, since this indicates a dedicated minibuffer frame.
Solution 2:
Position your cursor ("point" in GNU Emacs parlance) where you want to set the "background". Preferably where there is no text displayed. Then enter M-x describe-face
.
Emacs will tell you witch face (all that GNU Emacs can display have a "face") you are looking at. Most probably "default". Then in the bottom of the window, click on "you can customize this face".
You are now "in customize". (it is just some sort of wizard to get/set values from/to your ~/.emacs) Set the background color you want, then click on "save for future sessions".
There you have it. Now look at the bottom of your ~/.emacs, inside (custom-set-faces ...)
, this is your face definition.
BTW, color-theme is now somehow built-in GNU Emacs 24. I have this in my .emacs:
(custom-set-variables
...stuff...
'(custom-enabled-themes (quote (tango-dark)))
...stuff...)