From 07bad1471aaa5e0a259278e4fc64998955fcbb45 Mon Sep 17 00:00:00 2001 From: David Florness Date: Wed, 13 Nov 2024 12:28:51 -0500 Subject: [PATCH] define a function for each theme with the help of a macro --- lisp/themes.el | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lisp/themes.el b/lisp/themes.el index 3bfac49..8b27a57 100644 --- a/lisp/themes.el +++ b/lisp/themes.el @@ -18,24 +18,29 @@ (disable-current-themes) (enable-theme theme)) -(use-package gruvbox-theme - :config - (load-theme 'gruvbox-dark-hard t t) - (load-theme 'gruvbox-light-hard t t)) - -(use-package monokai-theme - :config - (load-theme 'monokai t t)) - -(use-package doom-themes - :config - (load-theme 'doom-one t t) - (load-theme 'doom-one-light t t) - (load-theme 'doom-vibrant t t)) - -(use-package zenburn-theme - :config - (load-theme 'zenburn t t)) +(defmacro use-theme (pkg themes) + `(use-package ,pkg + :config + ;; load each theme + ,@(cl-loop for thm in themes collect + `(load-theme (quote ,thm) t t)) + ;; define an interactive function for each theme + ,@(cl-loop for thm in themes collect + `(defun ,(intern (format "%s-theme" thm)) () + ,(format "Switch current theme to %s." thm) + (interactive) + (switch-theme (quote ,thm)))))) + +(use-theme gruvbox-theme (gruvbox-dark-hard + gruvbox-light-hard)) + +(use-theme monokai-theme (monokai)) + +(use-theme doom-themes (doom-one + doom-one-light + doom-vibrant)) + +(use-theme zenburn-theme (zenburn)) (defun dark-theme () (interactive) -- 2.38.4