Skip to content

Instantly share code, notes, and snippets.

@benhsu
Created January 12, 2013 03:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhsu/4515857 to your computer and use it in GitHub Desktop.
Save benhsu/4515857 to your computer and use it in GitHub Desktop.
(defun use-theme (theme &optional no-confirm no-enable)
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapcar 'symbol-name
(custom-available-themes))))
nil nil))
(progn
(dolist (curtheme (custom-available-themes))
(disable-theme curtheme))
(setq used-theme theme)
;; todo add to mode line
(load-theme theme)))
(defun following(n l)
(if (eq n (car l)) (car (cdr l)) (following n (cdr l))))
(defun cycle-theme ()
(interactive)
(progn
;; hack: append car of list to list to allow it to cycle
(let ((hacktheme (append (custom-available-themes) (list (car (custom-available-themes))))))
(use-theme (following used-theme hacktheme)))
;; yuck! I'm still learning mode-line-format. important thing is appending (list (symbol-name used-theme)) to the end
(setq mode-line-format (append '( " =^..^=" mode-line-front-space mode-line-mule-info mode-line-client mode-line-modified mode-line-remote mode-line-frame-identification mode-line-buffer-identification " " mode-line-position
(vc-mode vc-mode)
" " mode-line-modes mode-line-misc-info mode-line-end-spaces) (list (symbol-name used-theme))))))
@jmdeldin
Copy link

Thanks for this -- use-theme is great! It's really nice not having color theme artifacts after switching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment