This page is about color themes and custom themes.
EmacsLisp library color-theme.el provides many predefined color themes for your use, and you can easily define additional themes. For questions about color-theme, see ColorThemeQuestions. The library has not been updated recently, but you can use it with any Emacs version since at least Emacs 20 (through at least Emacs 24). See the color-theme web page at http://www.nongnu.org/color-theme for how to get started color-theme.el.
Custom themes are similar to color themes, but:
[Possibly not up-to-date. See http://www.nongnu.org/color-theme for the latest information.]
Put the file color-theme.el and the folder “themes” (with the files color-theme-example.el and color-theme-library.el) in a directory on your LoadPath. The main function to use is
‘color-theme-select’. It creates the Color Theme Selection buffer that allows you to test the themes before choosing one.
M-x load-library RET color-theme RET M-x color-theme-select RET
The easiest way is to install a chosen color theme is to require the file and call the appropriate color theme function. Put the appropriate code in your .emacs file:
(require 'color-theme) (color-theme-initialize) (color-theme-robin-hood)
If it doesn’t seem to work, try adding one more line:
(require 'color-theme) (setq color-theme-is-global t) (color-theme-robin-hood)
If you like putting globals in default.el and local customizations in .emacs then, add the require to default.el and use this in .emacs
(eval-after-load "color-theme" '(color-theme-robin-hood))
Use the `?’ in the Color Theme Selection buffer to find the name of the appropriate color theme function.
If the colors seem to get reset (such as background color changing to white on startup or when creating a new frame), consider checking ColorsAndKde.
If on loading emacs, you get an error like
Debugger entered--Lisp error: (wrong-type-argument keymapp nil) define-key(nil [menu-bar Tools] ("Tools" keymap "Tools"))
Change lines 589 and 590 in color-theme.el to:
(easy-menu-add-item nil '("tools") "--") (easy-menu-add-item nil '("tools") ["Color Themes" color-theme-select t])
Note the “tools” vs “Tools”.
Choosing a color theme by name is only convenient if you already know what color scheme a given name represents. After installing Color Theme, you can pick and choose from a menu. This menu can be accessed via
An alternative way to choose a theme is to cycle among a set of themes, applying each in turn, and stop when you find one you like – WYSIWYG.
Here are four alternative ways to cycle among color themes in a list. For illustration, they all use the same list.
(require 'color-theme) (setq my-color-themes (list 'color-theme-billw 'color-theme-jsc-dark 'color-theme-sitaramv-solaris 'color-theme-resolve 'color-theme-classic 'color-theme-jonadabian-slate 'color-theme-kingsajz 'color-theme-shaman 'color-theme-subtle-blue 'color-theme-snowish 'color-theme-sitaramv-nt 'color-theme-wheat))
Use command `
M-x doremi-color-themes+’ or `
M-x doremi-custom-themes+’, then use the up and down arrow keys and/or the mouse wheel to cycle among themes. The name of each newly applied theme is displayed in the echo area. You can customize options
‘doremi-custom-themes’, which is the set of color or custom themes to cycle among. By default, all color or custom themes are included.
You can use these commands to preview themes: use
‘C-g’ to cancel changes and return to what you had before.
‘C-g’is equivalent to picking pseudo-theme
[Reset], which also means that sometimes not everything is restored, but most is.
‘C-g’just disables each of the themes that you cycled through. This does not, however, restore any non-theme customizations in effect before cycling. The appearance of the last theme applied remains, for the existing frames, even though that theme has been disabled and will have no effect on new frames etc.
Also worth mentioning, if you define your own themes, are the commands in library doremi-frm.el that let you fine-tune frame and face colors incrementally, using the arrow keys or mouse wheel. They give you an easy way to get exactly the color scheme you want before saving it as a color theme. There are also commands to convert and tweak colors (for example, obtain a color that is slightly lighter, redder, etc. than a given color). See Do Re Mi.
You can use Icicles command
‘icicle-custom-theme’ to cycle among color themes or Emacs custom themes, respectively. This functionality is similar to that provided by DoReMiColorThemes (above), but you can also complete the color-theme names, which means also that you can narrow the set of themes that you cycle among. (You can also sort the set in various ways.)
Just as for the corresponding DoReMi commands,
‘C-g’ undoes your changes. Options
‘icicle-custom-themes’ are similar to options
‘doremi-custom-themes’, respectively – customize them to define the lists of themes to choose from (default: all themes). See Icicles.
‘my-theme-cycle’ (bound here to
`[F12]') to cycle among themes.
(defun my-theme-set-default () ; Set the first row (interactive) (setq theme-current my-color-themes) (funcall (car theme-current))) (defun my-describe-theme () ; Show the current theme (interactive) (message "%s" (car theme-current))) ; Set the next theme (fixed by Chris Webber - tanks) (defun my-theme-cycle () (interactive) (setq theme-current (cdr theme-current)) (if (null theme-current) (setq theme-current my-color-themes)) (funcall (car theme-current)) (message "%S" (car theme-current))) (setq theme-current my-color-themes) (setq color-theme-is-global nil) ; Initialization (my-theme-set-default) (global-set-key [f12] 'my-theme-cycle)
(note: Make the following changes to allow this code to work when (setq my-color-themes color-themes). )
(defun car-theme () ;figure out if we need car or caar (interactive) (cond ((consp (car theme-current)) (caar theme-current)) (t (car theme-current))))
(defun my-theme-set-default () ; Set the first row (interactive) (setq theme-current my-color-themes) (funcall (car-theme)))
(defun my-describe-theme () ; Show the current theme (interactive) (message "%s" (car-theme)))
; Set the next theme (fixed by Chris Webber - tanks) (defun my-theme-cycle () (interactive) (setq theme-current (cdr theme-current)) (if (null theme-current) (setq theme-current my-color-themes) (funcall (car-theme))) (message "%S" (car-theme))) (setq theme-current my-color-themes) (setq color-theme-is-global nil) ; Initialization (my-theme-set-default)
Here’s how to do this interactively.
Or you can use it programmatically to install a color theme based on a major mode, for example:
(require 'color-theme-buffer-local) (add-hook 'java-mode (lambda nil (color-theme-buffer-local 'color-theme-robin-hood (current-buffer))))
You can do this by using the variable
‘color-theme-is-global’ which determines whether a color theme is installed on all frames or not. Here’s how to do this interactively.
M-x set-variable RET color-theme-is-global nil M-x color-theme-blue-sea
A possible use for this variable is dynamic binding. Here is a larger example to put in your ~/.emacs; it will make the Blue Sea color theme the default used for the first frame, and it will create two additional frames with different color themes.
(require 'color-theme) ;; set default color theme (color-theme-blue-sea) ;; create some frames with different color themes (let ((color-theme-is-global nil)) (select-frame (make-frame)) (color-theme-gnome2) (select-frame (make-frame)) (color-theme-standard))
Use display-color-cells find how many colors are supported. Note that on X, even though all RGB values are supported, each application gets allocated a number of colors it may use. Perhaps that is the reason the function returns 64 on my system even though it seems that it supports a lot more.
(if ((display-color-cells) 20) (color-theme-tty-dark) (color-theme-goldenrod))
‘window-system’ to determine whether or not you are in a terminal, or a windowing system such as X11.
(if window-system (color-theme-subtle-hacker) (color-theme-hober))
‘window-system’ is nil for a character-based terminal, ‘x’ for X11, ‘mac’ for mac, etc.
Fixed: The (window-system) to window-system since it’s a variable and not a function shouldn’t have the ().
Question: Any idea how to detect if emacs has been started as a daemon? I think we need logic like:
(if window-system or started-as-daemon (color-theme-subtle-hacker) (color-theme-hober))
The following code in your .emacs file will test whether each frame is opened in a GUI or console and select according to the colors you select for each in the variable, color-theme-choices (based on the comments by Pierre on Emacs-Fu):
;; select theme - first list element is for windowing system, second is for console/terminal (setq color-theme-choices '(color-theme-deep-blue color-theme-standard))
;; test for each frame or console (require 'cl) (lexical-let ( (cols color-theme-choices) ) (defun test-win-sys (frame) (let ( (color-theme-is-global nil) ) (select-frame frame) (eval (append '(if (window-system frame)) (mapcar (lambda (x) (cons x nil)) cols))))))
;; hook on after-make-frame-functions (add-hook 'after-make-frame-functions 'test-win-sys)
I want a color theme to be selected any time I open an X frame, but not when I open a TTY frame. With multi-tty, this is selected on a frame-by-frame basis. So I use a hook:
(add-hook 'after-make-frame-functions (lambda (frame) (set-variable 'color-theme-is-global nil) (select-frame frame) (if window-system (color-theme-robin-hood) (color-theme-tty-dark))))
Usually the color themes don’t change fonts. Please let me know if they do. That is a bug. If you want to install a color-theme and then switch font-family and font-size to something new, here is an example of how to do it:
(let ((spec '((t (:family "neep alt" :height 200))))) (mapc (lambda (face) (face-spec-set face spec) (put face 'face-defface-spec spec)) '(default menu)))
If you use
‘set-face-font’ instead, you will note that on subsequent frames, your settings may not take effect. (Actually I haven’t really investigated this.)
(defmacro save-font-excursion (face &rest body) "Save the :font property of given FACE during the execution of BODY." (declare (indent 1) (debug t)) `(let ((oldfont (face-attribute ,face :font)) ret) (setq ret (progn ,@body)) (or (string= oldfont (face-attribute ,face :font)) (set-face-attribute ,face nil :font oldfont)) ret))
(save-font-excursion 'default (color-theme-emacs-nw))
Take a look at ColorThemeMaker.
Following code will allow you to setup a mechanism of saving and retrieving the last session’s settings. This depends on two files in your home directory, .themesettings and .curTheme. The first is just an elisp file which is loaded when Emacs starts. It is primarily used for two settings: theme-default and theme-load-from-file.
(setq theme-load-from-file t)
(setq theme-default 'color-theme-gnome2)
This always loads the default theme you provided. Add the following code to your ~/.emacs. This assumes that you have (require ‘color-theme) somewhere before that:
(defun my-onload() (setq filename (concat (expand-file-name "~") "/.themesettings")) (if (file-exists-p filename) (progn (load-file filename) (if (equalp theme-load-from-file t) (progn (setq filename (concat (expand-file-name "~") "/.curTheme")) (if (file-exists-p filename) (progn (message "selecting theme from .curTheme") (load-file filename) (color-theme-install (my-color-theme)) ))) (funcall theme-default) )) (message "selecting theme from color-theme-standard") (color-theme-install(color-theme-standard) ))) (defun my-kill-saves() (if (equalp theme-load-from-file t) (progn (color-theme-print) (write-file (concat (expand-file-name "~") "/.curTheme")) ))) (add-hook 'after-init-hook 'my-onload) (add-hook 'kill-emacs-hook 'my-kill-saves)
Please note that I have used this only on XEmacs. --GirishB
The above code should change the filenames to be in one place and give some indication of what the files are for. Otherwise a year later you will be scratching your head trying to figure out what program put those files there. Try sticking them in a directory like ~/.my-emacs-extensions. If you don’t believe that this is important, look at your home directory and tell me what program put each file there! – gadfly
Put the following lines to your ~/.emacs file:
(load-library "color-theme") (color-theme-select)
Assuming you have color-theme package in load-path.
You can switch to dark mode and back again with the following in your ~/.emacs:
(defun toggle-night-color-theme () "Switch to/from night color scheme." (interactive) (require 'color-theme) (if (eq (frame-parameter (next-frame) 'background-mode) 'dark) (color-theme-snapshot) ; restore default (light) colors ;; create the snapshot if necessary (when (not (commandp 'color-theme-snapshot)) (fset 'color-theme-snapshot (color-theme-make-snapshot))) (color-theme-dark-laptop))) (global-set-key (kbd "<f9> n") 'toggle-night-color-theme)
The function assumes that default
‘light’. You may wish to modify the name of [dark] theme and the key binding.
You can also automatically change your color theme based on the time of day using theme-changer.el. In your ~/.emacs, make sure your location is set:
(setq calendar-location-name "Dallas, TX") (setq calendar-latitude 32.85) (setq calendar-longitude -96.85)
And then specify the day and night color themes:
(require 'theme-changer) (change-theme 'color-theme-solarized-light 'color-theme-solarized-dark)
Note: you may need to add the theme-changer.el path to your loadpath. For example:
(add-to-list 'load-path "~/.emacs.d/elisp/theme-changer")
I added my tweaked port of ColorThemeInkpot from VIM. – Per Vognsen
DanielBrockman links to another color-theme on his page. I will add it for the next release. – zeDek.
Here’s my DarkVee color theme – vic
Alex rose to the Hello Kitty challenge and wrote PinkBliss.
I’ve attempted to clone the Blackboard theme from textmate here – JD Huntington
The Empty Void - A dark theme that I created for myself, with subtle shades; easy on the eyes.
I created a color theme based on your color-theme-tango.el. I modified it a bit and added some faces for Gnus, org-mode, customize buffers, etc. You can find screenshots and installation instructions here : https://github.com/juba/color-theme-tangotango – JulienBarnier
I have created a color theme based on the TextMate Mac Classic theme. It’s stored in a git repo via http://github.com/jbw/color-theme-mac-classic along with a screenshot and install instructions. --jbw
A port of VIM’s desert theme can be found here. Any comments / suggestions are welcome! – superbobry
Live color theme screenshots at the (color-theme-select) web site (almost ~130 themes) – vic
Bill Clementson has published his color theme: http://bc.tech.coop/ubuntu-config/elisp/color-theme-billc.el
Pomgranate Explosion, an elegant and soft color theme for GNU Emacs. Available at https://github.com/bmarcot/color-theme-pomgranate-explosion.
My take on Monokai for emacs: https://github.com/stafu/AnotherMonokai – SM
Color theme I use daily. It’s highly contrast black-purple theme. Lisp:color-theme-black-purple.el – Anonymous
The original color theme code was written by Jonadab the Unsightly One.
Put this in your ~/.emacs:
(funcall (car (nth (random (length color-themes)) color-themes)))
Given the name of a color theme, write out the .Xresources equivalent of the theme. You would want to do this if you want to make Emacs start much faster than loading the theme from Lisp.
M-x color-theme-x RET hober RET C-u M-x color-theme-x RET classic RET ~/elisp/color-theme.el RET
After the generated X resource settings have been written out to your .Xresources file, you’ll need run either xrdb -merge .Xresources or xrdb -load .Xresources (depending on the desired effect). You will have to restart your Emacs to have the new X resources take effect.
Using GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2) of 2009-11-01 on raven, modified by Debian, I’m not able to use properly that package. It loads fine, but when I’m invoking one of the example commands, I get the following error message: ‘assoc: Wrong type argument: listp, color-theme-classic’, and the buffer color-theme-xresources is practically empty. Am I doing something wrong? – MathieuBasille?
Lisp:color-theme-reg.el – convert color-theme to win32 reg. by Kyle M. Lee, based on color-theme-x.
Any ideas what to do about this?
<code>color-theme-backup-original-values: Symbol’s function definition is void: color-theme-filter</code>
To fix the problem, open color-theme.el and change:
<code>easy-menu-get-map(nil ("Tools") nil) easy-menu-add-item(nil ("Tools") "--")</code>
<code>easy-menu-get-map(nil ("tools") nil) easy-menu-add-item(nil ("tools") "--")</code>
Original help.gnu.emacs post: http://tinyurl.com/bgke3
This issue is fixed in the CVS.
I am running Ubuntu 6.06 (Dapper Drake) and emacs-snapshot seems to not play well with color-theme. When it loads, only the characters have the correct background color. The rest of the buffer has some default gray color. Emacs21 seems to work just fine. Has anyone else seen this? Any idea how to fix it?
How can I filter the themes to find those suitable for console/tty? Recently I’ve been using GNU Screen and naturally my X Windows faces don’t work. Ediff is especially limited ☹.
Screen supports 256 colors. It’s a compile-time option disabled by default in Debian and Ubuntu packages. – TrentBuck
This hasn’t been the case since 2007. 4.0.3-5 onward include 256 color support, which means Etch and Dapper, respectively, were the last releases to have non-256 color support in screen.
I suggest you use no theme at all. Most themes are not designed to degrade gracefully. They all use a spec that says “for all display types”. So you have to rely on the fall-back mechanism that reduces millions of colors to 16. Not good. All of themes I know except for retro orange or retro green look terrible on a 16 color terminal. Have you tried running on a 256 color terminal? Might be a bit better. – AlexSchroeder
It may still be desirable to filter for themes designed for those 256 color themes; 256 color ttys will still degrade themes designed for a 24-bit display.
Unfortunately, nothing here says where the bug tracker is (found it!), so I can’t report anything there. Should you happen to blow the stack trying to do color-theme-select, you might want to try this patch, which detects and suppresses such infinite recursions: https://gist.github.com/1259919
It happened to me because of https://github.com/dbrock/zenburn-el/issues/13
After downloading the tar.gz file, there’s a Makefile, a README, and a number of other files, but no instructions for Joe User on how to install. If you’re simply a user who wants to have the color themes installed, I believe you are to ignore the Makefile, and simply copy color-theme.el and the themes directory to a directory on your load-path (say, [[.emacs.d?]]).
. Thank you. It will be part of 6.6.1 – XavierMaillard
I am running 6.6.0 with the Carbon XEmacs port of 21.5.beta27. Whenever I choose a new theme, it resizes my frame to 80x40. – doktorstick
. – XavierMaillard
Just a note that after spending several hours trying to figure out why a color-theme wasn’t displaying the text under the cursor correctly for me on OSX, it appears according to the people on the emacs irc channel that the cursor is controlled by the operating system. Under OSX, apparently the foreground color cannot be adjusted. If you change this value within emacs you won’t see the result reflected as it will be ignored. It appears to work fine under Windows and Linux. The issues with OSX were noticed using OSX 10.6 and 10.7. This is not an issue with color-theme as such, but I just wanted to highlight it here also since I ran into this issue while trying to use color-theme and wasted several hours on it. I hope others won’t do the same. – Josh
Edit: The cursor colors function correctly with gnu emacs for osx v24, so they appear to have fixed whatever prevented it working with earlier versions. – Josh
To have an idea of what a theme looks like, I think we could all take a screenshot of our prefered and running theme.
If you want to help (as there are many themes now and still more pending), you can send me a big (png only) screenshot accompanished with a thumb of reasonable size (ie. 400x300). I will then build an online gallery and maybe add them to the ColorTheme package.
For theme creators, I would appreciate now if you could join a screenshot of your theme when you submit it to me.
Send them to me at : zedek (at) gnu.org
You can use the (color-theme-select) web site to preview many color themes ~130, and create your own. – vic
color-theme-library.elin small pieces (one theme per file)
CREDITS.themesas a thank-you list