aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/build-inventory.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-08 08:56:47 -0500
committerCraig Jennings <c@cjennings.net>2026-06-08 08:57:05 -0500
commitf2654a0083a94d0e0dc7cbb6094aae6116a1c318 (patch)
tree1aab6dac6b8c8b6cd4ccdb3ca06cd66055f55cbd /scripts/theme-studio/build-inventory.el
parent01e4214819fa9011f684097d54f5d8953973f8fc (diff)
downloaddotemacs-f2654a0083a94d0e0dc7cbb6094aae6116a1c318.tar.gz
dotemacs-f2654a0083a94d0e0dc7cbb6094aae6116a1c318.zip
refactor(theme-studio): rename theme-selector to theme-studio
The tool authors themes from scratch -- palette, faces across every tier, live preview, export to a loadable deftheme. It never selects among existing themes, so "selector" mis-described it. Renamed the directory, the generated HTML and its title, the design spec, and every reference in the code, README, tests, and todo. No behavior change.
Diffstat (limited to 'scripts/theme-studio/build-inventory.el')
-rw-r--r--scripts/theme-studio/build-inventory.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/theme-studio/build-inventory.el b/scripts/theme-studio/build-inventory.el
new file mode 100644
index 000000000..04d821453
--- /dev/null
+++ b/scripts/theme-studio/build-inventory.el
@@ -0,0 +1,31 @@
+;;; build-inventory.el --- emit package->faces inventory for theme-studio -*- lexical-binding: t -*-
+;;; Commentary:
+;; Loaded into a running Emacs (emacsclient -e '(load ".../build-inventory.el")')
+;; to write package-inventory.json next to itself: a JSON object mapping each
+;; installed (elpa/straight) package to the faces it defines, grouped by the
+;; package that owns the face's definition file. Built-in faces are skipped.
+;; generate.py embeds the JSON so the theme-studio dropdown can reach every
+;; installed package (tier-3 phase 6, the "theme every package" path).
+;;; Code:
+
+(require 'json)
+
+(let ((h (make-hash-table :test 'equal)))
+ (dolist (f (face-list))
+ (let* ((file (ignore-errors (symbol-file f 'defface)))
+ (pkg (and (stringp file)
+ (string-match "/\\(?:elpa\\|straight/build\\|site-lisp\\)/\\([a-zA-Z0-9._-]+?\\)-[0-9][^/]*/" file)
+ (match-string 1 file))))
+ (when pkg (push (symbol-name f) (gethash pkg h)))))
+ (let (al)
+ (maphash (lambda (k v) (push (cons (intern k) (sort v #'string<)) al)) h)
+ (setq al (sort al (lambda (a b) (string< (symbol-name (car a)) (symbol-name (car b))))))
+ (with-temp-file (expand-file-name
+ "package-inventory.json"
+ (file-name-directory (or load-file-name buffer-file-name
+ "~/.emacs.d/scripts/theme-studio/")))
+ (let ((json-encoding-pretty-print t))
+ (insert (json-encode al) "\n")))))
+
+(provide 'build-inventory)
+;;; build-inventory.el ends here