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 always indent the second line by
lisp-body-indention extra columns beyond the open-parenthesis
starting the expression.
Individual functions can override the standard pattern in various
ways, according to the
lisp-indent-function property of the
function name. (Note:
lisp-indent-function was formerly called
lisp-indent-hook). There are four possibilities for this
This is the same as no property; the standard indentation pattern is used.
The pattern used for function names that start with
def is used for
this function also.
The first number arguments of the function are
distinguished arguments; the rest are considered the body
of the expression. A line in the expression is indented according to
whether the first argument on it is distinguished or not. If the
argument is part of the body, the line is indented
more columns than the open-parenthesis starting the containing
expression. If the argument is distinguished and is either the first
or second argument, it is indented twice that many extra columns.
If the argument is distinguished and not the first or second argument,
the standard pattern is followed for that line.
symbol should be a function name; that function is called to calculate the indentation of a line within this expression. The function receives two arguments:
The value returned by
parse-partial-sexp (a Lisp primitive for
indentation and nesting computation) when it parses up to the
beginning of this line.
The position at which the line being indented begins.
It should return either a number, which is the number of columns of indentation for that line, or a list whose first element is such a number. The difference between returning a number and returning a list is that a number says that all following lines at the same nesting level should be indented just like this one; a list says that following lines might call for different indentations. This makes a difference when the indentation is computed by C-M-q; if the value is a number, C-M-q need not recalculate indentation for the following lines until the end of the list.