[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/autothemer 5d7ae3a0be 06/29: Rainbow mode: Colorize names
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/autothemer 5d7ae3a0be 06/29: Rainbow mode: Colorize names from palette |
Date: |
Sun, 28 Aug 2022 22:58:40 -0400 (EDT) |
branch: elpa/autothemer
commit 5d7ae3a0be98c634e5aeb6a12d30347ceb2df7b5
Author: Jason Milkins <jasonm23@gmail.com>
Commit: Jason Milkins <jasonm23@gmail.com>
Rainbow mode: Colorize names from palette
---
autothemer.el | 60 +++++++++++++++++++++----
tests/{theme-example.el => autothemer-tests.el} | 0
2 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/autothemer.el b/autothemer.el
index 3ac4636028..5f97e60168 100644
--- a/autothemer.el
+++ b/autothemer.el
@@ -308,7 +308,9 @@ Otherwise, append NEW-COLUMN to every element of LISTS."
Search the `autothemer--current-theme' color palette for COLOR-NAME
and returns a color in the form of `autothemer--color' struct.
-See also `autothemer--color-p', `autothemer--color-name',
`autothemer--color-value'."
+See also `autothemer--color-p',
+ `autothemer--color-name',
+ `autothemer--color-value'."
(autothemer--current-theme-guard)
(--find
(eql (intern color-name)
@@ -321,7 +323,9 @@ Current palette is read from `autothemer--current-theme'.
The selected color will be in the form of a `autothemer--color'
-See also `autothemer--color-p', `autothemer--color-name',
`autothemer--color-value'."
+See also `autothemer--color-p',
+ `autothemer--color-name',
+ `autothemer--color-value'."
(autothemer--current-theme-guard)
(let*
((selected
@@ -345,7 +349,7 @@ See also `autothemer--color-p', `autothemer--color-name',
`autothemer--color-val
(autothemer--get-color color-name)))
(defun autothemer-insert-color ()
- "Interactively select and insert a color from the current autotheme palette."
+ "Select and insert a color from the current autotheme palette."
(interactive)
(autothemer--current-theme-guard)
(let ((color (autothemer--color-value
@@ -353,7 +357,7 @@ See also `autothemer--color-p', `autothemer--color-name',
`autothemer--color-val
(insert color)))
(defun autothemer-insert-color-name ()
- "Interactively select and insert a color name from the current autotheme
palette."
+ "Select and insert a color name from the current autotheme palette."
(interactive)
(autothemer--current-theme-guard)
(let ((color-name (autothemer--color-name
@@ -385,11 +389,35 @@ If PLIST is nil, ARGS are bound to BODY nil values."
Load/eval the required autothemer theme source (not
byte-compiled) to set `autothemer--current-theme'."
-
+ (autothemer--current-theme-guard)
`(let ,(--map (list (autothemer--color-name it) (autothemer--color-value it))
(autothemer--theme-colors autothemer--current-theme))
,@body))
+;;; Colorize alist for rainbow-mode
+(defun autothemer-colorize-alist ()
+ "Generate an alist for use with rainbow-mode.
+
+To colorize use:
+
+ (rainbow-colorize-by-assoc (autothemer-colorize-alist))
+
+Colors are from `autothemer--current-theme'."
+ (autothemer--current-theme-guard)
+ (--map (cons (format "%s" (autothemer--color-name it))
+ (autothemer--color-value it))
+ (autothemer--theme-colors autothemer--current-theme)))
+
+(defvar autothemer--colors-font-lock-keywords nil)
+
+(defun autothemer-colorize ()
+ "Colorize using rainbow-mode."
+ (interactive)
+ (setq autothemer--colors-font-lock-keywords
+ `((,(regexp-opt (mapcar 'car (autothemer-colorize-alist)) 'words)
+ (0 (rainbow-colorize-by-assoc (autothemer-colorize-alist))))))
+ (font-lock-add-keywords nil autothemer--colors-font-lock-keywords t))
+
;;; SVG Palette generator...
(defun autothemer-generate-palette-svg (&optional options)
@@ -439,10 +467,24 @@ Swatch Template parameters:
%5$s - swatch-color-name"
(interactive)
(autothemer--plist-bind
- (theme-file theme-name theme-description theme-url
- swatch-width swatch-height columns page-template
- swatch-template font-family bg-color
- text-color text-accent-color svg-out-file)
+ (theme-file
+ theme-name
+ theme-description
+ theme-url
+
+ swatch-width
+ swatch-height
+ columns
+
+ page-template
+ swatch-template
+
+ font-family
+ bg-color
+ text-color
+ text-accent-color
+
+ svg-out-file)
options
(let ((theme-file (or theme-file (read-file-name "Select autothemer theme
.el file: "))))
(load-file theme-file) ;; make it the current-theme
diff --git a/tests/theme-example.el b/tests/autothemer-tests.el
similarity index 100%
rename from tests/theme-example.el
rename to tests/autothemer-tests.el
- [nongnu] elpa/autothemer updated (96ca493b9f -> f3a23b4b6d), ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer e0b1c2c0ad 01/29: Add autothemer-let-palette, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer aa63d8cd5e 02/29: Add github test workflow and tests. Fail expected due to display type., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 04a4fad366 03/29: Make sure package dash is available., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer b1124883ef 04/29: +x bin/setup, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 0d39a92d90 07/29: Fix naming of README.md, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer a528436677 16/29: 0.2.10, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer b0df7578fc 17/29: Additional parameters for svg generator., ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 5d7ae3a0be 06/29: Rainbow mode: Colorize names from palette,
ELPA Syncer <=
- [nongnu] elpa/autothemer 55db54a2ef 08/29: User parameters added for SVG generator, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 12dbb2e605 15/29: Merge branch 'master' into develop, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 67224c4a4c 21/29: Fix test run, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 726d5b99bb 05/29: Only supporting 26.1 and above, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 2b55532e0a 10/29: Fix test runner, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer f4ab56f44f 13/29: Structural change v-stacking, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 9bde5000f4 19/29: CONTRIBUTING.md, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 0b558a7cab 20/29: Update autothemer.el, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 882fd8f7bb 22/29: Update README, bin/test & SVG swatch sort hue-sat, ELPA Syncer, 2022/08/28
- [nongnu] elpa/autothemer 77ad2ec093 23/29: Trigger actions for pushes to master, or PRs, ELPA Syncer, 2022/08/28