patrickeganfoley / cycle-themes.el

Because switching between your themes shouldn't be so damn hard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cycle-themes.el

(Forked from https://github.com/toroidal-code/cycle-themes.el just to change the C-c C-t binding for cycling themes.)

Because switching between your themes shouldn't be so damn hard

How it works

Define a list of themes you want to be able to switch between. Then, enable the global minor mode. If you don't list any themes, we default to switching between all the ones emacs knows about.

(setq cycle-themes-theme-list
      '(leuven monokai solarized-dark))

(require 'cycle-themes)
(cycle-themes-mode)

That's it! Now, you can switch between your themes by calling M-x cycle-themes.

If you use use-package, it'll look something like this:

(use-package cycle-themes
  :ensure t
  :init (setq cycle-themes-theme-list
          '(leuven monokai solarized-dark))
  :config (cycle-themes-mode))

Hooks

Additionally, there is a custom variable for attaching your own hooks to be run after switching themes. For example, I don't like having my fringes be a different color than the background, so I simply use this:

(add-hook 'cycle-themes-after-cycle-hook
          #'(lambda ()
              (dolist (frame (frame-list))
                (set-face-attribute 'fringe frame 
                   :background (face-background 'default)))))

If you add any hooks and call cycle-themes-mode anywhere in your init file, it will automatically enable the first theme in the list and run all of your hooks.

Caveats

If you find that it's skipping themes in your list, make sure that all of your themes are installed and loaded properly. This is especially important for users of use-package, as it will require the theme, but not actually load it into emacs' list of valid themes (which makes (custom-theme-p my-theme) return nil).

(use-package solarized-theme
  :ensure t
  :config (progn (load-theme 'solarized-dark t t)
                 (load-theme 'solarized-light t t)))

Thanks

This package was inspired by a stackoverflow answer. I thought that snippet was great, and that it really deserved to be made into a true package. So I did.

About

Because switching between your themes shouldn't be so damn hard


Languages

Language:Emacs Lisp 100.0%