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

[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



reply via email to

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