32

I have the following code in my .emacs:

(if (null window-system)
  (progn
    (require 'color-theme)
    (color-theme-initialize)
    (color-theme-simple-1)))

When I open Emacs on the console, I can verify that the progn block runs (by a (message "Got here.")), and I see a flash that suggests that the color theme was loaded, but if it was loaded, it is overridden by something else. If, after loading, I open my .emacs file and submit the block above using C-x C-e, it works. I've tried doing:

(add-hook 'after-init-hook
          (lambda ()
            (progn
              (require 'color-theme)
              (color-theme-initialize)
              (color-theme-simple-1))))

but that acts the same.

It may be relevant that I'm using Emacs 24, and that this code is not in my .emacs, but in ~/Dropbox/.emacs, which is loaded from my .emacs.


An additional note: I've tried M-x customize-themes, but none of those work acceptably on the console. They either produce a nearly unreadable light theme, or most of the text is invisible.

Grzegorz Rożniecki
  • 27,415
  • 11
  • 90
  • 112
JasonFruit
  • 7,764
  • 5
  • 46
  • 61

2 Answers2

49

Emacs 24 has built-in theming, which doesn't use statements like (require 'color-theme). As Drew points out in the comments, there are differences between color themes and custom themes, and the new direction is towards the latter. Try M-x customize-themes to take a look. From .emacs, you can do things like (load-theme 'wombat t).

But...

It may still be going wrong for you. One thing that can mess it up like this is changing the face -- maybe in the custom-set-faces part of your .emacs file. Emacs's interactive customization automatically includes the color information (both background and foreground) of whatever theme you happen to be using at the time you set it, so this can definitely make trouble with color themes. If that is what's causing it, you can just set the particular attribute you care about with something like

(set-face-attribute 'default nil :height 120)

That will change the font size without changing the colors.

Mike
  • 19,114
  • 12
  • 59
  • 91
  • See my comments to @selman. The `customize-themes` themes don't work acceptably on the console. – JasonFruit Feb 27 '12 at 21:15
  • I checked out what happens if I remove the custom-set-faces block from my .emacs, and that works --- it makes color-themes and customize-themes work as expected. I will have to make it so my custom-set-faces only runs if I'm running Emacs in X. Thanks! – JasonFruit Feb 27 '12 at 21:23
  • Great. And by the way, if you're looking for non-standard options, I'm a fan of the [solarized](https://github.com/sellout/emacs-color-theme-solarized) color theme. (Of course, installation of it doesn't appear to be working via the package manager at the moment...) – Mike Feb 27 '12 at 22:26
  • FWIW, I disagree that "you probably don't want things like `(require 'color-theme)`." Color themes have some distinct advantages over custom themes (and vice versa). [**This**](http://www.emacswiki.org/emacs/ColorTheme) EmacsWiki page discusses the differences, including pros and cons. – Drew May 21 '14 at 21:35
6

Emacs 24 have own theming system.

M-x customize-themes

or

(custom-set-variables
  ....
   '(custom-enabled-themes (quote (selected-theme)))
)
N.N.
  • 8,336
  • 12
  • 54
  • 94
Selman Ulug
  • 867
  • 5
  • 17
  • 2
    Yes, but it doesn't have a good and simple console-appropriate theme. (If I'm wrong, please enlighten me.) – JasonFruit Feb 27 '12 at 21:13
  • In fact, as I remember, they all come out looking one of two ways on the console: text on a light grey background, or no text on a light grey background. Neither is at all what I'd like, though of course I'd prefer the former to the latter. – JasonFruit Feb 27 '12 at 21:14
  • 2
    I think tsdh-dark is good for both console and editing modes. – Selman Ulug Feb 27 '12 at 21:18