Macroexpansion

Typing C-c C-m after some form in a source buffer or the REPL will show you the macro expansion of the form in a new buffer. You’ll have access to additional keybindings in the macro expansion buffer (which is internally using cider-macroexpansion-mode):

Keyboard shortcut Description

m

Invoke macroexpand-1 on the form at point and replace the original form with its expansion. If invoked with a prefix argument, macroexpand is used instead of macroexpand-1.

a

Invoke clojure.walk/macroexpand-all on the form at point and replace the original form with its expansion.

g

The prior macro expansion is performed again and the current contents of the macro expansion buffer are replaced with the new expansion.

C-/
u

Undo the last in-place expansion performed in the macroexpansion buffer.

Configuration

The option cider-macroexpansion-display-namespaces controls whether to display namespaces in the macroexpansion buffer. It can be set to one of the following:

  • qualified - Vars are fully-qualified in the expansion.

  • none- Vars are displayed without namespace qualification.

  • tidy(default) - Vars that are :refer-ed or defined in the current namespace are displayed with their simple name, non-referred vars from other namespaces are referred using the alias for that namespace (if defined), other vars are displayed fully qualified.

The option cider-macroexpansion-print-metadata controls whether to print the var metadata in the macroexpansion buffer. It’s set to nil by default.