diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-14 18:20:04 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-14 18:20:04 -0500 |
| commit | 8bb63f00c9bcb5a6222a1ba56329a870a93bb35c (patch) | |
| tree | aff8f0e2c2a58aa2a43e9ab1bc77d432a4434d7c | |
| parent | 214c16fe127e007965b21d38d0c9c24f8c995b4c (diff) | |
| download | dotemacs-8bb63f00c9bcb5a6222a1ba56329a870a93bb35c.tar.gz dotemacs-8bb63f00c9bcb5a6222a1ba56329a870a93bb35c.zip | |
feat(theme-studio): make targets for the build-theme converter
theme-studio-theme converts a Theme Studio JSON export to themes/<name>-theme.el. theme-studio-theme-load disables the custom themes and loads one in the running Emacs. theme-studio-theme-reload chains the two. Each delegates to the scripts/theme-studio/Makefile and errors clearly when its required JSON or THEME argument is missing.
| -rw-r--r-- | Makefile | 30 | ||||
| -rw-r--r-- | scripts/theme-studio/Makefile | 35 |
2 files changed, 63 insertions, 2 deletions
@@ -29,6 +29,7 @@ EMACS ?= emacs TEST_DIR = tests MODULE_DIR = modules EMACS_HOME = $(HOME)/.emacs.d +OUT ?= themes # Test files UNIT_TESTS = $(filter-out $(TEST_DIR)/test-integration-%.el, $(wildcard $(TEST_DIR)/test-*.el)) @@ -46,7 +47,7 @@ EMACS_TEST = $(EMACS_BATCH) -L $(TEST_DIR) -L $(MODULE_DIR) # No colors - using plain text symbols instead .PHONY: help targets test test-all test-unit test-integration test-file test-name \ - test-bash theme-studio-test theme-studio-check theme-studio-coverage theme-studio-gen theme-studio-open \ + test-bash theme-studio-test theme-studio-check theme-studio-coverage theme-studio-gen theme-studio-open theme-studio-theme theme-studio-theme-load theme-studio-theme-reload \ benchmark coverage coverage-summary coverage-clean \ validate-parens validate-modules compile compile-file lint profile \ clean clean-compiled clean-tests reset @@ -75,6 +76,9 @@ help: @echo " make theme-studio-coverage - JS + generate.py coverage numbers" @echo " make theme-studio-gen - Regenerate theme-studio.html (SEED=x.json optional)" @echo " make theme-studio-open - Regenerate and open the page in Chrome" + @echo " make theme-studio-theme JSON=/path/theme.json - Convert JSON export to themes/<name>-theme.el" + @echo " make theme-studio-theme-load THEME=name - Disable all custom themes, then load THEME" + @echo " make theme-studio-theme-reload JSON=/path.json - Convert JSON, then cleanly reload its theme" @echo "" @echo " Coverage:" @echo " make coverage - Generate simplecov JSON and summarize modules" @@ -144,6 +148,30 @@ theme-studio-gen: theme-studio-open: @$(MAKE) -C scripts/theme-studio open SEED='$(SEED)' +theme-studio-theme: +ifndef JSON + @echo "Error: JSON parameter required" + @echo "Usage: make theme-studio-theme JSON=/path/to/theme.json [OUT=themes]" + @exit 1 +endif + @$(MAKE) -C scripts/theme-studio theme JSON='$(abspath $(JSON))' OUT='$(abspath $(OUT))' + +theme-studio-theme-load: +ifndef THEME + @echo "Error: THEME parameter required" + @echo "Usage: make theme-studio-theme-load THEME=theme [OUT=themes]" + @exit 1 +endif + @$(MAKE) -C scripts/theme-studio theme-load THEME='$(THEME)' OUT='$(abspath $(OUT))' + +theme-studio-theme-reload: +ifndef JSON + @echo "Error: JSON parameter required" + @echo "Usage: make theme-studio-theme-reload JSON=/path/to/theme.json [OUT=themes] [THEME=name]" + @exit 1 +endif + @$(MAKE) -C scripts/theme-studio theme-reload JSON='$(abspath $(JSON))' OUT='$(abspath $(OUT))' THEME='$(THEME)' + BANNER = ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ # Run the .el test files in $(1), each in its own Emacs, with :slow and :perf diff --git a/scripts/theme-studio/Makefile b/scripts/theme-studio/Makefile index 6cf48f66c..d98478aef 100644 --- a/scripts/theme-studio/Makefile +++ b/scripts/theme-studio/Makefile @@ -12,8 +12,11 @@ HERE := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) # Optional palette seed for `gen` / `open`: make gen SEED=dupre.json SEED ?= +OUT ?= ../../themes +EMACS ?= emacs +EMACSCLIENT ?= emacsclient -.PHONY: help test check check-generated coverage gen open +.PHONY: help test check check-generated coverage gen open theme theme-load theme-reload .DEFAULT_GOAL := help @@ -25,6 +28,9 @@ help: @echo " make coverage - JS (node) + generate.py (uvx coverage) numbers" @echo " make gen [SEED=x.json] - Regenerate theme-studio.html (optionally from a seed)" @echo " make open [SEED=x.json] - Regenerate and open the page in Chrome" + @echo " make theme JSON=x.json - Convert a Theme Studio JSON export to OUT/<name>-theme.el" + @echo " make theme-load THEME=x - Disable all custom themes, then load THEME in current Emacs" + @echo " make theme-reload JSON=x - Convert JSON, then cleanly reload its theme in current Emacs" test: @./run-tests.sh @@ -68,3 +74,30 @@ open: gen else \ echo "no Chromium-family browser found"; exit 1; \ fi + +theme: +ifndef JSON + @echo "Error: JSON parameter required" + @echo "Usage: make theme JSON=/path/to/theme.json [OUT=../../themes]" + @exit 1 +endif + @$(EMACS) --batch -l build-theme.el --eval '(princ (concat "wrote " (build-theme/convert-file "$(JSON)" "$(OUT)") "\n"))' + +theme-load: +ifndef THEME + @echo "Error: THEME parameter required" + @echo "Usage: make theme-load THEME=theme [OUT=../../themes]" + @exit 1 +endif + @$(EMACSCLIENT) -e "(progn (add-to-list 'custom-theme-load-path \"$(abspath $(OUT))\") (mapc #'disable-theme (copy-sequence custom-enabled-themes)) (load-theme '$(THEME) t) custom-enabled-themes)" + +theme-reload: +ifndef JSON + @echo "Error: JSON parameter required" + @echo "Usage: make theme-reload JSON=/path/to/theme.json [OUT=../../themes] [THEME=name]" + @exit 1 +endif + @$(MAKE) theme JSON='$(JSON)' OUT='$(OUT)' EMACS='$(EMACS)' + @theme_name='$(THEME)'; \ + if [ -z "$$theme_name" ]; then theme_name="$$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["name"])' '$(JSON)')"; fi; \ + $(MAKE) theme-load THEME="$$theme_name" OUT='$(OUT)' EMACSCLIENT='$(EMACSCLIENT)' |
