blob: 32f2c89a4d0b0e131999f6d0b966ca82825c1b32 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
;;; theme.el --- Colors and stuff -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; Package-Requires: ((emacs "24.3"))
;;; Commentary:
;;
;; Cycle through a whitelist of themes.
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'cycle)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgroup theme nil
"Customization options for `theme'."
:group 'theme)
(defcustom theme-whitelist
(cycle-from-list (custom-available-themes))
"The whitelist of themes through which to cycle."
:type '(cycle symbol)
:group 'theme)
(defcustom theme-after-change
nil
"Hook invoked after a new theme is loaded"
:type 'hook
:group 'theme)
(defun theme-whitelist-set (theme)
"Focus the THEME in the `theme-whitelist' cycle."
(cycle-focus! (lambda (x) (equal x theme)) theme-whitelist)
(theme--set (cycle-current theme-whitelist)))
(defun theme-select ()
"Load a theme using `completing-read'."
(interactive)
(let ((theme (completing-read "Theme: " (cycle-to-list theme-whitelist))))
(theme--disable-all)
(theme--set (intern theme))))
(defun theme-next ()
"Disable the currently active theme and load the next theme."
(interactive)
(disable-theme (cycle-current theme-whitelist))
(theme--set (cycle-next! theme-whitelist))
(message (format "Active theme: %s" (cycle-current theme-whitelist))))
(defun theme-prev ()
"Disable the currently active theme and load the previous theme."
(interactive)
(disable-theme (cycle-current theme-whitelist))
(theme--set (cycle-prev! theme-whitelist))
(message (format "Active theme: %s" (cycle-current theme-whitelist))))
(defun theme--disable-all ()
"Disable all currently enabled themes."
(interactive)
(dolist (x custom-enabled-themes)
(disable-theme x)))
(defun theme--set (theme)
"Call `load-theme' with `THEME', ensuring that the line numbers are bright.
There is no hook that I'm aware of to handle this more elegantly."
(load-theme theme t)
(run-hooks 'theme-after-change))
(provide 'theme)
;;; theme.el ends here
|