25.4 Convenience Features for Indentation

The variable tab-always-indent tweaks the behavior of the TAB (indent-for-tab-command) command. The default value, t, gives the behavior described in Indentation. If you change the value to the symbol complete, then TAB first tries to indent the current line, and if the line was already indented, it tries to complete the text at point (see Completion for Symbol Names). If the value is nil, then TAB 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 tab-always-indent is complete, whether to expand or indent can be further customized via the tab-first-completion variable. For instance, if that variable is eol, only complete if point is at the end of a line. See Mode-Specific Indent in The Emacs Lisp Reference Manual, for further details.

Electric Indent mode is a global minor mode that automatically indents the line after every RET you type. This mode is enabled by default. To toggle this minor mode, type M-x electric-indent-mode. To toggle the mode in a single buffer, use M-x electric-indent-local-mode.