Skip to content

Commit cc1bffb

Browse files
authored
Merge branch 'master' into emacs-default
2 parents ed531af + eeff0d8 commit cc1bffb

File tree

2 files changed

+28
-38
lines changed

2 files changed

+28
-38
lines changed

theme-looper-tests.el

+22-26
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
(theme-looper--disable-all-themes)
5252
(should (equal custom-enabled-themes
5353
'())))
54-
(load-theme current-theme
55-
t))))
54+
(when current-theme
55+
(load-theme current-theme t)))))
5656

5757
(ert-deftest tl-test:getting-theme-indices ()
5858
(let ((current-theme (car custom-enabled-themes)))
@@ -86,8 +86,8 @@
8686
'wombat)))
8787
(setq theme-looper--favorite-themes
8888
(custom-available-themes))
89-
(load-theme current-theme
90-
t))))
89+
(when current-theme
90+
(load-theme current-theme t)))))
9191

9292
(ert-deftest tl-test:setting-next-theme ()
9393
(let ((current-theme (car custom-enabled-themes)))
@@ -113,40 +113,36 @@
113113
'(wombat))))
114114
(setq theme-looper--favorite-themes
115115
(custom-available-themes))
116-
(load-theme current-theme
117-
t))))
116+
(when current-theme
117+
(load-theme current-theme
118+
t)))))
118119

119120
(ert-deftest tl-test:adding-customization ()
120121
(let ((current-theme (car custom-enabled-themes))
121-
(current-face-height (face-attribute 'default
122-
:height)))
122+
(current-face-background (face-background 'default)))
123123
(unwind-protect
124124
(progn
125-
(message (concatenate 'string
126-
"current-face-height: "
127-
(number-to-string current-face-height)))
128-
(theme-looper-set-favorite-themes (list 'wombat
125+
(set-face-background 'default "red")
126+
(message (concat "current face-background: red"))
127+
(theme-looper-set-favorite-themes (list 'wombat
129128
'tango-dark
130129
'wheatgrass))
131130
;;Should apply customizations when specified
132-
(load-theme 'tango
131+
(load-theme 'tango
133132
t)
134-
(theme-looper-set-post-switch-script (lambda ()
135-
(set-face-attribute 'default nil
136-
:height 120)))
133+
(add-hook 'theme-looper-post-switch-hook
134+
(lambda ()
135+
(set-face-background 'default "green")))
137136
(theme-looper-enable-next-theme)
138-
(message (concatenate 'string
139-
"found face-height: "
140-
(number-to-string (face-attribute 'default :height))))
141-
(should (< (abs (- (face-attribute 'default :height)
142-
120))
143-
2)))
137+
(message (concat "found face-background: "
138+
(face-background 'default)))
139+
(should (equal (face-background 'default) "green")))
144140
(setq theme-looper--favorite-themes
145141
(custom-available-themes))
146-
(load-theme current-theme
147-
t)
148-
(set-face-attribute 'default nil
149-
:height current-face-height))))
142+
(setq theme-looper-post-switch-hook nil)
143+
(when current-theme
144+
(load-theme current-theme t))
145+
(set-face-background 'default current-face-background))))
150146

151147
(ert-deftest tl-test:emacs-defaults ()
152148
(let ((current-theme (car custom-enabled-themes)))

theme-looper.el

+6-12
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969
;;
7070
;; (theme-looper-reset-themes-selection)
7171
;;
72-
;; You can set some script to be run after every theme switch
72+
;; You can set hook functions to be run after every theme switch
7373
;;
74-
;; (theme-looper-set-post-switch-script my-func)
74+
;; (add-hook 'theme-looper-post-switch-hook 'my-func)
7575
;;
7676
;; The special symbol `*default*' represents Emacs defaults (no theme)
7777
;;
@@ -80,7 +80,7 @@
8080
;;; Commentary:
8181

8282
;; You can use this package to cycle through color themes in Emacs with a
83-
;; shortcut. Select your favorite themes, unfavorite thmes and key-bindings
83+
;; shortcut. Select your favorite themes, unfavorite themes and key-bindings
8484
;; to switch color themes in style!
8585
;;
8686
;; Overview of features:
@@ -98,8 +98,8 @@
9898
(defvar theme-looper--ignored-themes
9999
nil)
100100

101-
(defun theme-looper--post-switch
102-
nil)
101+
(defvar theme-looper-post-switch-hook nil
102+
"Hook that runs after selecting a theme.")
103103

104104
(defvar theme-looper--themes-map-separator
105105
" | ")
@@ -142,12 +142,6 @@
142142
(symbol-name theme)))
143143
(theme-looper-available-themes))))
144144

145-
;;;###autoload
146-
(defun theme-looper-set-post-switch-script (func)
147-
"Sets script to be run after every theme switch"
148-
(setq theme-looper--post-switch
149-
func))
150-
151145
;;;###autoload
152146
(defun theme-looper-reset-themes-selection ()
153147
"Resets themes selection back to default"
@@ -262,7 +256,7 @@ Pass `*default*' to select Emacs defaults"
262256
(theme-looper--disable-all-themes)
263257
(when (not (eq theme '*default*))
264258
(load-theme theme t))
265-
(theme-looper--post-switch))
259+
(run-hooks 'theme-looper-post-switch-hook))
266260

267261
;;;###autoload
268262
(defun theme-looper-enable-next-theme ()

0 commit comments

Comments
 (0)