diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-05-26 20:12:59 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-05-26 20:24:42 +0200 |
commit | 5b8cc5c6dbef5093769bf7588d2a59a13c8c4337 (patch) | |
tree | 4681c5e29710e29f8d80f526fbe96db5e426ffcb /lisp | |
parent | 5a11f20a0ee0b28eba70cd787d05ee6f1d1d7856 (diff) |
theme: C-c t prompts for theme with prefix arg
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-theme.el | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lisp/init-theme.el b/lisp/init-theme.el index 58441ed..9d6954a 100644 --- a/lisp/init-theme.el +++ b/lisp/init-theme.el @@ -10,12 +10,14 @@ (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)) - (if theme - (load-theme theme) - (call-interactively 'load-theme)))) + (interactive) + (if (and (not theme) (functionp 'consult-theme)) + (call-interactively 'consult-theme) + (let ((custom-safe-themes t)) + (mapcar #'disable-theme custom-enabled-themes) + (if theme + (load-theme theme) + (call-interactively 'load-theme))))) (defun mpolden/current-theme () "Return current theme, which is either 'light or 'dark." @@ -27,12 +29,18 @@ (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." +decides the themes to toggle between. + +A prefix argument prompts for a theme to load instead of toggling +the current theme." (interactive) - (let* ((is-light (eq (mpolden/current-theme) 'light)) - (new-theme (if is-light mpolden/theme-dark mpolden/theme-light))) - (mpolden/switch-theme new-theme))) + (if current-prefix-arg + (mpolden/switch-theme) + (let* ((is-light (eq (mpolden/current-theme) 'light)) + (new-theme (if is-light mpolden/theme-dark mpolden/theme-light))) + (mpolden/switch-theme new-theme)))) (use-package doom-themes :ensure t |