7

Update:

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?

Community
  • 1
  • 1
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
  • Sometimes one theme defines a colour and the other doesn't. When switching those then remain when switching the colour theme. Could you check whether both themes define the colours which don't get changed? – nominolo Feb 06 '11 at 15:38
  • Cycle among color themes. Complete to choose color themes... http://www.emacswiki.org/emacs/ColorTheme#toc4 – Drew Aug 20 '11 at 16:17

2 Answers2

9

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).

Victor Deryagin
  • 11,895
  • 1
  • 29
  • 38
  • 1
    Actually, Emacs custom themes suffer worse than color themes from this. Or rather, they suffer differently. You can completely "disable" one custom theme relative to another, but you *cannot undo* a custom theme and thus restore the non-themed appearance that was there before. You can, for the most part, undo a color theme. Another disadvantage of custom-theme switching is that it is *very SLOW*, especially if you have several frames. Color-them switching is very fast. – Drew Oct 28 '13 at 20:11
2

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).

  • And this lightweight design can also be an advantage, especially wrt (a) interacting with other, non-theme customizations and (b) switching among themes. – Drew Oct 28 '13 at 20:13