[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/alect-themes 7b42f0a 022/269: Add support for inverted (al
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/alect-themes 7b42f0a 022/269: Add support for inverted (alternative) themes |
Date: |
Thu, 21 Oct 2021 17:58:41 -0400 (EDT) |
branch: elpa/alect-themes
commit 7b42f0acf58100fa214b2a0d34d9508daed1b179
Author: Alex Kost <alezost@gmail.com>
Commit: Alex Kost <alezost@gmail.com>
Add support for inverted (alternative) themes
---
alect-themes.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 8 deletions(-)
diff --git a/alect-themes.el b/alect-themes.el
index 2a66b17..caf990a 100644
--- a/alect-themes.el
+++ b/alect-themes.el
@@ -155,17 +155,52 @@ See `alect-colors' for details."
(error "Color '%s' does not exist" color-name))
(setcdr color-cons color-val))))
-(defun alect-get-color (theme-name color-name)
- "Return the value of color for the specified theme."
+(defcustom alect-inverted-color-regexp
+ "^\\(red\\|yellow\\|green\\|cyan\\|blue\\|magenta\\)\\([-+]\\)\\([012]\\)$"
+ "Regexp matching a name of the color for inverted theme.
+
+The first parenthesized group should match a base color
+name (e.g. \"fg\" or \"blue\").
+The second group should match a sign (\"-\" or \"+\").
+The third group should match a color number (0, 1 or 2).
+
+For available color names, see `alect-colors'.
+For description of inverting colors, see `alect-get-color'."
+ :type 'string
+ :group 'alect)
+
+(defun alect-get-color (theme-name color-name &optional invert)
+ "Return the value of color COLOR-NAME for a theme THEME-NAME.
+
+If INVERT is non-nil, return the value of the \"opposite\" color.
+E.g. use the value of \"magenta+1\" if COLOR-NAME is
+\"magenta-1\" or use \"red-2\" instead of \"red+2\" and so on.
+Invert only the color matching `alect-inverted-color-regexp'.
+
+For the values of THEME-NAME and COLOR-NAME, see `alect-colors'."
+ (and invert
+ (let ((color (symbol-name color-name)))
+ (and (string-match alect-inverted-color-regexp color)
+ (let ((base (match-string 1 color))
+ (sign (match-string 2 color))
+ (num (match-string 3 color)))
+ (and base sign num
+ (setq color-name
+ (intern (concat base
+ (if (equal sign "-")
+ "+"
+ "-")
+ num))))))))
(cdr (assoc color-name
(cdr (assoc theme-name alect-colors)))))
-(defun alect-get-customization (theme)
+(defun alect-get-customization (theme &optional invert)
"Return cons of settings for theme THEME.
Car of the cons is a list for `custom-theme-set-faces' function.
Cdr of the cons is a list for `custom-theme-set-variables' function.
-THEME is a name of the color theme (symbol from `alect-colors')."
- (cl-flet ((gc (col) (alect-get-color theme col)))
+THEME is a name of the color theme (symbol from `alect-colors').
+For INVERT, see `alect-get-color'."
+ (cl-flet ((gc (col) (alect-get-color theme col invert)))
(cons
;; FACES
`(;; basic colors
@@ -1124,8 +1159,12 @@ static char *gnus-pointer[] = {
(vc-annotate-background ,(gc 'bg-2))
))))
-(defmacro alect-create-theme (theme)
- (let* ((theme-name (intern (concat "alect-" (symbol-name theme))))
+(defmacro alect-create-theme (theme &optional invert)
+ "Define and provide a color theme THEME.
+For INVERT, see `alect-get-color'."
+ (let* ((theme-name (intern (concat "alect-"
+ (symbol-name theme)
+ (and invert "-alt"))))
(theme-vals (alect-get-customization theme invert))
(theme-faces (car theme-vals))
(theme-vars (cdr theme-vals)))
@@ -1135,7 +1174,9 @@ static char *gnus-pointer[] = {
(defvar gnus-mode-line-image-cache nil)
`(progn
- (deftheme ,theme-name ,(format "Just another %s color theme." theme))
+ (deftheme ,theme-name ,(format "The %s color theme."
+ (concat (and invert "alternative ")
+ (symbol-name theme))))
(apply 'custom-theme-set-variables ',theme-name ',theme-vars)
(apply 'custom-theme-set-faces ',theme-name ',theme-faces)
(provide-theme ',theme-name))))
- [nongnu] elpa/alect-themes 61dac55 051/269: Update README, (continued)
- [nongnu] elpa/alect-themes 61dac55 051/269: Update README, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes b0a96eb 063/269: Modify red colors for the dark theme, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes ba7beed 007/269: Add .gitignore, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes b51ffad 012/269: Update README, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes e25ff17 008/269: Update package commentary, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 2591fdd 013/269: Add faces for sh-mode, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes fbf0829 011/269: Update colors sample, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes dc88e28 015/269: Add customization type for `alect-colors' variable, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 3139f1a 017/269: Add description of customizing color palettes, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 95c7091 021/269: Combine `alect-get-faces' and `alect-get-vars', ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 7b42f0a 022/269: Add support for inverted (alternative) themes,
ELPA Syncer <=
- [nongnu] elpa/alect-themes 602655e 023/269: Add files for alternative themes, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes d3443de 024/269: Replace white/gray/black with a gray group, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes a10591e 025/269: Improve custom-button faces, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes ef4816b 026/269: Improve yellow colors for the light theme, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 6c459a6 029/269: Update .gitignore, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes ff095a8 030/269: Update README, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 209804e 037/269: Inherit `org-agenda-structure' from `alect-title', ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes b0ee25c 040/269: Delete unknown w3m faces, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes d9583c9 044/269: Remove redundant part from mode-line face, ELPA Syncer, 2021/10/21
- [nongnu] elpa/alect-themes 5e6748d 042/269: Improve match face, ELPA Syncer, 2021/10/21