Indentation Specification

Overview

An indent spec can be used to specify intricate indentation rules for the more complex macros (or functions). It is provided as a value in the var metadata, under the :style/indent key.

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

It can take one of 3 forms:

  • Absent, meaning "indent like a regular function call".

  • An integer or a keyword x, which is shorthand for the list [x].

  • A list, meaning that this function/macro takes a number of special arguments, and then all other arguments are non-special.

    • The first element describes how the arguments are indented relative to the sexp. It can be:

      • An integer n, which indicates this function/macro takes n special arguments (see below for the meaning of this).

      • The keyword :form, meaning "every arg indents like a function form".

      • The keyword :defn, which means "every arg not on the first line is non-special".