Scans #+begin_src lisp ... #+end_src blocks, strips strings and comments, reports unbalanced parens per-block with line numbers. Detects unterminated blocks (no matching #+end_src). Zero dependencies (stdlib Python). Called from AGENTS.md step: projects/check-parens/check-parens org/file.org
1.0 KiB
1.0 KiB
check-parens
Standalone parentheseis checker for Lisp source blocks in Org files.
Scans all #+begin_src lisp … #+end_src blocks in an Org file, strips
string and comment content, and reports unbalanced parentheses per block.
== Usage
check-parens <file.org> [<file.org> ...]
check-parens -v <file.org>
Exit 0 if all blocks are balanced and terminated, 1 otherwise.
== Output
file.org: OK — all blocks balanced
file.org: Block at line 27: +2 (missing 2 closes) — near …
file.org: Block at line 103: unterminated — no matching #+end_src
The -v flag prints the full block content for each issue.
== Integration
Pre-commit hook:
cat > .git/hooks/pre-commit <<'HOOK'
#!/bin/sh
for f in $(git diff --cached --name-only --diff-filter=ACM | grep '\.org$'); do
projects/check-parens/check-parens "$f" || exit 1
done
HOOK
chmod +x .git/hooks/pre-commit
== Dependencies
None (stdlib Python 3).