1

I am using emacs with the prelude configuration. I changed the theme and it works fine, and I added it in the preload directory like so :

;; preload color theme
(setq prelude-theme 'my-theme)

I installed the theme via prelude-require-packages, but not in the preload folder (not sure if it is available that soon). Is there a way to programmatically check if the theme is available, to replace the previous line with something more safe, like :

;; just to get the idea
(when (is-available 'my-theme)
      (setq prelude-theme 'my-theme))

Edit I tried :

;; preload color theme
(when (featurep 'my-theme)
  (setq prelude-theme 'my-theme))

But in this case I get the default theme, not 'my-theme.

Cœur
  • 37,241
  • 25
  • 195
  • 267
nha
  • 17,623
  • 13
  • 87
  • 133

1 Answers1

2

The load-theme function uses locate-file to find theme files. This approach is based that code:

(if (locate-file (concat (symbol-name 'my-theme) "-theme.el")
                 custom-theme-load-path '("" "c"))
    (setq prelude-theme 'my-theme))

You can replace the entire (concat ...) construct with the theme filename string, which for this example would be "my-theme-theme.el".

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
  • It is not working. Is it because my theme is in the `elpa` directory ? – nha Jul 25 '15 at 15:06
  • 1
    Yes. Just add that directory to `custom-theme-load-path` as described in [this answer](http://stackoverflow.com/a/15381087/409228). – Steve Vinoski Jul 25 '15 at 15:47
  • I'm a bit surprised though that I can load it using `M-x load-theme` but that it's not in my load-path ? But thanks I'll try that. – nha Jul 25 '15 at 15:54