aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/capture-default-faces.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-19 11:00:58 -0400
committerCraig Jennings <c@cjennings.net>2026-06-19 11:00:58 -0400
commit4035aa7a1efee80a0b8e86e792d6e1e3c4daa76b (patch)
tree2cd20fba2be12990b29fa3318bcbdcd797c81420 /scripts/theme-studio/capture-default-faces.py
parentdde63d2708d1d374b2166d3da573402492df072a (diff)
downloaddotemacs-4035aa7a1efee80a0b8e86e792d6e1e3c4daa76b.tar.gz
dotemacs-4035aa7a1efee80a0b8e86e792d6e1e3c4daa76b.zip
refactor(theme-studio): derive the Python face model from one spec list
STYLE_DEFAULTS, default_faces.seed, and capture-default-faces' ATTRS each hand-listed the face attributes, so adding one meant editing three places in step. face_specs.FACE_ATTRS is now one row per attribute carrying the model key, default, capture keyword, snapshot field, and seed transform kind. STYLE_DEFAULTS derives from it (same keys, order, and values), seed iterates it applying the per-kind extraction, and the capture probe map derives its emacs-attr to snapshot-field pairs from it. The snapshot-to-model translation stays genuinely per-attribute (colors prefer the Hex variant, flags become objects, weight/slant are value-narrowed), but the attribute list itself is now single-sourced. Verified byte-identical: STYLE_DEFAULTS and ATTRS match the old literals, the generated page is unchanged, and the suite is green. app-core.js mirrors this list by hand since the page is a separate runtime.
Diffstat (limited to 'scripts/theme-studio/capture-default-faces.py')
-rw-r--r--scripts/theme-studio/capture-default-faces.py22
1 files changed, 7 insertions, 15 deletions
diff --git a/scripts/theme-studio/capture-default-faces.py b/scripts/theme-studio/capture-default-faces.py
index 3de09941b..8c8fd6679 100644
--- a/scripts/theme-studio/capture-default-faces.py
+++ b/scripts/theme-studio/capture-default-faces.py
@@ -17,6 +17,8 @@ import re
import subprocess
import tempfile
+from face_specs import FACE_ATTRS
+
HERE = pathlib.Path(__file__).resolve().parent
ROOT = HERE.parents[1]
OUT = HERE / "emacs-default-faces.json"
@@ -85,21 +87,11 @@ BUILTIN_FEATURES = [
"shr",
]
-ATTRS = {
- ":foreground": "foreground",
- ":background": "background",
- ":weight": "weight",
- ":slant": "slant",
- ":underline": "underline",
- ":strike-through": "strike",
- ":overline": "overline",
- ":box": "box",
- ":height": "height",
- ":inherit": "inherit",
- ":inverse-video": "inverseVideo",
- ":extend": "extend",
- ":distant-foreground": "distantForeground",
-}
+# Emacs face :attribute keyword -> snapshot field name, derived from the shared
+# face-attribute spec so the capture, the seed extraction, and STYLE_DEFAULTS all
+# stay in step. Attributes the snapshot doesn't carry (e.g. family) have no
+# capture keyword and are skipped.
+ATTRS = {a["capture"]: a["snapshot"] for a in FACE_ATTRS if a["capture"]}
def x11_colors() -> dict[str, str]: