diff --git a/README.org b/README.org index 792194b..dd9569a 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 5cb8c77..c0ebab1 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'."