When I'm trying different color themes out, it seems if a particular element is not defined in the new theme the old theme value is retained, and this leads to some clashing. This happens in emacs 24 and also previous versions using color-theme
. Is there a way to reset all colors in between to default so that each color theme looks as intended?

- 1,086
- 2
- 9
- 18
2 Answers
Are you sure that you are using color themes and not Emacs custom themes? Color themes are defined by library color-theme.el
. Custom themes are available starting with Emacs 24 - and they are not the same as color themes.
If you are using color themes then the answer is simple: just enable the pseudo color-theme named
[Reset]
. That completely undoes the theme: removes all effects that it imposed.If you are in fact using Emacs custom themes then the answer is not so simple. You cannot undo the application of a custom theme. What you can do, which will help a lot, is to disable each custom theme, using
disable-theme
, after it has been enabled and before enabling another custom theme.Here are two ways to do this "semi-automatically":
Advise
load-theme
, so that it first disables all custom themes before loading (enabling) another one. This was suggested in this StackOverflow answer by Tungd at tungdao.com.(defadvice load-theme (before theme-dont-propagate activate) (mapcar #'disable-theme custom-enabled-themes))
Define and use a function that disables the current theme before enabling a theme. This was suggested by Maris Orbidans.
(defun enab-theme (theme) (if current-t43m3 (disable-theme current-t43m3)) (setq current-t43m3 theme) (load-theme theme t))
See those original S.O. posts for a little more info, and see the question and other answers to it on the same S.O. page. (Caveat: The accepted answer on that page is not an answer to the problem of undoing a custom theme.)
Be aware that even the solutions described in #2 are not general solutions: they do not undo the application of a custom theme - there is no way to do that. That is, disabling a custom theme does not restore any non-theme customizations (e.g., face changes) that you might have made before enabling that theme and that were overridden by that theme.
In other words, undoing a color theme is trivial; undoing a custom theme is impossible. The best you can do for a custom theme is to disable it relative to other custom themes.
The best reference for this question and for ways of switching (e.g. cycling) among both color and custom themes is the Emacs Wiki page Color and Custom Themes.
And be forewarned: There is a fair amount of misleading information in various places about Emacs custom themes in this regard. People were rightfully excited that Emacs added custom themes as a feature in Emacs 24, and some of them jumped immediately to the mistaken conclusion that custom themes were a replacement for color themes. They are not. Each has some advantages. Not being able to undo is a major disadvantage of custom themes, for example.
[This GNU Emacs bug report is an enhancement request to remedy the inability to undo a custom theme (and thus restore earlier customizations).]
color-theme-dark-laptop
then you manually need to make a snapshot if you want to revert to the previous theme. E.g.(fset 'color-theme-revert (color-theme-make-snapshot))
will give you the commandcolor-theme-revert
to revert. The [Resert] button will not work otherwise. (To test if I am right, do not issue the commandcolor-theme-select
before you change the theme, as this will make the missing snapshot for you) – user4514 May 23 '15 at 11:37customize-themes
UI) if I want to enable more than one theme at the same time. I'm guessing those might be ways of undoing a theme applying in case I change my mind. And I'm also guessing that, with some Lisp, one could keep an auto backup before any enablings. – Charles Roberto Canato Jul 05 '17 at 22:08