check-parens: standalone paren balance checker for lisp blocks in org files
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
This commit is contained in:
42
projects/check-parens/README.org
Normal file
42
projects/check-parens/README.org
Normal file
@@ -0,0 +1,42 @@
|
||||
#+TITLE: check-parens
|
||||
#+FILETAGS: :tool:lisp:org:
|
||||
|
||||
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
|
||||
|
||||
#+begin_src shell
|
||||
check-parens <file.org> [<file.org> ...]
|
||||
check-parens -v <file.org>
|
||||
#+end_src
|
||||
|
||||
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:
|
||||
|
||||
#+begin_src shell
|
||||
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
|
||||
#+end_src
|
||||
|
||||
== Dependencies
|
||||
|
||||
None (stdlib Python 3).
|
||||
Reference in New Issue
Block a user