5
(add-to-list 'custom-theme-load-path "~/.emacs.d")
(load-theme 'sanityinc-solarized-dark-theme)

I have these two lines in my .emacs file, and those theme files in the listed directory, yet emacs still does not detect the theme file.

I've seen other threads with similar issues, but none have worked for me so far, particularly with using package.el

Any help?

Kaushal Modi
  • 25,651
  • 4
  • 80
  • 183
CodeSammich
  • 365
  • 3
  • 12

1 Answers1

3

If you are installing the theme using the package.el, you should not set the custom-theme-load-path.

All you need to do is:

  • Install the theme from the emacs package manager as explained in the theme's instructions.
  • Put (load-theme 'sanityinc-solarized-dark) in your .emacs.
  • The first time you load the theme (and the first time after each update of that theme), emacs will ask if you consider that theme to be safe and you hit y or yes.

How to install this theme step-by-step from an emacs -Q session

  1. Eval below in the *scratch* buffer

    (require 'package)

    (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))

  2. M-x package-list-archives.

  3. Find the theme package you want to install, color-theme-sanityinc-solarized in this case.
  4. Important Step! M-x package-initialize or eval (package-initialize).
  5. M-x customize-themes and select the check box in front of sanityinc-solarized-dark or sanityinc-solarized-light.
  6. Done.

How to load this theme automatically when you restart emacs

Here is a minimum-working test-load-theme.el file to load this theme automatically. You need to have the theme installed using the package manager first!

(require 'package)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(load-theme 'sanityinc-solarized-dark t)

Save above in ~/.emacs.d/test-load-theme.el. It is a good convention to put emacs related stuff in ~/.emacs.d.

Start a fresh emacs session while loading just the above file:

\emacs -Q -l ~/.emacs.d/test-load-theme.el

Related emacs.SE question

Kaushal Modi
  • 25,651
  • 4
  • 80
  • 183
  • It says that the theme is not found. I installed the color-theme-sanityinc-solarized-2.25.

    That's the folder name. Should I just write the name without the 2.25?

    – CodeSammich Feb 12 '15 at 00:51
  • I have updated my answer on how to install this theme in a fresh emacs -Q session. Suggestions: (1) Erase the customization for custom-theme-load-path (2) You are probably missing (package-initialize) in your .emacs file. – Kaushal Modi Feb 12 '15 at 14:11
  • Also the theme name is sanityinc-solarized-dark, not sanityinc-solarized-dark-theme. – Kaushal Modi Feb 12 '15 at 14:30
  • Awesome! So what was the problem? – Kaushal Modi Feb 12 '15 at 23:32
  • I wasn't too sure. I think I had a different theme name – CodeSammich Feb 12 '15 at 23:32
  • I had to add a theme name and a t) at the end, instead of just a parentheses – CodeSammich Feb 12 '15 at 23:34
  • The third argument t is not mandatory. Having it there prevents emacs from asking you if you consider the theme as safe and want to load it. – Kaushal Modi Feb 12 '15 at 23:37
  • It probably was a theme name then. I managed to install the packages, but it didn't work. But then I found someone with the correct theme name, and it worked (: – CodeSammich Feb 12 '15 at 23:38
  • It does not work - it says "theme is not found" – Draif Kroneg Jan 05 '18 at 15:09
  • @Draif It would help us help you if you put in more information.. What step exactly doesn't work? Also it would be better to post a new question with detailed steps to reproduce your problem. – Kaushal Modi Jan 05 '18 at 15:17