Fork me on GitHub
Adam Helins05:05:10

Hey! I wrote a macro that does templating like the syntax quote (with ~ and ~@). The idea is very similar to Kondo struggles with it since it lints the given form like any Clojure code. That would be easily solved if there was a "lint as syntax quote" option. Maybe is there already something resembling that?


@adam678 Probably writing a hook for this is your best bet, or suppress warnings inside this macro


I have one similar macro like this called $ which is part of babashka.process. clj-kondo has built-in support for that


so perhaps you could look at its code

Adam Helins13:05:05

Okay, thanks! Writing those hooks is always a fun puzzle (well, maybe not always)


@adam678 In your case, just expanding the body from (your-macro ...) to

`(do ...)
should be sufficient?


We could have some :lint-as support for this, but it seems pretty rare

Adam Helins13:05:06

I'm going to do some experiments now, I believe I should rather traverse the given form and extracts everything enclosed in (clojure.core/unquote ...) and (clojure.core/unquote-splicing ...)

Adam Helins13:05:57

What's encapsulated in those will always be valid Clojure, whereas everything outside is actually Convex Lisp in my case

Adam Helins14:05:49

Is there a way for interacting with QuoteNode ? Any node manipulation must happen via the hook api, right?


hmm, good point, there is probably no way to generate a syntax-quote, but a normal quoted one can be generated using (list-node (list* (token-node 'quote) ...))

Adam Helins14:05:53

I think I can manage, with a little indirection. It's more about recognizing literal unquoting (combination between returning false on list-node? and guessing unquote and unquote-splicing from the sexpr).

Adam Helins14:05:08

Is there an obvious reason why you removed support for map nodes?


yeah, the rewrite-clj around map-nodes and namespaced-map-nodes wasn't stable yet

👍 3