23

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?

19

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.

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

  2. 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":

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

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

  • 1
    You could also add, that if you select a color theme using a command like 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 command color-theme-revert to revert. The [Resert] button will not work otherwise. (To test if I am right, do not issue the command color-theme-select before you change the theme, as this will make the missing snapshot for you) – user4514 May 23 '15 at 11:37
  • Please note, helm-themes will automatically disable other themes when selecting a new one. – ocodo Jul 2 '15 at 1:11
  • 1
    @EmacsFodder: If you are talking about custom themes then disabling other themes is not enough. You cannot necessarily return to the initial state that existed before enabling any custom themes. This problem does not exist for color themes - you can take a snapshot of the initial state and return to it. See the cited EmacsWiki page and the cited bug report. There is no magic silver bullet here, Helm or otherwise. It is because of (a flaw in) the way custom themes were designed. – Drew Jul 2 '15 at 1:35
  • @JSG: Yes, to be able to return to the initial state, before enabling any color themes, you should create a snapshot of it (which amounts to a pseudo color theme). That is explained in the cited EmacsWiki page and the cited Emacs bug report. So yes, you might need to think ahead, but at least it is possible to get back to that state. This feature is missing for custom themes - disabling custom themes does not take you back to the initial state. – Drew Jul 2 '15 at 1:38
  • This was valuable info for me about their differences, as I've never touched the subject before on Emas, so thanks! Just for the sake of additional and updated info, as of July 2016 on Emacs 25.2.1, now it seems you can save your own settings as a theme also - or at least, Emacs here let me do it. Also, I must explicitly indicate (on customize-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 5 '17 at 22:08
-2

If you selected one of the built-in themes from M-x customize-themes, simply comment out the lines that enable the custom theme in your ~/.emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.