branch: externals/modus-themes
commit 49d435ee79c56cf37179dcdb3a6febd4a7b60a46
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Implement a modus-themes-sort function
---
modus-themes.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/modus-themes.el b/modus-themes.el
index db4358195f..b5f0a7a7c6 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -3859,6 +3859,17 @@ derivatives."
(background (plist-get properties :background-mode)))
(eq background background-mode)))
+(defun modus-themes-sort (themes background-mode)
+ "Reorder THEMES so that those with BACKGROUND-MODE come first.
+BACKGROUND-MODE is either `dark' or `light'."
+ (unless (memq background-mode '(dark light))
+ (error "The BACKGROUND-MODE can be either `dark' or `light'"))
+ (sort
+ themes
+ (lambda (theme1 theme2)
+ (and (modus-themes--background-p theme1 background-mode)
+ (modus-themes--background-p theme2 (if (eq background-mode 'dark)
'light 'dark))))))
+
(cl-defgeneric modus-themes-get-themes ()
"Return a list of all themes with `modus-themes' :family property."
(modus-themes-get-all-known-themes 'modus-themes))