Add utilities for DIY users

Basically this defines the 'modus-themes-color' function that lets you
retrieve the colour value assigned to KEY.  The key is found in the
association list that contains each theme's colour palette.

Example for how to use this:

    (set-face-attribute 'cursor nil :background (modus-themes-color 'blue))

Ongoing discussion in the Modus themes' main repo:
https://gitlab.com/protesilaos/modus-themes/-/issues/119
This commit is contained in:
Protesilaos Stavrou 2020-11-15 13:58:57 +02:00
parent e00a59a2c8
commit 3f97a3f153
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -1307,6 +1307,26 @@ symbol and the latter as a string.")
(make-obsolete 'modus-vivendi-theme-override-colors-alist nil "1.0.0")
;;;; Utilities for DIY users
(defun modus-themes--active-theme ()
"Return appropriate alist of color values for active theme."
(let ((theme (car custom-enabled-themes)))
(pcase theme
('modus-operandi modus-themes-operandi-colors)
('modus-vivendi modus-themes-vivendi-colors)
(_ (user-error "'%s' not a Modus theme; check `custom-enabled-themes'" theme)))))
;;;###autoload
(defun modus-themes-color (key)
"Return color value for KEY."
(let ((alist (modus-themes--active-theme)))
(cdr (assoc `,key alist))))
;;;; Face specifications
(defvar modus-themes