Emacs Color Theme Switcher
I recently started using color theme modern, in place of custom themes, because color themes can be undone more easily—see Custom Theme Compared to Color Theme for a comparison1.
Color Theme provides various themes and the GitHub repository has a page with screenshots. One can enable a theme by name, but the theme has to be loaded first and the old theme manually disabled.
However, I could not find an equivalent to the customize interface, which lists all available themes and allows switching to a theme by clicking on its name. I thus decided to write a couple of functions and an Org Mode to make color theme selection more similar to the one provided by custom themes.
The support functions, to be put your .emacs.el
initialization file,
enable all color themes and define two functions,
color-theme-preview
and color-theme-switch
. The former loads the
GitHub page with the previews and the second opens an Org Mode file
with all the themes, from which you can select the one you like.
(require 'color-theme-modern nil t) (setq all-themes '(aalto-dark aalto-light aliceblue andreas arjen beige-diff beige-eshell bharadwaj-slate bharadwaj billw black-on-gray blippblopp blue-erc blue-eshell blue-gnus blue-mood blue-sea calm-forest charcoal-black clarity classic cobalt comidia dark-blue dark-blue2 dark-erc dark-font-lock dark-gnus dark-green dark-info dark-laptop deep-blue desert digital-ofs1 emacs-21 emacs-nw euphoria feng-shui fischmeister gnome gnome2 goldenrod gray1 gray30 greiner gtk-ide high-contrast hober infodoc jb-simple jedit-grey jonadabian-slate jonadabian jsc-dark jsc-light jsc-light2 katester kingsajz late-night lawrence ld-dark lethe marine marquardt matrix midnight mistyday montz oswald parus pierson pok-wob pok-wog ramangalahy raspopovic renegade resolve retro-green retro-orange robin-hood rotor ryerson salmon-diff salmon-font-lock scintilla shaman simple-1 sitaramv-nt sitaramv-solaris snow snowish standard-ediff standard subtle-blue subtle-hacker taming-mr-arneson taylor tty-dark vim-colors whateveryouwant wheat word-perfect xemacs xp julie subdued railscast )) (mapcar (lambda (x) (load-theme x t t)) all-themes) (defun color-theme-preview () "Go to the GitHub repository and preview themes" (interactive) (eww "https://github.com/emacs-jp/replace-colorthemes/blob/master/screenshots.md")) (defun color-theme-switch () "Open the color-theme-switcher page and select a theme" (interactive) (find-file (expand-file-name "~/Sources/elisp/color-theme-switcher.org")))
Notice that you might want to update the path of the filename in the
color-switch-function
.
The Org Mode file opened by color-theme-switch
has a list of links,
which switch theme, when clicked, as demonstrated by the following
video:
The Org Mode file is available here.
If, for any reason, you want to update the list of themes, M-x
org-babel-execute-buffer
will execute the code embedded in the Org
Mode file.
Footnotes:
color theme modern is a re-implementation of Color Theme.