Reputation: 647
I have a function that sets Emacs' color theme to a theme defined by myself. In this function I do:
(set-face-attribute 'default cur-frame :foreground fg-color :background bg-color)
I then set the background color, foreground color, and cursor color for default-frame-alist
, initial-frame-alist
and special-display-frame-alist
.
All of this works fine on my Mac. But when I use this on Linux, it looks fine for all frames that have already been opened, but on newly created frames it looks like this:
I do not have this problem with new frames if use the set-background-color
/ set-foreground-color
functions instead of (set-face-attribute 'default ...
). But if I do that I have to manually reset the colors for every frame that's already open.
I am using Emacs version 23.3 on both Mac and Ubuntu.
For clarification, this is the theme file I use:
Upvotes: 6
Views: 15479
Reputation: 3482
Emacs uses1) (or does not paint over) the Gtk3.0 theme background in more recent Emacs versions. Changing background using e.g. set-background-color
or default-frame-alist
only works until I resize the window, after which the Gtk theme background "shines through" again.
I have not yet been able to figure out how to get emacs to always paint over the Gtk theme background, but at least I have found a way how to change the Gtk theme background color, for Emacs only: https://superuser.com/questions/699501/emacs-showing-grey-background-where-there-are-no-characters/937749#937749
So this does not fully solve changing the background color when you switch themes, but at least you can get rid of the black-white contrast you experience when opening new frames.
1) on my machine at least :)
Upvotes: 0
Reputation: 647
It seems that it's better to use
(custom-set-faces
'(default ... )
'(region ... )
....
)
style to set faces, this way it will not have that problem.
Upvotes: 1
Reputation: 71
set-face-attribute
sets, as the name suggest, the attributes of a face (i.e., font-related properties), not the attributes of the frame. Use
(add-to-list 'default-frame-alist '(background-color . "lightgray"))
and similar to change frame-related properties.
Upvotes: 6
Reputation: 7951
(if (eq system-type 'darwin)
;; mac os x settings
(if (eq system-type 'gnu/linux)
(setq default-frame-alist '((background-color . "black")
(foreground-color . "gray")))))
something like this should help you maintain settings per OS.
Upvotes: 3