branch: elpa/autothemer
commit 167cdcedb1d7a554683c83506561eecd644a82cf
Author: jasonm23 <[email protected]>
Commit: jasonm23 <[email protected]>
0.2.15 Insert missing spec(s)
---
autothemer.el | 64 +++++++++++++++++++++++++++++++++++------------
tests/autothemer-tests.el | 2 +-
2 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/autothemer.el b/autothemer.el
index 8d2def7121..0e1a8dfdd8 100644
--- a/autothemer.el
+++ b/autothemer.el
@@ -7,7 +7,7 @@
;; Maintainer: Jason Milkins <[email protected]>
;;
;; URL: https://github.com/jasonm23/autothemer
-;; Version: 0.2.14
+;; Version: 0.2.15
;; Package-Requires: ((dash "2.10.0") (emacs "26.1"))
;;
;;; License:
@@ -34,6 +34,8 @@
;; - Generate specs for unthemed faces using the theme color palette.
;; - `autothemer-generate-templates'
;; - `autothemer-generate-templates-filtered' (filter by regexp)
+;; - `autothemer-insert-missing-face'
+;; - `autothemer-insert-missing-faces'
;; - Generate a palette SVG image
;; - `autothemer-generate-palette-svg'
;; - Insert a color name or color from the active palette
@@ -62,9 +64,7 @@
description)
(defvar autothemer-current-theme nil
- "Internal variable of type `autothemer--theme' used by autothemer.
-Contains the color palette and the list of faces most recently
-customized using `autothemer-deftheme'.")
+ "Palette and face list for last evaluated `autothemer-deftheme'.")
(defvar autothemer-hue-groups
'((red (345 . 10))
@@ -364,6 +364,50 @@ Will become:
(cl-loop for row in (cdr palette)
collect (list (car row) (elt row (1+ n)))))
+;;;###autoload
+(defun autothemer-insert-missing-face ()
+ "Insert a face spec template for an unthemed face.
+An approximate color from the palette will be used for
+color attributes."
+ (interactive)
+ (let ((selected (completing-read "Select an un-themed face: "
(autothemer--unthemed-faces))))
+ (insert
+ (replace-regexp-in-string "\n" ""
+ (pp-to-string
+ (autothemer--approximate-spec
+ (autothemer--alist-to-reduced-spec (intern selected)
(autothemer--face-to-alist (intern selected)))
+ autothemer-current-theme))))))
+
+;;;###autoload
+(defun autothemer-insert-missing-faces (&optional regexp)
+ "Insert face spec templates for unthemed faces matching REGEXP.
+An error is shown when no current theme is available."
+ (interactive)
+ (autothemer--current-theme-guard)
+ (let* ((regexp (or regexp
+ (completing-read
+ "(Match un-themed face set) Regexp: "
+ (autothemer--unthemed-faces))))
+ (missing-faces
+ (if (null regexp)
+ (autothemer--unthemed-faces)
+ (--filter
+ (string-match-p regexp (symbol-name it))
+ (autothemer--unthemed-faces))))
+ (templates (--reduce
+ (format "%s%s" acc it)
+ (--map
+ (format "%s\n"
+ (replace-regexp-in-string
+ "\n" ""
+ (pp-to-string
+ (autothemer--approximate-spec
+ (autothemer--alist-to-reduced-spec
+ it (autothemer--face-to-alist it))
+ autothemer-current-theme))))
+ missing-faces))))
+ (insert templates)))
+
;;;###autoload
(defun autothemer-generate-templates-filtered (regexp)
"Autogenerate customizations for unthemed faces matching REGEXP.
@@ -410,18 +454,6 @@ Otherwise, append NEW-COLUMN to every element of LISTS."
(if lists (inline (-zip-with #'append lists new-column))
new-column))
-(defun autothemer-insert-missing-face ()
- "Insert a face spec template for an unthemed face.
-An approximate color from the palette will be used for
-color attributes."
- (interactive)
- (let ((selected (completing-read "Select an un-themed face: "
(autothemer--unthemed-faces))))
- (insert
- (pp
- (autothemer--approximate-spec
- (autothemer--alist-to-reduced-spec (intern selected)
(autothemer--face-to-alist (intern selected)))
- autothemer-current-theme)))))
-
(defun autothemer--current-theme-guard ()
"Guard functions from executing when there's no current theme."
(unless autothemer-current-theme
diff --git a/tests/autothemer-tests.el b/tests/autothemer-tests.el
index 390e589979..fc1cd4079e 100644
--- a/tests/autothemer-tests.el
+++ b/tests/autothemer-tests.el
@@ -1,6 +1,6 @@
;; autothemer-tests.el
-;; Version: 0.2.14
+;; Version: 0.2.15
;;; Code: