diff options
Diffstat (limited to 'scripts/theme-studio/capture-default-faces.py')
| -rw-r--r-- | scripts/theme-studio/capture-default-faces.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/scripts/theme-studio/capture-default-faces.py b/scripts/theme-studio/capture-default-faces.py index acfd4984d..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]: @@ -371,7 +363,11 @@ def main() -> None: A defface form is self-contained, so registering a face this way avoids loading the whole package (and its dependencies / side effects), which in batch -Q is fragile: a missing dependency or mid-load error would silently -drop every face in the file. Each form is evaluated independently." +drop every face in the file. Each form is evaluated independently. + +Catch any error from `read', not just `end-of-file': a reader-level error +(unrecognized syntax) otherwise propagates out and aborts the whole pass, +dropping every face in every later file. Stop reading this file instead." (when (file-readable-p file) (with-temp-buffer (insert-file-contents file) @@ -381,7 +377,7 @@ drop every face in the file. Each form is evaluated independently." (let ((form (read (current-buffer)))) (when (and (consp form) (eq (car form) 'defface)) (ignore-errors (eval form t))))) - (end-of-file nil))))) + (error nil))))) ;; Pass 1: best-effort full load. Registers faces that are defined by a macro ;; or loop rather than a literal defface (e.g. rainbow-delimiters depth faces, ;; markdown header faces), which pass 2 cannot see. Failures are swallowed. |
