From 92d8b14b96f39a765eed5643f2656f4e8b41dd8d Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:53:32 -0500 Subject: fix hook and add optional theme arg --- bard-elisp/bard-theme.el | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'bard-elisp') diff --git a/bard-elisp/bard-theme.el b/bard-elisp/bard-theme.el index fb90c85..1d37ffb 100644 --- a/bard-elisp/bard-theme.el +++ b/bard-elisp/bard-theme.el @@ -65,7 +65,7 @@ :default-family "Monospace" ))) -;; Switching themes +;;; Switching themes (defun bard/disable-all-themes () "disable all active themes." (interactive) @@ -75,27 +75,25 @@ (defvar bard/after-theme-load-hook nil "Hook that runs after a new theme is loaded using `bard/select-theme`.") -(dolist (hook '(enable-theme-hook)) +(dolist (hook '(bard/after-theme-load-hook)) (add-hook hook #'fontaine-apply-current-preset) (add-hook hook #'logos-update-fringe-in-buffers)) -(add-to-list 'enable-theme-functions #'logos-update-fringe-in-buffers) - -(add-to-list 'enable-theme-functions #'fontaine-apply-current-preset) - -(defun bard/select-theme () - "Prompt the user to select a theme from all available custom themes and enable it." - (interactive) - (let* ((theme (completing-read "Select theme: " (mapcar 'symbol-name (custom-available-themes)))) - (theme-symbol (intern theme)) - (theme-name (if (string-suffix-p "-theme" theme) - (substring theme 0 -6) - theme)) - (colored-theme-name (propertize theme-name 'face '(:weight bold)))) +(defun bard/select-theme (&optional theme) + "Enable the specified THEME, or prompt the user to select one if THEME is nil." + (interactive + (list + (completing-read "Select theme: " + (mapcar 'symbol-name (custom-available-themes))))) + (let* ((theme-symbol (if (symbolp theme) theme (intern theme))) + (theme-name (symbol-name theme-symbol)) + (display-theme-name (if (string-suffix-p "-theme" theme-name) + (substring theme-name 0 -6) + theme-name)) + (colored-theme-name (propertize display-theme-name 'face '(:weight bold)))) (bard/disable-all-themes) (load-theme theme-symbol t) (message "Loaded the %s theme" colored-theme-name) - (run-hooks 'after-theme-load-hook))) - + (run-hooks 'bard/after-theme-load-hook))) (provide 'bard-theme) -- cgit v1.2.3