An important function of each major mode is to customize the TAB key to indent properly for the language being edited. This section describes the mechanism of the TAB key and how to control it. The functions in this section return unpredictable values.
This is the command bound to TAB in most editing modes. Its usual action is to indent the current line, but it can alternatively insert a tab character or indent a region.
Here is what it does:
indent-regionto indent all the text in the region (see Region Indent).
indent-to-left-margin(a trivial command that inserts a tab character), or if the variable tab-always-indent specifies that a tab character ought to be inserted (see below), then it inserts a tab character.
complete(see below), it tries completing the text at point.
If rigid is non-
nil (interactively, with a prefix
argument), then after this command indents a line or inserts a tab, it
also rigidly indents the entire balanced expression which starts at
the beginning of the current line, in order to reflect the new
indentation. This argument is ignored if the command indents the
This variable’s value is the function to be used by
indent-for-tab-command, and various other indentation commands,
to indent the current line. It is usually assigned by the major mode;
for instance, Lisp mode sets it to
lisp-indent-line, C mode
sets it to
c-indent-line, and so on. The default value is
indent-relative. See Auto-Indentation.
This command calls the function in indent-line-function to indent the current line in a way appropriate for the current major mode.
This function inserts a newline, then indents the new line (the one
following the newline just inserted) according to the major mode. It
does indentation by calling
This command reindents the current line, inserts a newline at point,
and then indents the new line (the one following the newline just
inserted). It does indentation on both lines by calling
This variable can be used to customize the behavior of the TAB
indent-for-tab-command) command. If the value is t
(the default), the command normally just indents the current line. If
the value is
nil, the command indents the current line only if
point is at the left margin or in the line’s indentation; otherwise,
it inserts a tab character. If the value is
command first tries to indent the current line, and if the line was
already indented, it calls
completion-at-point to complete the
text at point (see Completion in Buffers).