Reduce the amount of pain and boilerplate code needed to create custom themes using autothemer-deftheme
.
Autothemer also includes interactive commands and functions to assist with theme building, here are a few highlights...
- Generate specs for unthemed faces using the theme color palette.
autothemer-generate-templates
autothemer-generate-templates-filtered
(filter by regexp)
- Generate a palette SVG image
autothemer-generate-palette-svg
- Insert a color name or color from the active palette
autothemer-insert-color-name
autothemer-insert-color
- Colorize/font-lock palette color names in the buffer
autothemer-colorize
(requiresrainbow-mode
during development.)
- autothemer-colorize
- autothemer-generate-palette-svg
- autothemer-generate-templates
- autothemer-generate-templates-filtered
- autothemer-insert-color
- autothemer-insert-color-name
- autothemer-brightness-group
- autothemer-color-brightness
- autothemer-color-hue
- autothemer-color-sat
- autothemer-color-to-group
- autothemer-darkest-order
- autothemer-desaturated-order
- autothemer-group-and-sort
- autothemer-group-colors
- autothemer-group-sort
- autothemer-groups-to-palette
- autothemer-hex-to-rgb
- autothemer-hue-group
- autothemer-hue-order
- autothemer-lightest-order
- autothemer-saturated-order
- autothemer-saturation-group
- autothemer-sort-palette
- autothemer-let-palette
- autothemer--alist-to-reduced-spec
- autothemer--approximate-spec
- autothemer--color-distance
- autothemer--color-to-hsv
- autothemer--colorize-alist
- autothemer--cons-to-tree
- autothemer--current-theme-guard
- autothemer--demote-heads
- autothemer--extract-display
- autothemer--extract-let-block
- autothemer--face-to-alist
- autothemer--fill-empty-palette-slots
- autothemer--find-closest-color
- autothemer--get-color
- autothemer--pad-with-nil
- autothemer--reduced-spec-to-facespec
- autothemer--replace-nil-by-precursor
- autothemer--select-color
- autothemer--unindent
- autothemer--unthemed-faces
In the current buffer, colorize palette color names, from the last evaluated theme, by their color value.
function signature
(autothemer-colorize)
Create an SVG palette image for a theme.
Optional parameter options
(a plist). Any required values not
supplied in options
will use defaults or prompt interactively.
Option | Description |
---|---|
:theme-file |
theme filename |
:theme-name |
override the title found in :theme-file |
:theme-description |
override the description found in :theme-file |
:theme-url |
override the url found in :theme-file |
:font-family |
font name to use in the generated SVG |
:columns |
number of columns for each palette row (default: 6) |
:bg-color |
Page background color |
:text-color |
Main text color |
:text-accent-color |
Text accent color |
:page-template |
see page-template below |
:page-top-margin |
(default: 120) |
:page-right-margin |
(default: 30) |
:page-bottom-margin |
(default: 60) |
:page-left-margin |
(default: 30) |
:swatch-template |
see swatch-template below |
:swatch-border-color |
the border color of a color swatch |
:swatch-width |
px spacing width of a color swatch (default: 100) |
:swatch-height |
px spacing height of a color swatch (default: 150) |
:swatch-rotate |
degrees of rotation for swatch (default: 45) |
:h-space |
horizontal-space between swatches (default: 10) |
:v-space |
vertical-space between swatches (default: 10) |
:sort-palette |
arrange palette using a function name |
:group-swatches |
boolean |
:svg-out-file |
the file/pathname to save SVG output |
For advanced customization the :page-template and :swatch-template can be used to provide customize the SVG templates.
Note: Template parameters are filled by format
so we mark them as follows:
Page Template parameters:
Parameter | Description |
---|---|
%1$s |
width |
%2$s |
height |
%3$s |
font-family |
%4$s |
text-color |
%5$s |
text-accent-color |
%6$s |
bg-color |
%7$s |
theme-name |
%8$s |
theme-description |
%9$s |
theme-url |
%10$s |
color swatches |
Swatch Template parameters:
Parameter | Description |
---|---|
%1$s |
x |
%2$s |
y |
%3$s |
swatch-border-color |
%4$s |
swatch-color |
%5$s |
text-accent-color |
%6$s |
swatch-color-name |
function signature
(autothemer-generate-palette-svg (&optional options))
Autogenerate customizations for unthemed faces (optionally by regexp
).
Generate customizations that approximate current face definitions using the
nearest colors in the color palette of autothemer-current-theme
.
An error is shown when no current theme is available.
function signature
(autothemer-generate-templates (&optional regexp))
Autogenerate customizations for unthemed faces matching regexp
.
Calls autothemer-generate-templates
after user provides regexp
interactively.
function signature
(autothemer-generate-templates-filtered (regexp))
Select and insert a color from the current autotheme palette.
function signature
(autothemer-insert-color)
Select and insert a color name from the current autotheme palette.
function signature
(autothemer-insert-color-name)
Return the brightness group of color
.
Functionally identical to autothemer-hue-groups
for brightness.
Optionally provide a list of brightness-groups
.
The default is autothemer-20-percent-brightness-groups
.
function signature
(autothemer-brightness-group (color &optional brightness-groups))
Return the HSV brightness of color
(hex color or autothemer--color struct).
function signature
(autothemer-color-brightness (color))
Return the HSV hue of color
(hex color or autothemer--color struct).
function signature
(autothemer-color-hue (color))
Return the HSV saturation of color
(hex color or autothemer--color struct).
function signature
(autothemer-color-sat (color))
Group color
using fn
, in groups
.
function signature
(autothemer-color-to-group (color fn groups))
Return t if the darkness of a
> b
.
function signature
(autothemer-darkest-order (a b))
Return t if the saturation of a
< b
.
function signature
(autothemer-desaturated-order (a b))
Group and sort palette
using options
.
Options is a plist of:
Option | Description |
---|---|
:group-fn |
mandatory group function |
:group-args |
optional group args (to use a non-default group) |
:sort-fn |
optional sort function |
See color grouping functions and group lists:
Hue grouping:
Function | Description |
---|---|
autothemer-hue-group |
color hue group for COLOR |
Hue Groups | Description |
---|---|
autothemer-hue-groups |
group colors into major hue groups (default) |
autothemer-simple-hue-groups |
group colors into broad hue groups |
Brightness grouping:
Function | Description |
---|---|
autothemer-brightness-group |
brightness group for COLOR |
Brightness Groups | Description |
---|---|
autothemer-dark-mid-light-brightness-groups |
3 brightness groups |
autothemer-10-percent-brightness-groups |
10 brightness groups |
autothemer-20-percent-brightness-groups |
5 brightness groups (default) |
Saturation grouping:
Function | Description |
---|---|
autothemer-saturation-group |
saturation group for COLOR |
Saturation Groups | Description |
---|---|
autothemer-low-mid-high-saturation-groups |
3 saturation groups |
autothemer-10-percent-saturation-groups |
10 saturation groups |
autothemer-20-percent-saturation-groups |
5 saturation groups (default) |
Sorting:
The sort/ordering functions take args A and B, which are expected
to be autothemer--color
structs.
Sort Functions | Description |
---|---|
autothemer-darkest-order |
darkest to lightest |
autothemer-lightest-order |
lightest to darkest |
autothemer-hue-order |
sort by hue |
autothemer-saturated-order |
sort by most saturated to least |
autothemer-desaturated-order |
sort by least saturated to most |
function signature
(autothemer-group-and-sort (palette options))
Group palette
colors into groups as defined in plist options
:
:group-fn
- mandatory group function
:group-args
- args for group-fn
function signature
(autothemer-group-colors (palette options))
Sort groups
of colors using sort-fn
.
groups
are produced by autothemer-group-colors
.
function signature
(autothemer-group-sort (groups sort-fn))
Flatten a grouped-palette
from autothemer-group-and-sort
to a single list.
function signature
(autothemer-groups-to-palette (grouped-palette))
Convert hex
to (r g b)
.
r
, g
, b
will be values 0..65535
function signature
(autothemer-hex-to-rgb (hex))
Return the color hue group for color
.
Optionally provide a list of hue-groups
.
(default uses autothemer-hue-groups
.)
Also available is autothemer-simple-hue-groups
,
both are customizable, or define your own.
This facilitates hue grouping & sorting by a secondary axis. For example sort a list of colors by some axis (brightness or saturation). Then group by hue groups, and sort the groups. The format of each group in the list is:
(group-name (n1 . n2))
Where group-name
is a symbol to name the group,
(n1 . n2)
is a hue range specifier (in degrees)
low n1
to high n2
.
A hue range which crosses the apex (i.e. 360°..0°
) is permitted.
function signature
(autothemer-hue-group (color &optional hue-groups))
Return t if the hue of a
> b
.
function signature
(autothemer-hue-order (a b))
Return t if the lightness of a
> b
.
function signature
(autothemer-lightest-order (a b))
Return t if the saturation of a
> b
.
function signature
(autothemer-saturated-order (a b))
Return the saturation group of color
.
Functionally identical to autothemer-hue-groups
for saturation.
Optionally provide a list of saturation-groups
.
The default is autothemer-20-percent-saturation-groups
.
function signature
(autothemer-saturation-group (color &optional saturation-groups))
Produce a list of sorted theme-colors
using sort-fn
.
If sort-fn
is nil, sort by default autothemer-darkest-order
.
Grouping is supported via group-fn
& group-args
.
See autothemer-group-and-sort
for a full list.
function signature
(autothemer-sort-palette (theme-colors &optional sort-fn group-fn group-args))
Provide a let block for body
from autothemer-current-theme
.
Load/eval the required autothemer source (not byte-compiled) to set
autothemer-current-theme', before using
autothemer-let-palette`
function signature
;; assuming your theme has a palette color of juicy-watermelon
(autothemer-let-palette ;;
(message "%s" juicy-watermelon))
Generate a reduced-spec for facename
, based on the face attribute alist
.
function signature
(autothemer--alist-to-reduced-spec (facename alist))
Replace colors in reduced-spec
by their closest approximations in theme
.
Replace every expression in reduced-spec
that passes
color-defined-p
by the closest approximation found in
autothemer-current-theme
. Also quote all face names and
unbound symbols, such as normal
or demibold
.
function signature
(autothemer--approximate-spec (reduced-spec theme))
Return the distance in rgb space between color
and AUTOTHEMER-color
.
Here, color
is an Emacs color specification and AUTOTHEMER-color
is of
type autothemer--color
.
function signature
(autothemer--color-distance (color autothemer-color))
Convert rgb
, a list of (r g b)
to list (h s v)
.
The r
g
b
values can range between 0..65535
.
In (h s v)
h
, s
and v
are 0.0..1.0
.
function signature
(autothemer--color-to-hsv (rgb))
Generate an alist for use with rainbow-mode.
To colorize use:
(rainbow-colorize-by-assoc (autothemer--colorize-alist))
Colors are from autothemer-current-theme
.
function signature
(autothemer--colorize-alist)
Turn the-cons
into a list, unless its cdr is unspecified
.
function signature
(autothemer--cons-to-tree (the-cons))
Guard functions from executing when there's no current theme.
function signature
(autothemer--current-theme-guard)
Demote every list head within expr
by one element.
E.g., (a (b c d) e (f g)) -> (list a (list b c d) e (list f g)).
function signature
(autothemer--demote-heads (expr))
Extract from palette
display specification #n
.
function signature
(autothemer--extract-display (palette n))
Extract a variable definition block from palette
for display type n
.
function signature
(autothemer--extract-let-block (palette n))
Return the attribute alist for face
in frame (selected-frame).
function signature
(autothemer--face-to-alist (face))
Fill empty palette
slots so each display has all color-definitions.
function signature
(autothemer--fill-empty-palette-slots (palette))
Return the element of colors
that is closest in rgb space to color
.
Here, color
is an Emacs color specification and colors
is a list
of autothemer--color
structs.
function signature
(autothemer--find-closest-color (colors color))
Return color palette object for (string) color-name
.
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
.
function signature
(autothemer--get-color (color-name))
Make sure that row
has at least min-number-of-elements
.
Pad with nil if necessary.
function signature
(autothemer--pad-with-nil (row min-number-of-elements))
Create a face spec for display
, with specs reduced-specs
.
For example:
(autothemer--reduced-spec-to-facespec '(min-colors 60) '(button (:underline t :foreground red)))
;; => `(button (((min-colors 60) (:underline ,t :foreground ,red)))).
function signature
(autothemer--reduced-spec-to-facespec (display reduced-specs))
Replace nil colors in palette-row
with their precursor.
palette-row
is of the form (name color [color ...])
Where the first color
must be non nil.
Any subsequent nil color will be replaced by the previous value.
For example:
("red-foo" "#FF0000" nil)
Will become:
("red-foo" "#FF0000" "#FF0000")
function signature
(autothemer--replace-nil-by-precursor (palette-row))
Select a color from the current palette, optionally use prompt
.
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
.
function signature
(autothemer--select-color (&optional prompt))
Unindent string s
marked with | chars.
function signature
(autothemer--unindent (s))
Find uncustomized faces.
Iterate through all currently defined faces and return those that
were left uncustomized by the most recent call to
autothemer-deftheme
.
function signature
(autothemer--unthemed-faces)