aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/generate.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-19 11:23:25 -0400
committerCraig Jennings <c@cjennings.net>2026-06-19 11:23:25 -0400
commitd32553aa1a8cd49a514a347558524c98eb566627 (patch)
treeea20cfabadc920de8eb56074b2f6487ae35dd121 /scripts/theme-studio/generate.py
parent569a539bea5e14acd91c6ddd0fdae01ee4bc6912 (diff)
downloaddotemacs-d32553aa1a8cd49a514a347558524c98eb566627.tar.gz
dotemacs-d32553aa1a8cd49a514a347558524c98eb566627.zip
refactor(theme-studio): dedup the palette harvest and color-pair walks
generate.py's add_default_palette_colors repeated the same fg/bg/box-color harvest three times (syntax, ui, package faces); it now calls one _harvest_spec_colors helper, preserving the add order so the palette and generated page are byte-identical. default_faces' _build_color_hex and _build_color_names each walked the same faces -> chosen/effective -> foreground/background/distantForeground nesting; both now consume one _iter_color_pairs generator and only differ in their key choice and filter. The rebuilt color maps match the originals exactly. I left the lower-value generate.py items (a build() wrapper, dict-driven fill_data) and the capture/face-coverage script dedups for later: they touch import-time behavior or scripts the suite doesn't run, so they want their own verification rather than riding this change.
Diffstat (limited to 'scripts/theme-studio/generate.py')
-rw-r--r--scripts/theme-studio/generate.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/theme-studio/generate.py b/scripts/theme-studio/generate.py
index d774a6061..43ebf02c6 100644
--- a/scripts/theme-studio/generate.py
+++ b/scripts/theme-studio/generate.py
@@ -177,25 +177,23 @@ def add_palette_color(palette,defaults,value,label=None):
name=base+'-'+str(n); n+=1
palette.append([value,name,column_id(name)])
+def _harvest_spec_colors(palette,defaults,spec):
+ """Add a face spec's fg, bg, and box color (if any) to the palette, in order."""
+ add_palette_color(palette,defaults,spec.get('fg'))
+ add_palette_color(palette,defaults,spec.get('bg'))
+ if spec.get('box'):
+ add_palette_color(palette,defaults,spec['box'].get('color'))
+
def add_default_palette_colors(palette,map_,syntax,uimap,apps,defaults):
for key,value in map_.items():
add_palette_color(palette,defaults,value,'bg' if key=='bg' else 'fg' if key=='p' else None)
for spec in syntax.values():
- add_palette_color(palette,defaults,spec.get('fg'))
- add_palette_color(palette,defaults,spec.get('bg'))
- if spec.get('box'):
- add_palette_color(palette,defaults,spec['box'].get('color'))
+ _harvest_spec_colors(palette,defaults,spec)
for _face,spec in uimap.items():
- add_palette_color(palette,defaults,spec.get('fg'))
- add_palette_color(palette,defaults,spec.get('bg'))
- if spec.get('box'):
- add_palette_color(palette,defaults,spec['box'].get('color'))
+ _harvest_spec_colors(palette,defaults,spec)
for app in apps.values():
for _face,_label,spec in app['faces']:
- add_palette_color(palette,defaults,spec.get('fg'))
- add_palette_color(palette,defaults,spec.get('bg'))
- if spec.get('box'):
- add_palette_color(palette,defaults,spec['box'].get('color'))
+ _harvest_spec_colors(palette,defaults,spec)
def apply_seed_packages(apps,data,seed):
if seed: