Switching between Emacs color themes

http://blog.modelworks.ch/?p=347

Emacs has lots of different color-themes. Depending on the light and my own mood, I would like to change between my two favorite themes, the “standard” light theme and a dark one.
This is the color-theme I use for my LaTeX files (“sitaramv-nt”):
But for my model files, I like the dark color-theme (“dark-laptop”), but sometimes the light one.
I searched the internet and found some code that allows me to switch easily between the themes using F11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(require 'color-theme)
(color-theme-initialize)
 
(setq my-color-themes (list 'color-theme-dark-laptop
                            'color-theme-sitaramv-solaris
                            'color-theme-sitaramv-nt
                              ))
 
(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 - thanks)
    (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 [f11] 'my-theme-cycle)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s