Hey! I wrote a macro that does templating like the syntax quote (with ~
and ~@
). The idea is very similar to https://github.com/brandonbloom/backtick
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
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
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 ...)
What's encapsulated in those will always be valid Clojure, whereas everything outside is actually Convex Lisp in my case
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) ...))
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).
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