Switching between color themes in Emacs ( < v.24)
U开发者_StackOverflow社区pdate:
Note that this thread does not applyt o recent versions of Emacs (24+). Emacs now comes with it's own powerful color theming system (e.g. see a review here) that does not required loading the external package color-theme
.
I have the following code snippet in my .emacs
file, where I defined a few aliases that allow me to switch conveniently between a couple of color themes using short extended commands:
(require 'color-theme)
(eval-after-load "color-theme"
'(progn
(color-theme-initialize)
(color-theme-aalto-light)))
;; Aliases to color-themes, e.g. 'M-x a' switches to color-theme-hober
(defalias 'a 'color-theme-hober)
(defalias 'b 'color-theme-aalto-light)
Now, when Emacs loads, it displays the color-theme-aalto-light
theme properly, and, when I M-x a
to change to color-theme-hober
, that works too.
The problem is when I try to change the color theme back again to color-theme-aalto-light
. Some color faces remain in the old color-theme while others are changed to the new color theme. I have tried with different color theme combinations with no luck (the color faces are not always fully updated, regardless of the color-themes I switch between). Any thoughts?
This is a known bug in 'color-theme' package. If that feature is important for you, consider upgrading to trunk (future emacs-24.1), it natively supports changing themes (M-x customize-themes
).
colour themes are basically just functions, which assign new colours to certain faces. There is nothing special about them, especially faces are not reset before switching colour themes. If one colour theme A sets a colour for a certain face, and another B does not, then B will simply take over the colour defined by A for this face.
This is more or less by design, and there is nothing, you can do about, save modifying the colour themes to cover all defined faces (which is rather tedious, and also quite impossible, because any elisp library can define its own faces).
精彩评论