logoalt Hacker News

chriswarbo • today at 5:24 PM • 1 reply • view on HN

A tool I've found really valuable when writing Lisp is https://github.com/shcv/parenmedic

It compares the indentation to the parentheses, and complains if they don't agree. It doesn't care about indentation amount (like I-expressions/Wisp/etc.), only that lines following some opened parens get indented more; lines following some closed parens get indented less; and sibling lines are indented the same amount.

I find this much more accurate at spotting the cause of a problem, compared to simply counting whether the openers and closers balance; e.g. the latter will only spot a missing close parenthesis when it reaches the end of the file. This is especially useful for LLMs, which are terrible at counting parentheses.

Unfortunately, there can be some cases where an auto-indenter (e.g. elisp-autofmt) causes parenmedic to complain. One remedy is to alter the auto-indenter's behaviour by inserting a line-comment; but it's not ideal.

I wonder whether Sift would (knowingly or unknowingly) adhere to the rules parenmedic requires?


Replies

jhayward • today at 6:33 PM

It's fairly common in agentic work with lisps to use the OG of indentation-implies-parens, parinfer. https://github.com/parinfer

It's a little disappointing to not see a credit for it in parenmedic. The agentic interface looks interesting though.

➕ show 1 reply