I'm trying to write a macro that takes a vector of bindings and a function that can access these bindings. In the simplest form:
(defmacro f-with-binds [binds f]
`(let [~@binds]
~f))
even though the above works:
(f-with-binds [n 123 m 456] (println n m)) ;; => 123 456
I am not happy with this because Cursive highlights n
and m
as undeclared variables which does not happen for macros like for
and let
. How can I improve my implementation?
ps.: the real macro returns a transducer - bindings are the transducer's state and function is the transducer's step function
taken from @superkonduktr comment:
This is a known issue in Cursive that is currently being worked on. For now the only remedy seems to be in the beta version 1.3.0-eap1, where you can instruct Cursive to resolve bindings in your macro as if it was a let. Another solution would be to disable highlighting of unresolved symbols entirely (Settings → Languages & Frameworks → Clojure → Highlight Unresolved Symbols).