summaryrefslogtreecommitdiffstats
path: root/lisp/init-theme.el
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-10-09 12:35:54 +0200
committerMartin Polden <mpolden@mpolden.no>2021-10-09 12:38:23 +0200
commitfed5478581707742df17ab6313224a791567e4b3 (patch)
tree26dcc34ddadc4c4d3f82b7c70a3c1a311baed347 /lisp/init-theme.el
parent19fcc8a3e6b4442db51bcdba18e2b98ffa721bcf (diff)
theme: C-c T toggles between dark and light themes
Diffstat (limited to 'lisp/init-theme.el')
-rw-r--r--lisp/init-theme.el31
1 files changed, 26 insertions, 5 deletions
diff --git a/lisp/init-theme.el b/lisp/init-theme.el
index 2179b35..04af81b 100644
--- a/lisp/init-theme.el
+++ b/lisp/init-theme.el
@@ -2,18 +2,39 @@
;;; Commentary:
;;; Code:
-(defun mpolden/switch-theme ()
- "Disable any currently enabled themes and load a new one."
- (interactive)
+(defvar mpolden/theme-light 'doom-one-light
+ "The light theme to use when toggling themes with `mpolden/toggle-theme'.")
+
+(defvar mpolden/theme-dark 'doom-one
+ "The dark theme to use when toggling themes with `mpolden/toggle-theme'.")
+
+(defun mpolden/switch-theme (&optional theme)
+ "Disable any currently enabled themes and load THEME."
+ (interactive "P")
(mapcar #'disable-theme custom-enabled-themes)
(let ((custom-safe-themes t))
- (call-interactively 'load-theme)))
+ (if theme
+ (load-theme theme)
+ (call-interactively 'load-theme))))
+
+(defun mpolden/toggle-theme ()
+ "Toggle between dark and light themes.
+The variables `mpolden/theme-light' and `mpolden/theme-dark'
+decides the themes to toggle between."
+ (interactive)
+ (let ((is-light (memq mpolden/theme-light custom-enabled-themes) )
+ (is-dark (memq mpolden/theme-dark custom-enabled-themes)))
+ (cond
+ (is-light (mpolden/switch-theme mpolden/theme-dark))
+ (is-dark (mpolden/switch-theme mpolden/theme-light))
+ (t (message "Don't know how to toggle theme: %s" (car custom-enabled-themes))))))
(use-package doom-themes
:ensure t
:if (display-graphic-p)
+ :bind ("C-c T" . mpolden/toggle-theme)
:config
- (load-theme 'doom-one t))
+ (load-theme mpolden/theme-dark t))
(provide 'init-theme)