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

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

[elpa] externals/ef-themes c5fedb64e3 01/28: Add commands ef-themes-sele


From: ELPA Syncer
Subject: [elpa] externals/ef-themes c5fedb64e3 01/28: Add commands ef-themes-select-dark, ef-themes-select-light
Date: Sun, 30 Apr 2023 12:02:36 -0400 (EDT)

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

    Add commands ef-themes-select-dark, ef-themes-select-light
    
    These make it easier for users to experiment with the themes we
    provide and find the one they prefer.
---
 README.org   | 11 ++++++++++
 ef-themes.el | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 70 insertions(+), 13 deletions(-)

diff --git a/README.org b/README.org
index d6a6b76efc..a0366efa7d 100644
--- a/README.org
+++ b/README.org
@@ -171,6 +171,8 @@ Everything is in place to set up the package.
 ;;
 ;; - `ef-themes-toggle'
 ;; - `ef-themes-select'
+;; - `ef-themes-select-dark'
+;; - `ef-themes-select-light'
 ;; - `ef-themes-load-random'
 ;; - `ef-themes-preview-colors'
 ;; - `ef-themes-preview-colors-current'
@@ -587,6 +589,15 @@ When ~ef-themes-select~ is called with a prefix argument 
(=C-u= by
 default), it first produces a minibuffer prompt to limit the choice to
 dark or light themes, and then shows only the relevant subset.
 
+#+findex: ef-themes-select-dark
+#+findex: ef-themes-select-light
+Instead of calling ~ef-themese-select~ with a prefix argument, users
+can invoke either of ~ef-themes-select-dark~, ~ef-themes-select-light~
+commands.  Those behave the same as ~ef-themes-select~ except they
+limit the interaction to dark or light Ef themes, respectively.  [ The
+commands ~ef-themes-select-dark~ and ~ef-themes-select-light~ are part
+of {{{development-version}}}. ]
+
 #+findex: ef-themes-load-random
 The command ~ef-themes-load-random~ is for those who appreciate a bit of
 serendipity in their life.  When call interactively with =M-x= it loads
diff --git a/ef-themes.el b/ef-themes.el
index c04646ebed..8cc62484ba 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -541,23 +541,35 @@ overrides."
 (defvar ef-themes--select-theme-history nil
   "Minibuffer history of `ef-themes--select-prompt'.")
 
+(defun ef-themes--load-subset (subset)
+  "Return the `light' or `dark' SUBSET of the Ef themes.
+If SUBSET is neither `light' nor `dark', return all the known Ef themes."
+  (pcase subset
+    ('dark ef-themes-dark-themes)
+    ('light ef-themes-light-themes)
+    (_ (ef-themes--list-known-themes))))
+
+(defun ef-themes--maybe-prompt-subset (variant)
+  "Helper function for `ef-themes--select-prompt' VARIANT argument."
+  (cond
+   ((null variant))
+   ((or (eq variant 'light) (eq variant 'dark)) variant)
+   (t (ef-themes--choose-subset))))
+
 (defun ef-themes--select-prompt (&optional prompt variant)
   "Minibuffer prompt for `ef-themes-select'.
 With optional PROMPT string, use it.  Else use a generic prompt.
 
-With optional VARIANT, prompt for a subset of themes divided into
-light and dark variants.  Then limit the completion candidates
-accordingly."
-  (let* ((subset (when variant (ef-themes--choose-subset)))
-         (themes (pcase subset
-                   ('dark ef-themes-dark-themes)
-                   ('light ef-themes-light-themes)
-                   ;; NOTE 2022-11-02: This condition made sense when
-                   ;; the code now in `ef-themes--choose-subset' used
-                   ;; `completing-read'.  With `read-multiple-choice'
-                   ;; we never meet this condition, as far as I can
-                   ;; tell.  But it does no harm to keep it here.
-                   (_ (ef-themes--list-known-themes))))
+With optional VARIANT as a non-nil value, prompt for a subset of
+themes divided into light and dark variants.  Then limit the
+completion candidates accordingly.
+
+If VARIANT is either `light' or `dark' then use it directly
+instead of prompting the user for a choice.
+
+When VARIANT is nil, all Ef themes are candidates for completion."
+  (let* ((subset (ef-themes--maybe-prompt-subset variant))
+         (themes (ef-themes--load-subset subset))
          (completion-extra-properties `(:annotation-function 
,#'ef-themes--annotate-theme)))
     (intern
      (completing-read
@@ -598,6 +610,40 @@ is ignored in this scenario."
   (interactive (list (ef-themes--select-prompt nil current-prefix-arg)))
   (ef-themes--load-theme theme))
 
+;;;###autoload
+(defun ef-themes-select-light (theme)
+  "Load a light Ef THEME.
+Run `ef-themes-post-load-hook' after loading the theme.
+
+Also see `ef-themes-select-dark'.
+
+This command is the same as `ef-themes-select' except it only
+prompts for light themes when called interactively.  Calling it
+from Lisp behaves the same as `ef-themes-select' for the THEME
+argument, meaning that it loads the Ef THEME regardless of
+whether it is light or dark."
+  (interactive
+   (list
+    (ef-themes--select-prompt "Select light Ef theme: " 'light)))
+  (ef-themes--load-theme theme))
+
+;;;###autoload
+(defun ef-themes-select-dark (theme)
+  "Load a dark Ef THEME.
+Run `ef-themes-post-load-hook' after loading the theme.
+
+Also see `ef-themes-select-light'.
+
+This command is the same as `ef-themes-select' except it only
+prompts for light themes when called interactively.  Calling it
+from Lisp behaves the same as `ef-themes-select' for the THEME
+argument, meaning that it loads the Ef THEME regardless of
+whether it is light or dark."
+  (interactive
+   (list
+    (ef-themes--select-prompt "Select light Ef theme: " 'dark)))
+  (ef-themes--load-theme theme))
+
 (defun ef-themes--toggle-theme-p ()
   "Return non-nil if `ef-themes-to-toggle' are valid."
   (mapc (lambda (theme)



reply via email to

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