[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

32.17.2 Indentation Controlled by Major Mode

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.

Variable: indent-line-function
This variable's value is the function to be used by TAB (and various commands) to indent the current line. The command indent-according-to-mode does no more than call this function.

In Lisp mode, the value is the symbol lisp-indent-line; in C mode, c-indent-line; in Fortran mode, fortran-indent-line. In Fundamental mode, Text mode, and many other modes with no standard for indentation, the value is indent-to-left-margin (which is the default value).

Command: indent-according-to-mode
This command calls the function in indent-line-function to indent the current line in a way appropriate for the current major mode.

Command: indent-for-tab-command
This command calls the function in indent-line-function to indent the current line; however, if that function is indent-to-left-margin, insert-tab is called instead. (That is a trivial command that inserts a tab character.)

Command: newline-and-indent
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 the current indent-line-function. In programming language modes, this is the same thing TAB does, but in some text modes, where TAB inserts a tab, newline-and-indent indents to the column specified by left-margin.

Command: reindent-then-newline-and-indent
This command reindents the current line, inserts a newline at point, and then indents the new line (the one following the newline just inserted).

This command does indentation on both lines according to the current major mode, by calling the current value of indent-line-function. In programming language modes, this is the same thing TAB does, but in some text modes, where TAB inserts a tab, reindent-then-newline-and-indent indents to the column specified by left-margin.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 2, 2002 using texi2html