branch: externals/ef-themes
commit 898ed4ca9a8025c2f90cef3733f4c25fa91aa487
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Steamline how we define aliases for the Modus user options
---
 ef-themes.el | 198 ++++++++++-------------------------------------------------
 1 file changed, 32 insertions(+), 166 deletions(-)

diff --git a/ef-themes.el b/ef-themes.el
index 4b21f8c96c..6d7456ef62 100644
--- a/ef-themes.el
+++ b/ef-themes.el
@@ -102,7 +102,7 @@ and Modus into a single group, enable 
`modus-themes-include-derivatives-mode'."
   "List of symbols with the dark Ef themes.")
 
 (defvaralias 'ef-themes-collection 'ef-themes-items
-  "Alias of `ef-themes-items'.")
+  "Alias for `ef-themes-items'.")
 
 (defconst ef-themes-items
   (append ef-themes-light-themes ef-themes-dark-themes)
@@ -212,8 +212,22 @@ and Modus into a single group, enable 
`modus-themes-include-derivatives-mode'."
 
 ;;;; Compatibility with older versions of the Ef themes
 
-(define-obsolete-function-alias 'ef-themes-load-theme 'modus-themes-load-theme
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
+(defvar ef-themes--aliased-p nil)
+
+(defun ef-themes-define-alias (prefix suffix &optional is-function)
+  "Make alias for the Modus themes symbol with PREFIX and SUFFIX.
+If IS-FUNCTION is non-nil, use the appropriate calls for functions, else
+assume this is a variable."
+  (let ((our-symbol (intern (format "%s-%s" prefix suffix)))
+        (modus-symbol (intern (format "modus-themes-%s" suffix))))
+    (funcall
+     (if is-function
+         #'defalias
+       #'defvaralias)
+     our-symbol
+     modus-symbol
+     (format "`%s' is an alias for `%s'.
+Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
 You can configure the `ef-themes' via the user options of the
 `modus-themes'.
 
@@ -226,167 +240,21 @@ Alternatively, use the commands `ef-themes-rotate', 
`ef-themes-select',
 `ef-themes-load-random', `ef-themes-load-random-dark',
 `ef-themes-load-random-light', `ef-themes-list-colors',
 `ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-function-alias 'ef-themes-toggle 'modus-themes-toggle
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-disable-other-themes 
'modus-themes-disable-other-themes
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-headings 'modus-themes-headings
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only
-Ef themes, enable `ef-themes-take-over-modus-themes-mode'.
-Or, if you prefer to blend Ef and Modus into a single group,
-enable `modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-mixed-fonts 
'modus-themes-mixed-fonts
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-to-rotate 'modus-themes-to-rotate
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-to-toggle 'modus-themes-to-toggle
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-common-palette-overrides 
'modus-themes-common-palette-overrides
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-variable-pitch-ui 
'modus-themes-variable-pitch-ui
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-after-load-theme-hook 
'modus-themes-after-load-theme-hook
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
-
-(define-obsolete-variable-alias 'ef-themes-post-load-hook 
'modus-themes-post-load-hook
-  "Since version 2.0.0, `ef-themes' derive from the `modus-themes'.
-You can configure the `ef-themes' via the user options of the
-`modus-themes'.
-
-To make all the Modus commands that operate on a theme consider only Ef
-themes, enable `ef-themes-take-over-modus-themes-mode'.  Or, if you
-prefer to blend Ef and Modus into a single group, enable
-`modus-themes-include-derivatives-mode' instead.
-
-Alternatively, use the commands `ef-themes-rotate', `ef-themes-select',
-`ef-themes-load-random', `ef-themes-load-random-dark',
-`ef-themes-load-random-light', `ef-themes-list-colors',
-`ef-themes-list-colors-current'.  They are all designed to only consider
-Ef themes.")
+Ef themes." our-symbol modus-symbol))))
+
+;; FIXME 2025-10-07: How best to handle a possible `ef-themes-toggle'?
+;; Should we keep the `ef-themes-to-toggle'? And how about the same
+;; for rotation?
+(defun ef-themes-define-option-aliases ()
+  "Define aliases for the user options of the Modus themes."
+  (unless ef-themes--aliased-p
+    (dolist (suffix '( disable-other-themes to-toggle to-rotate 
after-load-theme-hook
+                       italic-constructs bold-constructs variable-pitch-ui 
mixed-fonts
+                       headings completions prompts common-palette-overrides))
+      (ef-themes-define-alias "ef-themes" suffix))
+    (setq ef-themes--aliased-p t)))
+
+(ef-themes-define-option-aliases)
 
 ;;;; Limit the Modus themes to only Ef themes
 
@@ -411,8 +279,6 @@ Ef themes."
 
 ;;;; Convenience commands
 
-;; TODO 2025-10-06: How best to handle a possible `ef-themes-toggle'?
-
 ;;;###autoload (autoload 'ef-themes-rotate "ef-themes")
 (modus-themes-define-derivative-command ef-themes rotate)
 

Reply via email to