Created
November 29, 2015 12:41
-
-
Save karls/9d0d5e25cd72d633893f to your computer and use it in GitHub Desktop.
Quick hack for cycling themes in Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Theme cycling. | |
;; NOTE: themes have to exist somewhere on disk, e.g in ~/.emacs.d/themes/ | |
;; Set it with (setq custom-theme-directory "~/.emacs.d/themes/") | |
(defvar current-theme-index 0) | |
(defvar theme-list | |
'(solarized-dark solarized-light) | |
"List of themes to cycle through.") | |
(defun get-theme-name (idx) | |
(nth idx theme-list)) | |
(defun cycle-themes () | |
(interactive) | |
(let* ((theme (get-theme-name current-theme-index)) | |
(next-theme-index (mod (+ 1 current-theme-index) (length theme-list))) | |
(next-theme (get-theme-name next-theme-index))) | |
(disable-theme theme) | |
(setq current-theme-index next-theme-index) | |
(load-theme next-theme))) | |
(when window-system | |
(global-set-key (kbd "<f5>") 'cycle-themes) | |
(load-theme (get-theme-name 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment