From 569a539bea5e14acd91c6ddd0fdae01ee4bc6912 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 19 Jun 2026 11:09:01 -0400 Subject: refactor(theme-studio): single-source the bespoke-app list in face_data The bespoke apps were listed twice: generate.py's _BESPOKE_APPS (key, label, preview, faces, prefix, seed) and app_inventory's BESPOKE_APPS set of keys, which had drifted (it carried both "org" and "org-mode"). The spec list now lives in face_data.py as BESPOKE_APP_SPECS, beside the FACES/SEED constants it references. generate.py builds APPS from it, and app_inventory derives its exclusion set from the same keys plus an explicit "org" alias of the "org-mode" app. Adding a bespoke app is now one row. APPS order and the generated page are unchanged. --- scripts/theme-studio/app_inventory.py | 33 +++++++-------------------------- scripts/theme-studio/face_data.py | 30 ++++++++++++++++++++++++++++++ scripts/theme-studio/generate.py | 31 +++---------------------------- 3 files changed, 40 insertions(+), 54 deletions(-) (limited to 'scripts') diff --git a/scripts/theme-studio/app_inventory.py b/scripts/theme-studio/app_inventory.py index ed904b119..11ca605d1 100644 --- a/scripts/theme-studio/app_inventory.py +++ b/scripts/theme-studio/app_inventory.py @@ -7,33 +7,14 @@ import os from collections.abc import Sequence from typing import Any +from face_data import BESPOKE_APP_SPECS -BESPOKE_APPS = { - "magit", - "elfeed", - "org", - "org-mode", - "mu4e", - "gnus", - "org-faces", - "ghostel", - "auto-dim-other-buffers", - "dashboard", - "lsp-mode", - "git-gutter", - "flycheck", - "dired", - "dirvish", - "calibredb", - "erc", - "org-drill", - "org-noter", - "signel", - "pearl", - "slack", - "telega", - "shr", -} + +# Keys of the bespoke apps (single-sourced in face_data), excluded from the +# generic-inventory path so they aren't also emitted as plain inventory apps. +# "org" is an explicit alias of the "org-mode" bespoke app, so an inventory +# package literally named "org" never gets a duplicate generic entry. +BESPOKE_APPS = {spec[0] for spec in BESPOKE_APP_SPECS} | {"org"} # Inventory apps (not in BESPOKE_APPS) default to the generic preview. A few have diff --git a/scripts/theme-studio/face_data.py b/scripts/theme-studio/face_data.py index a73db7137..58e38a906 100644 --- a/scripts/theme-studio/face_data.py +++ b/scripts/theme-studio/face_data.py @@ -328,3 +328,33 @@ GNUS_SEED={ "gnus-cite-1":{"fg":"sage"},"gnus-cite-2":{"fg":"steel"},"gnus-cite-3":{"fg":"gold"},"gnus-cite-4":{"fg":"blue"},"gnus-cite-5":{"fg":"sage"},"gnus-cite-6":{"fg":"steel"},"gnus-cite-7":{"fg":"gold"},"gnus-cite-8":{"fg":"blue"},"gnus-cite-9":{"fg":"sage"},"gnus-cite-10":{"fg":"steel"},"gnus-cite-11":{"fg":"gold"},"gnus-cite-attribution":{"fg":"silver","italic":True}, "gnus-signature":{"fg":"pewter","italic":True},"gnus-button":{"fg":"blue","underline":True}, "gnus-emphasis-bold":{"bold":True},"gnus-emphasis-italic":{"italic":True},"gnus-emphasis-underline":{"underline":True},"gnus-emphasis-strikethru":{"fg":"pewter","strike":True},"gnus-emphasis-highlight-words":{"fg":"gold","bold":True}} + +# The bespoke package apps, single-sourced here. Each row is +# (key, label, preview, FACES, prefix, SEED); add an app by adding one row. +# generate.py builds APPS from this, and app_inventory derives the set of +# bespoke keys (to exclude them from the generic-inventory path) from it too. +BESPOKE_APP_SPECS=[ + ("org-mode","org-mode","org",ORG_FACES,"org-",ORG_SEED), + ("magit","magit","magit",MAGIT_FACES,"magit-",MAGIT_SEED), + ("elfeed","elfeed","elfeed",ELFEED_FACES,"elfeed-",ELFEED_SEED), + ("mu4e","mu4e","mu4e",MU4E_FACES,"mu4e-",MU4E_SEED), + ("gnus","gnus (mu4e article view)","gnus",GNUS_FACES,"gnus-",GNUS_SEED), + ("org-faces","org-faces","orgfaces",ORGFACES_FACES,"org-faces-",ORGFACES_SEED), + ("ghostel","ghostel","ghostel",GHOSTEL_FACES,"ghostel-",GHOSTEL_SEED), + ("auto-dim-other-buffers","auto-dim","autodim",AUTODIM_FACES,"auto-dim-other-buffers-",AUTODIM_SEED), + ("dashboard","dashboard","dashboard",DASHBOARD_FACES,"dashboard-",DASHBOARD_SEED), + ("lsp-mode","lsp-mode","lsp",LSP_FACES,"lsp-",LSP_SEED), + ("git-gutter","git-gutter","gitgutter",GITGUTTER_FACES,"git-gutter:",GITGUTTER_SEED), + ("flycheck","flycheck","flycheck",FLYCHECK_FACES,"flycheck-",FLYCHECK_SEED), + ("dired","dired","dired",DIRED_FACES,"dired-",DIRED_SEED), + ("dirvish","dirvish","dirvish",DIRVISH_FACES,"dirvish-",DIRVISH_SEED), + ("calibredb","calibredb","calibredb",CALIBREDB_FACES,"calibredb-",CALIBREDB_SEED), + ("erc","erc","erc",ERC_FACES,"erc-",ERC_SEED), + ("org-drill","org-drill","orgdrill",ORGDRILL_FACES,"org-drill-",ORGDRILL_SEED), + ("org-noter","org-noter","orgnoter",ORGNOTER_FACES,"org-noter-",ORGNOTER_SEED), + ("signel","signel","signel",SIGNEL_FACES,"signel-",SIGNEL_SEED), + ("pearl","pearl","pearl",PEARL_FACES,"pearl-",PEARL_SEED), + ("slack","slack","slack",SLACK_FACES,"slack-",SLACK_SEED), + ("telega","telega","telega",TELEGA_FACES,"telega-",TELEGA_SEED), + ("shr","shr (HTML: nov/eww/mail)","shr",SHR_FACES,"shr-",SHR_SEED), +] diff --git a/scripts/theme-studio/generate.py b/scripts/theme-studio/generate.py index 3d8eae68d..d774a6061 100644 --- a/scripts/theme-studio/generate.py +++ b/scripts/theme-studio/generate.py @@ -241,35 +241,10 @@ PALETTE,UIMAP,LOCKS=apply_seed_basics(_d,PALETTE,UIMAP,LOCKS) PALETTE=normalize_palette(PALETTE) SYNTAX=build_syntax(COLS,MAP,BOLD,ITALIC_MAP,DEFAULTS) apply_syntax_seed(_d if _seed else {},SYNTAX,MAP) -# Bespoke package face lists and seed defaults live in face_data.py. Each entry -# is (key, label, preview, FACES, prefix, SEED); add an app by adding one row. -_BESPOKE_APPS=[ - ("org-mode","org-mode","org",ORG_FACES,"org-",ORG_SEED), - ("magit","magit","magit",MAGIT_FACES,"magit-",MAGIT_SEED), - ("elfeed","elfeed","elfeed",ELFEED_FACES,"elfeed-",ELFEED_SEED), - ("mu4e","mu4e","mu4e",MU4E_FACES,"mu4e-",MU4E_SEED), - ("gnus","gnus (mu4e article view)","gnus",GNUS_FACES,"gnus-",GNUS_SEED), - ("org-faces","org-faces","orgfaces",ORGFACES_FACES,"org-faces-",ORGFACES_SEED), - ("ghostel","ghostel","ghostel",GHOSTEL_FACES,"ghostel-",GHOSTEL_SEED), - ("auto-dim-other-buffers","auto-dim","autodim",AUTODIM_FACES,"auto-dim-other-buffers-",AUTODIM_SEED), - ("dashboard","dashboard","dashboard",DASHBOARD_FACES,"dashboard-",DASHBOARD_SEED), - ("lsp-mode","lsp-mode","lsp",LSP_FACES,"lsp-",LSP_SEED), - ("git-gutter","git-gutter","gitgutter",GITGUTTER_FACES,"git-gutter:",GITGUTTER_SEED), - ("flycheck","flycheck","flycheck",FLYCHECK_FACES,"flycheck-",FLYCHECK_SEED), - ("dired","dired","dired",DIRED_FACES,"dired-",DIRED_SEED), - ("dirvish","dirvish","dirvish",DIRVISH_FACES,"dirvish-",DIRVISH_SEED), - ("calibredb","calibredb","calibredb",CALIBREDB_FACES,"calibredb-",CALIBREDB_SEED), - ("erc","erc","erc",ERC_FACES,"erc-",ERC_SEED), - ("org-drill","org-drill","orgdrill",ORGDRILL_FACES,"org-drill-",ORGDRILL_SEED), - ("org-noter","org-noter","orgnoter",ORGNOTER_FACES,"org-noter-",ORGNOTER_SEED), - ("signel","signel","signel",SIGNEL_FACES,"signel-",SIGNEL_SEED), - ("pearl","pearl","pearl",PEARL_FACES,"pearl-",PEARL_SEED), - ("slack","slack","slack",SLACK_FACES,"slack-",SLACK_SEED), - ("telega","telega","telega",TELEGA_FACES,"telega-",TELEGA_SEED), - ("shr","shr (HTML: nov/eww/mail)","shr",SHR_FACES,"shr-",SHR_SEED), -] +# Bespoke apps are single-sourced as BESPOKE_APP_SPECS in face_data.py (one +# row per app: key, label, preview, FACES, prefix, SEED). APPS={key:{"label":label,"preview":preview,"faces":face_rows(faces,prefix,seed)} - for key,label,preview,faces,prefix,seed in _BESPOKE_APPS} + for key,label,preview,faces,prefix,seed in BESPOKE_APP_SPECS} # Phase 6: merge the generated all-package inventory (refresh with build-inventory.el). # Bespoke apps stay; every other installed package becomes an editable generic app. _inv_path=os.path.join(HERE,"package-inventory.json") -- cgit v1.2.3