diff options
| author | Protesilaos Stavrou <info@protesilaos.com> | 2022-08-18 07:51:25 +0300 |
|---|---|---|
| committer | Protesilaos Stavrou <info@protesilaos.com> | 2022-08-18 07:51:25 +0300 |
| commit | ee30e75e77e925cf97e28e037d78796b56c5a78a (patch) | |
| tree | fe9cac639750a7d9d7a9627c49f491da46c494d2 | |
| parent | 4ebe3cb7c0b3a56c96ce8c64181fa7ed2e3799b4 (diff) | |
Add ef-themes-post-load-hook
| -rw-r--r-- | README.org | 5 | ||||
| -rw-r--r-- | ef-themes.el | 24 |
2 files changed, 23 insertions, 6 deletions
@@ -207,6 +207,11 @@ as =init.el=. :CUSTOM_ID: h:58345e8c-2bec-459c-872c-a85a29e9fe97 :END: +#+vindex: ef-themes-post-load-hook +The commands mentioned herein call ~ef-themes-post-load-hook~ at the +end. This is for advanced users who want to trigger some code after an +Ef theme is loaded ([[#h:5b74bd9e-e7f2-46b3-af2e-7c45b2e69245][Use colors from the active Ef theme]]). + #+findex: ef-themes-select The themes can also be loaded interactively ([[#h:75d74aea-d17f-497f-a3b8-f0bf4c372de0][Loading a theme]]). The command ~ef-themes-select~ (call it with =M-x=) prompts with minibuffer diff --git a/ef-themes.el b/ef-themes.el index fd89e17..b16d418 100644 --- a/ef-themes.el +++ b/ef-themes.el @@ -87,13 +87,26 @@ nil t nil 'ef-themes--select-theme-history)) +(defcustom ef-themes-post-load-hook nil + "Hook that runs after loading an Ef theme. +This is used by the commands `ef-themes-select' and +`ef-themes-load-random'." + :type 'hook + :group 'ef-themes) + +(defun ef-themes--load-theme (theme) + "Load THEME while disabling other Ef themes. +Run `ef-themes-post-load-hook'." + (mapc #'disable-theme (ef-themes--list-known-themes)) + (load-theme theme :no-confirm) + (run-hooks 'ef-themes-post-load-hook)) + ;;;###autoload (defun ef-themes-select (theme) "Load an Ef THEME using minibuffer completion. When called from Lisp, THEME is a symbol." (interactive (list (intern (ef-themes--select-prompt)))) - (mapc #'disable-theme (ef-themes--list-known-themes)) - (load-theme theme :no-confirm)) + (ef-themes--load-theme theme)) (defconst ef-themes-light-themes '(ef-day ef-light ef-spring ef-summer) "List of symbols with the light Ef themes.") @@ -126,14 +139,13 @@ prompts with completion for either `light' or `dark'." (interactive (list (when current-prefix-arg (intern (completing-read "Random choice of Ef themes VARIANT: " - '(light dark) nil t))))) + '(light dark) nil t))))) (let* ((themes (ef-themes--minus-current variant)) (n (random (length themes))) (pick (nth n themes))) - (mapc #'disable-theme (ef-themes--list-known-themes)) (if (null pick) - (load-theme (car themes) :no-confim) - (load-theme pick :no-confim)))) + (ef-themes--load-theme (car themes)) + (ef-themes--load-theme pick)))) (defun ef-themes--preview-colors-render (buffer theme &rest _) "Render colors in BUFFER from THEME. |
