Indentation

Dynamic Indentation

It is common for macros to require special indentation mechanisms. This is most common in macros that start with do, def, or with-. CIDER has some heuristics to detect these macros, but it also lets you explicitly specify how a macro should be indented.

Here's a simple example of how someone would specify the indent spec for a macro they've written (using an example in core):

(defmacro with-in-str
  "[DOCSTRING]"
  {:style/indent 1}
  [s & body]
  ...cut for brevity...)

And here's a more complex one:

(defmacro letfn
  "[DOCSTRING]"
  {:style/indent [1 [[:defn]] :form]}
  [fnspecs & body]
  ...cut for brevity...)

Don't worry if this looks intimidating. For most macros the indent spec should be either just a number, or one of the keywords :defn or :form. A full description of the spec is provided in the indent spec section of the manual.

If you don't want to use this feature, you can disable it by setting cider-dynamic-indentation to nil in your Emacs init file.

(setq cider-dynamic-indentation nil)