valignatev / heaven-and-hell

Emacs light/dark theme toggler
MIT License
58 stars 2 forks source link

Howto combine with customized spacemacs-theme? #12

Closed tdd11235813 closed 5 years ago

tdd11235813 commented 5 years ago

Maybe you can help. I would like to combine heaven-and-hell with spacemacs-theme. Unfortunately, I could not get it to work yet. There is also an open spacemacs-theme issue. If needed, there is a minimal example:

git clone --single-branch --branch test-space-theme https://github.com/tdd11235813/emacs_config.git
emacs -l emacs_config/init.el

UPDATE-1: Do NOT use -l emacs_config/init.el, this messes up emacs init process.

There are actually three commits, where only the third commit tests the combination with heaven-and-hell theme switcher.

Issue: Only the first theme colors work, but only after you toggle. When you toggle back, then only the default color setup of spacemacs-theme is loaded without custom color definitions applied. When you run load-theme first, then toggling is not needed, but the second theme is still not working.

Code: From init.el

(use-package heaven-and-hell
  :init
  (setq heaven-and-hell-theme-type 'dark) ;; Omit to use light by default
  (setq heaven-and-hell-themes
        '((light . test-space-light)
          (dark . test-space))) ;; Themes can be the list: (dark . (tsdh-dark wombat))
  :hook (after-init . heaven-and-hell-init-hook) ;;
;;  :hook (emacs-startup . heaven-and-hell-init-hook) ;; if above does not work
  :bind (("C-c M-k" . heaven-and-hell-load-default-theme)
         ("C-c M-l" . heaven-and-hell-toggle-theme)))

From test-space-theme.el

(require 'spacemacs-common)

(deftheme test-space
  "Modified spacemacs theme.")

(custom-set-variables '(spacemacs-theme-custom-colors
      '(
        (str . "#ff0000")
;; ... more colors ...
        )))

(create-spacemacs-theme 'dark 'test-space)

(provide-theme 'test-space)

This association list is applied via cl-loop in spacemacs-common.el.

UPDATE-2: Using setq instead of custom-set-variables finally resolved this issue. Minimal example branch is here.

valignatev commented 5 years ago

Thanks for the ticket! Hm, interesting... I'm not using some heavy modifications to the spacemancs theme, but I have some: https://github.com/valignatev/dotfiles/blob/master/.emacs.d/config/fancification.el#L45-L64

They work quite well for me, but I haven't upgraded spacemacs theme in a while :)

So I'll need to look more into it.

BTW, why do you use init block to set custom variables instead of custom in your use-package definition? https://github.com/tdd11235813/emacs_config/blob/master/lisp/themes/scicpp-dark-theme.el#L8

tdd11235813 commented 5 years ago

cool, your emacs config is already inspiring me :) (You will probably not see issues with the recent spacemacs-theme updates, because you do not use color customization on the spacemacs-theme.)

Yes, there are several lines in my files which could be simplified by the use-package interface, also things like hooks. My emacs code needs continuous refactoring ;) Regarding :custom or customize-set-...: At least the theme stuff shall not go into custom.el, so going to use setq,... for it instead. Not sure, if it is correct, but it seems redundant, when the custom.el is full with theme based definitions, which are actually statically defined and not set by the user.

tdd11235813 commented 5 years ago

for ref: had an issue with custom-file and custom-enabled-themes, see other issue resulting in a current workaround to avoid always loading default theme at startup.

(use-package heaven-and-hell
;; ...
  :config
  (custom-set-variables `(custom-enabled-themes (quote (scicpp-dark scicpp-light)))) ;; set your custom themes here
)
tdd11235813 commented 5 years ago

Solved. I use setq instead of custom-set-variables. Using CLI option -l for init files is also wrong, see #11. Updated initial post.