26.3.3 Customizing Lisp Indentation
The indentation pattern for a Lisp expression can depend on the function called by the expression. For each Lisp function, you can choose among several predefined patterns of indentation, or define an arbitrary one with a Lisp program.
The standard pattern of indentation is as follows: the second line of the expression is indented under the first argument, if that is on the same line as the beginning of the expression; otherwise, the second line is indented underneath the function name. Each following line is indented under the previous line whose nesting depth is the same.
If the variable lisp-indent-offset
is non-nil
, it overrides the usual indentation pattern for the second line of an expression, so that such lines are always indented lisp-indent-offset
more columns than the containing list.
Certain functions override the standard pattern. Functions whose names start with def
treat the second lines as the start of a body, by indenting the second line lisp-body-indent
additional columns beyond the open-parenthesis that starts the expression.
You can override the standard pattern in various ways for individual functions, according to the lisp-indent-function
property of the function name. This is normally done for macro definitions, using the declare
construct. See Defining Macros in The Emacs Lisp Reference Manual.