syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

No easy way to use custom themes #7373

Closed jupl closed 4 years ago

jupl commented 8 years ago

Description :octocat:

I am attempting to set the default theme to Doom at startup using dotspacemacs-additional-packages and dotspacemacs-themes. When I add doom-themes to dotspacemacs-additional-packages and doom-one to dotspacemacs-themes as the first item I get this error at startup and the default white Emacs theme is used:

screen shot 2016-10-12 at 8 47 49 am

The theme is not broken as I can select it via SPC T s and works as expected

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: Error message.

Expected behaviour: :heart: :smile: Doom theme.

System Info :computer:

(typescript colors docker editorconfig emacs-lisp html javascript markdown org-plus osx react restclient shell shell-scripts syntax-checking vimscript yaml
            (auto-completion :variables auto-completion-return-key-behavior nil auto-completion-tab-key-behavior 'complete auto-completion-enable-help-tooltip t)
            (clojure :variables clojure-enable-fancify-symbols t)
            (git :variables git-magit-status-fullscreen t)
            (version-control :variables version-control-diff-tool 'diff-hl))
TheBB commented 8 years ago

Unfortunately it's not possible to use dotspacemacs-additional-packages for themes at this moment.

TheBB commented 8 years ago

If you don't mind we can hijack this issue to be more general.

TheBB commented 8 years ago

In the meantime, I have added support for doom themes in develop: https://github.com/syl20bnr/spacemacs/commit/df49e2a8d2d892bbc8635fb82927c243ac191b23

jupl commented 8 years ago

Hijack away. I will note that I can get this to work with other themes. (it works with darktooth and darkokai for example) I take it could be because of naming conventions which some themes follow differently?

TheBB commented 8 years ago

Looks like this breaks because doom depends on dash, and Spacemacs wants to set the themes before packages have been initialized.

marienz commented 8 years ago

I encountered a similar error message when trying to use a theme installed locally into ~/.emacs.d/private/local and loaded by adding (my-theme :location local) to dotspacemacs-additional-packages. spacemacs would try to load my theme from elpa, which wouldn't work.

I worked around it by adding default to the front of the dotspacemacs-themes list and adding a call to (spacemacs/load-theme 'my-theme) to dotspacemacs/user-config. This probably works for other uses of dotspacemacs-additional-packages for custom themes as well, and as far as I can tell is pretty close to what I was hoping spacemacs would do (use the default theme until a little further into initialization).

Flink commented 7 years ago

@marienz tried your solution but it’s not working for me 😕 Still getting the error Warning (spacemacs): An error occurred while retrieving the theme, using default theme. (error: (error Package ‘my-theme-’ is unavailable))

Flink commented 7 years ago

It’s even weirder than that, I copied a theme from the elpa directory with the same structure/files, edited them and the them is actually loaded and working but I still have this annoying message… Why is it so difficult to load a custom theme? (or package even)

gilbertw1 commented 7 years ago

Just adding to this issue, since #8090 was closed as a duplicate of this one. Any theme (new or updated) that requires autothemer will break because the autothemer package is not yet loaded when the the theme is.

I've noticed a number of high quality themes converting over to using autothemer including gruvbox, darktooth, and creamsody. I'm currently loading autothemer (and dash) manually in user-init to work around this.

marienz commented 7 years ago

The workaround still works for my local theme. @Flink: maybe you don't have default first in dotspacemacs-themes? If you add a spacemacs/load-theme call to dotspacemacs/user-config but don't put default first in the initial list, I'd expect it to behave the way you describe: try to load the first theme from the list, fall back to default with an error, and then successfully switch to your theme shortly afterwards.

Flink commented 7 years ago

@marienz Tried that but I get the same error, in fact it’s when the theme is used that the error occurs. I set the theme in the list with default first then I type leader-T-n, it changes to my theme but it still displays the error 😕

westlywright commented 7 years ago

@marienz I've used your method and got custom themes to load that are not in the themes mega pack. Thanks! I am wondering if you have used this to load a local only custom theme? e.g. a theme i'm developing. I've tried a few different things without success. I can load the theme into spacemacs after via Helm without issue but if I try to use my local theme as the default it breaks saying it can't load the theme.

kvloxx commented 7 years ago

For anyone having trouble loading a local theme, I found that once I used customize to set the variable custom-theme-directory to my theme's location location (~/.emacs.d/private/local/), I could just include my theme's name at the top of the dotspacemacs-themes list and it would load as normal, no modifications to dotspacemacs-additional-packages required.

Flink commented 7 years ago

@kvloxx Not working for me, I still have the same error than previously 😕

agzam commented 7 years ago

I believe, I am still using my own custom theme by modifying custom-theme-load-path yet at the start it still trying to find theme packages:

  Found 2 new package(s) to install...
  --> refreshing package archive: gnu... [3/3]
  --> installing package: ag-zenburn-old-theme@dotfile... [1/2]
  Package ag-zenburn-old-theme is unavailable. Is the package name misspelled?
  --> installing package: base16-ocean-dark-theme@dotfile... [2/2]
  Package base16-ocean-dark-theme is unavailable. Is the package name misspelled?

which is a bit annoying, since it increases a startup time

marienz commented 7 years ago

@westlywright I was previously using this to load a locally-developed theme, by setting dotspacemacs-additional-packages to '((mz-tango-theme :location local)) and putting my theme in ~/.emacs.d/private/local/mz-tango-theme/mz-tango-theme.el. This recently stopped working (probably because of b3c8ebc8160dcd0d1f0e67cc9578e9a676243302). I've fixed it for now by symlinking my theme to ~/.emacs.d/mz-tango-theme.el, but haven't checked yet what the best approach now is. It might be to just remove the dotspacemacs-additional-packages stuff and only keep the theme in ~/.emacs.d.

d12frosted commented 7 years ago

Should become better after https://github.com/syl20bnr/spacemacs/commit/b3c8ebc8160dcd0d1f0e67cc9578e9a676243302. Though I haven't tried it yet.

syl20bnr commented 7 years ago

In develop, package properties like :location are now supported in dotspacemacs-themes.

https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#choosing-themes

So now this works:

(setq-default dotspacemacs-themes
              '(spacemacs-light
              leuven
              (zenburn :location (recipe :fetcher github
                                         :repo "bbatsov/zenburn-emacs"))
              ))

Important note: since this is in the dotspacemacs-themes, the theme name must be used, not the package name like in other lists like dotspacemacs-additional-packages.

Can you try this new feature ? We may still need to handle custom-theme-directory for local location though. Tell me what's breaking and I'll fix it. We should be very close to have proper POLA support for themes in Spacemacs now.

Also SPC f e R is capable to correctly synchronize theme packages (but it won't change the current theme).

marienz commented 7 years ago

Thanks! Putting my theme in ./private/local/mz-tango-theme/mz-tango-theme.el and setting dotspacemacs-themes to '((mz-tango :location local) spacemacs-dark) now almost works. There are two issues:

First issue: with just dotspacemacs-themes, it doesn't load:

(Spacemacs) Warning: An error occurred while applying the theme "mz-tango", fallback on theme "spacemacs-dark". 
Error was: (error Unable to find theme file for ‘mz-tango’)
(Spacemacs) Warning: Please check the value of "dotspacemacs-themes" in your dotfile or open an issue 
so we can add support for the theme "mz-tango".

because (I think) nothing adds the theme to custom-theme-load-path. spacemacs/load-theme adds the theme's configuration-layer/get-elpa-package-install-directory, but that doesn't seem to work for :location local. And there's an autoload much like the one in core/libs/spacemacs-theme/spacemacs-common.el in my theme, but that doesn't trigger either.

If I explicitly require the theme in dotspacemacs/user-config it loads.

Would it make sense for spacemacs/load-theme to (require pkg-name) (if spacemacs/get-theme-package-name returns a non-nil pkg-name)?

Second issue: my custom theme seems to be applied on top of the Spacemacs default theme, which means some faces only customized by the Spacemacs theme look wrong. If I modify the call to load the theme in core/core-spacemacs.el to (spacemacs/load-theme spacemacs--delayed-user-theme nil t) (disable any already-loaded themes before loading the delayed user theme) that problem goes away.

syl20bnr commented 7 years ago

Thank you for taking time in testing this. I should be able to fix both of these issues and we should be good :-)

Is it possible to fetch your theme somewhere so I can test your exact same setup and see if everything is fixed?

syl20bnr commented 7 years ago

@marienz I pushed the support for :location local in commit https://github.com/syl20bnr/spacemacs/commit/252547a Can you test it ?

Note that you must put your theme in a folder named after the package name, not the theme name. For instance if your theme is foo you must put it in foo-theme as mentioned in the Emacs conventions.

Also you can provide a string as the value for :location which is the path to your theme directory, so you can use this if you need to name the folder differently.

carloscheddar commented 7 years ago

@syl20bnr setting the theme in private/local/foo-theme/foo-theme.el works but after loading the layers, spacemacs removes the theme. I've attached a gif of how it behaves:

Manually setting the theme after loading the layers keeps the theme but I have to set it each time spacemacs starts up.

syl20bnr commented 7 years ago

@carloscheddar that's strange, is it possible for you to share your .spacemacs ?

carloscheddar commented 7 years ago

@syl20bnr yeah that particular issue was not happening on the stable release. Here's a gist of my .spacemacs https://gist.github.com/carloscheddar/73e450fc57cbeb93baa9ed4aa0b88fa8

carloscheddar commented 7 years ago

@syl20bnr I pulled the latest develop branch and I keep getting the same issue. Let me know if you need anything else from me.

et2010 commented 7 years ago

How to use the melpa version of leuven instead of version shipped with emacs? I found :location not working for leuven theme.

asnider6 commented 7 years ago

I'm experiencing a similar issue with base16-ocean since 200.8 update. No longer loads by default (and I believe the version it does load is not the previous working version in terminal)

marienz commented 7 years ago

@syl20bnr this works great here, thanks!

@carloscheddar it looks like your problem is caused by '(custom-enabled-themes nil) in your custom-set-variables. If I eval that, I lose my theme (and looking at the implementation confirms that's intended).

I don't know why manually (re-)setting the theme isn't updating that value for you, since enable-theme is supposed to do that (how are you setting the theme?). But removing that line and restarting Spacemacs might help.

carloscheddar commented 7 years ago

@marienz thanks for the help, removing that line finally fixed my issue!

What I was doing when starting spacemacs the theme was gone but I could easily recover it by reloading the dotfile.

nivpgir commented 7 years ago

can someone from here that succeeded setting his theme please explain the steps to use a custom theme?

I've put this theme: https://github.com/tonyfloatersu/idea-dracula-theme-for-spacemacs in my '.emacs.d/private/local' as described and also added: '(idea-darcula :location local)' to the appropriate place and still for some reason the theme isn't being applied properly.

marienz commented 7 years ago

@nivpgir please make sure:

If it still doesn't work, please clarify what happens when you start Spacemacs, and share any error messages from your *Messages* buffer (SPC b m).

nivpgir commented 7 years ago

sorry, I should've mentioned: the naming in that repository isn't consistent, so I changed all the files in my local copy to contain 'idea-darcula':

[nivpgir@acer-57d4 idea-darcula-theme]$ pwd /home/nivpgir/.emacs.d/private/local/idea-darcula-theme [nivpgir@acer-57d4 idea-darcula-theme]$ ll total 272 -rw-r--r-- 1 nivpgir nivpgir 663 Nov 6 20:08 idea-darcula-theme-autoloads.el -rw-r--r-- 1 nivpgir nivpgir 8628 Nov 6 22:38 idea-darcula-theme.el -rw-r--r-- 1 nivpgir nivpgir 246 Nov 6 20:08 idea-darcula-theme-pkg.el -rw-r--r-- 1 nivpgir nivpgir 247857 Nov 4 20:11 'idea-dracula theme ver 001.png' -rw-r--r-- 1 nivpgir nivpgir 1057 Nov 4 20:11 LICENSE -rw-r--r-- 1 nivpgir nivpgir 364 Nov 4 20:11 README.md

and also all occurences of the theme name inside any .el file of the theme.

when I start spacemacs, it hangs for about 10 seconds on the message: Installing user theme: (idea-darcula :location local)... while searching for it in melpa, elpa, and such, repos, and afterwards opens normally using the standard spacemacs-dark theme.

gist of my .spacemacs: https://gist.github.com/nivpgir/51f65f29fddc58f164df3882162c1cdf

gist of messages: https://gist.github.com/nivpgir/ea2830dad631ef38f826d2822ab2cb4f

also, I have in my .spacemacs the line: dotspacemacs-additional-packages '( ;; (idea-darcula-theme :location local) ) commented out, and for the record, I tried running it with that line, and without it, both didn't work.

marienz commented 7 years ago

Did you also change all references to idea-darkula in idea-darkula-theme.el to idea-darcula? Just renaming the files is not sufficient.

Which version of spacemacs is this? I don't quite see how you'd trigger exactly those errors on develop (there's a (message "error: %s" err) you're not hitting), and it looks like 252547a isn't in master. You need to run develop or wait for 0.300 for this to work, I think.

nivpgir commented 7 years ago

@marienz

yes, I did change all references inside the file.

the problem was that I wasn't running develop, I was still running stable 0.200, changed it, works great, thanks. by the way, is this feature documented anywhere yet? it wasn't easy for me to find this thread, and it's not very friendly to go over the whole thread just to figure this solution.

I think it's something worth noting somewhere in the docs.

anyways, thanks!

marienz commented 7 years ago

Glad to hear you got it fixed!

This feature is briefly mentioned in the documentation: https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#choosing-themes

It's not on http://spacemacs.org/doc/DOCUMENTATION.html yet because it hasn't been released yet.

Nate-Wilkins commented 6 years ago

Any update on this? Really looking forward to getting that merged into master!

It might be nice to also be able to specify an alternative path.

kimonoki commented 6 years ago

just want to add a solution to load custom theme add (add-to-list 'custom-theme-load-path "path/to/my-theme/") to user-init

futile commented 6 years ago

I tried the instructions under https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#choosing-themes but my local theme doesn't show up in SPC T s.

Here is my setup, on the develop branch:

[~/.emacs.d/private/local/lucius-theme]$ ls                                                                                                                                                            
lucius-theme.el

File lucius-theme.el:

;; Lucius color scheme for emacs
;;
;; To use add the following to your .emacs file:
;;
;; (require 'color-theme)
;; (color-theme-initialize)
;; (load-file "~/.emacs.d/site-lisp/themes/color-theme-lucius.el")
;; (color-theme-lucius.el)
;;
;; MIT License Copyright (c) 2010 Mahmoud Abdelkader <mahmoud@linux.com>
;; Inspired by the Vim colorscheme Lucius by Jonathan Filip
;;

(defun lucius-theme ()
  (interactive)
  (color-theme-install
   '(lucius-theme
     ((background-color . "#202020")
      (background-mode . dark)
      (cursor-color . "#5A647E")
      (foreground-color . "#e0e0e0"))
     (default ((t (nil))))
     (bold ((t (:bold t))))
     (bold-italic ((t (:italic t :bold t))))
     (fringe ((t (:background "#232323"))))
     (font-lock-builtin-face ((t (:foreground "#D0D0FF"))))
     (font-lock-comment-face ((t (:foreground "#BC9458" :italic t))))
     (font-lock-constant-face ((t (:foreground "#6D9CBE"))))
     (font-lock-doc-string-face ((t (:foreground "#A5C261"))))
     (font-lock-function-name-face ((t (:foreground "#FFC66D"))))
     (font-lock-keyword-face ((t (:foreground "#CC7833"))))
     (font-lock-preprocessor-face ((t (:foreground "#CC7833"))))
     (font-lock-reference-face ((t (:foreground "LightSteelBlue"))))
     (font-lock-string-face ((t (:foreground "#A5C261"))))
     (font-lock-type-face ((t (:foreground "white"))))
     (font-lock-variable-name-face ((t (:foreground "LightSteelBlue"))))
     (font-lock-warning-face ((t (:foreground "Pink"))))
     (paren-face-match-light ((t (:foreground "#FFC66D" :background "#555577"))))
     (highlight ((t (:background "darkolivegreen"))))
     (italic ((t (:italic t))))
     (modeline ((t (:background "#A5BAF1" :foreground "black"))))
     (modeline-buffer-id ((t (:background "#A5BAF1" :foreground 
                                          "black"))))
     (modeline-mousable ((t (:background "#A5BAF1" :foreground 
                                         "black"))))
     (modeline-mousable-minor-mode ((t (:background
                                        "#A5BAF1" :foreground "black"))))
     (region ((t (:background "#555577"))))
     (primary-selection ((t (:background "#555577"))))
     (isearch ((t (:background "#555555"))))
     (zmacs-region ((t (:background "#555577")))) 
     (secondary-selection ((t (:background "darkslateblue")))) 
     (flymake-errline ((t (:background "LightSalmon" :foreground 
                                       "black")))) 
     (flymake-warnline ((t (:background "LightSteelBlue" :foreground 
                                        "black"))))
     (underline ((t (:underline t)))) 
     (minibuffer-prompt ((t (:bold t :foreground "#FF6600")))))))

(I changed some references in the file from color-theme-lucius to lucius-theme, that's why the comment in the header mismatches.)

In my .spacemacs:

   dotspacemacs-themes '(sanityinc-tomorrow-night subatomic wilson jbeans ujelly dracula base16-default-dark
                         (lucius :location local)
                         spacemacs-dark
                         spacemacs-light
                         solarized-light
                         solarized-dark
                         leuven
                         monokai
                         zenburn)

What I would expect: SPC T s should allow me to see a theme called "lucius" What happens: Theme doesn't show up

What am I missing? Thanks!

marienz commented 6 years ago

lucius-theme uses color-theme.el, not the normal Emacs theming machinery (deftheme, custom-theme-set-faces, provide-theme etc.). It looks like color-theme.el predates theming support in Emacs and does not integrate with it.

So lucius-theme isn't providing a theme that Spacemacs can use (it just provides a function lucius-theme that nothing ever calls).

It's probably best fixed by porting lucius-theme to the normal Emacs theming machinery. I haven't done this myself in quite some time so I don't know off the top of my head which theme to point you at as an example, sorry.

futile commented 6 years ago

Ah, ok! Thanks for the quick reply :) Thanks for the effort though! :)

ishovkun commented 6 years ago

Is there a way to have more that one custom (local) theme? E.g. now I have

   dotspacemacs-themes
   '((palenight :location local)
     (one-dark :location local)
     solarized-dark)

When I am trying to change theme to one-dark it does not appear in the list of themes. When one-dark is the only local theme it works fine.

syl20bnr commented 6 years ago

@ishovkun Seems to be a bug, can you open a new issue to track and resolve this particular issue ?

Igor Shovkun notifications@github.com writes:

Is there a way to have more that one custom (local) theme? E.g. now I have dotspacemacs-themes '((palenight :location local) (one-dark :location local) solarized-dark) When I am trying to change theme to one-dark it does not appear in the list of themes. When one-dark is the only local theme it works fine.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/syl20bnr/spacemacs/issues/7373#issuecomment-398449670

ishovkun commented 6 years ago

@syl20bnr done #10970 .

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!