Skip to content

Macro-expand - show code generated by macrosλ︎

There are around 50 macros in clojure.core and to understand what they are doing it is useful to expand the macro into the code that it generates. Expanding a macro shows you the code generated by the macro reader. Code from the macro is displayed in a new buffer.

. e m expands a macro once, the most simple and commonly used command (cider-macroexpand-1 ).

, e M expands until there are no more macros. Less often there will be layers of macros in the expression, so this will show the code from complete resolution of all macros in the expression (cider-macroexpand-all).

In this example we expand a simple defn macro

(defn foo
  "I don't do a whole lot."
  (println x "Hello, World!"))

Spacemacs - Clojure - Evaluate - Macro-expand a defn macro