5
votes

I'm using emacs 24.3 on Windows 8. I have installed the solarized color theme from the marmalade repository, and am able to set it using M + x load-theme. It also sets for the current session when I use Customize, but doesn't load when I open emacs again.

I can open the customize menu and select the theme, but saving the changes does nothing, and nothing changes between that and my next session. I looked at several questions here about color themes, but most do not apply to Emacs 24, since I don't need to use color-theme to do it.

Below is a snippet from my .emacs file.

(custom-set-variables
  '(custom-enabled-themes (quote (solarized-dark)))
  '(custom-safe-themes (quote ("fc5fcb6f1f1c1bc01305694c59a1a861b008c534cae8d0e48e4d5e81ad718bc6" default)))
...

When I try to put (load-theme 'solarized-dark t) into my .emacs, I get the error:

error: Unable to find theme file for `solarized-dark'

I've checked the value of custom-theme-load-path after opening emacs and it includes the directory elpa uses to store the solarized theme. As mentioned above, I can load the theme manually, but something about loading it during init is breaking.

2

2 Answers

14
votes

Just add

(package-initialize)

To the top of your .emacs file and you are good to go.

0
votes

Side note: if the theme author has taken care of it, the theme will add itself to the custom-theme-load-path, however this is not a part of the deftheme and is down to individual theme authors implementing this behaviour.

To solve the problem, I made a quick snippet of emacslisp that will find packages with theme in their name, then add them to the custom-theme-load-path at startup.

Just add it near the top of your ~/.emacs or ~/.emacs.d/init.el (ie. before you load-theme

It has dependencies on s.el and dash.el (both available on elpa)

(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)))