why cant emacs 24 find a custom theme I added?

Terrence Brannon picture Terrence Brannon · Mar 23, 2012 · Viewed 18.9k times · Source

My entire emacs setup is here

I loaded my init-theme.el file here

And supposedly that should make the darkclean theme available.

But when I type M-x load-theme TAB the darkclean theme is not listed.

How can I register it for Emacs 24?

Answer

ocodo picture ocodo · Mar 13, 2013

If you install themes via elpa / package.el you'll notice that you need to add each theme folder into your custom-theme-load-path - this is a bit of a pain to do manually, especially when you take into account upgrades will create a new folder, e.g. 0.1.0 -> 0.1.2 will be a new folder inside your elpa folder.

Assuming you've installed your elpa packages into ~/.emacs.d/elpa/ add this script to your ~/.emacs.d/init.el

(require 'dash)
(require 's)

(-each
   (-map
      (lambda (item)
      (format "~/.emacs.d/elpa/%s" item))
   (-filter
      (lambda (item) (s-contains? "theme" item))
      (directory-files "~/.emacs.d/elpa/")))
   (lambda (item)
      (add-to-list 'custom-theme-load-path item)))

You'll need dash.el and s.el (available from elpa.)