Setting Emacs 24 color theme from .emacs

50,715

Solution 1

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.

Solution 2

Emacs 24 have own theming system.

M-x customize-themes

or

(custom-set-variables
  ....
   '(custom-enabled-themes (quote (selected-theme)))
)
Share:
50,715
JasonFruit
Author by

JasonFruit

I work mostly with an open-source stack, Python, PostgreSQL, and the like. I think I'm becoming a language gourmand; in the last few years, I've learned plenty of JavaScript, Scheme, Lua, and Emacs Lisp, and enough Common Lisp, Go, and Object Pascal to be dangerous. I'm doing far more web work than I used to, and that's okay, I guess, though I miss desktop applications. Oddly, I find myself being much more productive using Python with CherryPy and Cheetah Templates than I have ever managed to be using a more complete web framework like Django.

Updated on March 28, 2020

Comments

  • JasonFruit
    JasonFruit about 4 years

    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.