emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ef-themes ee30e75e77 08/10: Add ef-themes-post-load-hoo


From: ELPA Syncer
Subject: [elpa] externals/ef-themes ee30e75e77 08/10: Add ef-themes-post-load-hook
Date: Thu, 18 Aug 2022 00:57:55 -0400 (EDT)

branch: externals/ef-themes
commit ee30e75e77e925cf97e28e037d78796b56c5a78a
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add ef-themes-post-load-hook
---
 README.org   |  5 +++++
 ef-themes.el | 24 ++++++++++++++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/README.org b/README.org
index a4f0461214..f81c0586f7 100644
--- a/README.org
+++ b/README.org
@@ -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 fd89e179ff..b16d418cc8 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]