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

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

[elpa] externals/ef-themes e15123e1dc 01/10: Add ef-themes-load-random c


From: ELPA Syncer
Subject: [elpa] externals/ef-themes e15123e1dc 01/10: Add ef-themes-load-random command
Date: Tue, 16 Aug 2022 23:57:34 -0400 (EDT)

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

    Add ef-themes-load-random command
---
 README.org   |  1 +
 ef-themes.el | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/README.org b/README.org
index 792194bc4d..dd9569a49c 100644
--- a/README.org
+++ b/README.org
@@ -139,6 +139,7 @@ Everything is in place to set up the package.
 ;; We also provide these commands, but do not assign them to any key:
 ;;
 ;; - `ef-themes-select'
+;; - `ef-themes-load-random'
 ;; - `ef-themes-preview-colors'
 ;; - `ef-themes-preview-colors-current'
 #+end_src
diff --git a/ef-themes.el b/ef-themes.el
index 5cb8c77073..c0ebab1df7 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -97,6 +97,23 @@ When called from Lisp, THEME is a symbol."
   (mapc #'disable-theme (ef-themes--list-known-themes))
   (load-theme theme :no-confirm))
 
+(defun ef-themes--minus-current ()
+  "Return list of Ef themes minus the current one."
+  (let* ((themes (copy-sequence (ef-themes--list-known-themes))))
+    (delete (ef-themes--current-theme) themes)))
+
+;;;###autoload
+(defun ef-themes-load-random ()
+  "Load an Ef theme at random, excluding the current one."
+  (interactive)
+  (let* ((themes (ef-themes--minus-current))
+         (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))))
+
 (defun ef-themes--preview-colors-render (buffer theme &rest _)
   "Render colors in BUFFER from THEME.
 Routine for `ef-themes-preview-colors'."



reply via email to

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