retrieve the documentation strings of the major and minor mode
commands (@pxref{Accessing Documentation}).
-If called from Lisp with a non-nil @var{buffer} argument, this
+If called from Lisp with a non-@code{nil} @var{buffer} argument, this
function displays the documentation for that buffer's major and minor
modes, rather than those of the current buffer.
@end deffn
It is normally @code{nil}, so that ordinary buffers have no header line.
@end defvar
-The function @code{window-header-line-height} returns the height of
-the header line:
-
@defun window-header-line-height &optional window
-Return the height of @var{window}'s header line, in pixels.
-@var{window} must be a live window. If @var{window} is @code{nil} or
-omitted, it will be the selected window.
+This function returns the height in pixels of @var{window}'s header
+line. @var{window} must be a live window, and defaults to the
+selected window.
@end defun
A window that is just one line tall never displays a header line. A
@section Automatic Indentation of code
For programming languages, an important feature of a major mode is to
-provide automatic indentation. This is controlled in Emacs by
-@code{indent-line-function} (@pxref{Mode-Specific Indent}).
-Writing a good indentation function can be difficult and to a large
-extent it is still a black art.
-
-Many major mode authors will start by writing a simple indentation
-function that works for simple cases, for example by comparing with the
-indentation of the previous text line. For most programming languages
-that are not really line-based, this tends to scale very poorly:
-improving such a function to let it handle more diverse situations tends
-to become more and more difficult, resulting in the end with a large,
-complex, unmaintainable indentation function which nobody dares to touch.
+provide automatic indentation. There are two parts: one is to decide what
+is the right indentation of a line, and the other is to decide when to
+reindent a line. By default, Emacs reindents a line whenever you
+type a character in @code{electric-indent-chars}, which by default only
+includes Newline. Major modes can add chars to @code{electric-indent-chars}
+according to the syntax of the language.
+
+Deciding what is the right indentation is controlled in Emacs by
+@code{indent-line-function} (@pxref{Mode-Specific Indent}). For some modes,
+the @emph{right} indentation cannot be known reliably, typically because
+indentation is significant so several indentations are valid but with different
+meanings. In that case, the mode should set @code{electric-indent-inhibit} to
+make sure the line is not constantly re-indented against the user's wishes.
+
+Writing a good indentation function can be difficult and to a large extent it
+is still a black art. Many major mode authors will start by writing a simple
+indentation function that works for simple cases, for example by comparing with
+the indentation of the previous text line. For most programming languages that
+are not really line-based, this tends to scale very poorly: improving
+such a function to let it handle more diverse situations tends to become more
+and more difficult, resulting in the end with a large, complex, unmaintainable
+indentation function which nobody dares to touch.
A good indentation function will usually need to actually parse the
text, according to the syntax of the language. Luckily, it is not
purpose of indentation it has the advantage of not needing to
guess a ``safe'' starting point, and it generally enjoys the property
that only a minimum of text will be analyzed to decide the indentation
-of a line, so indentation will tend to be unaffected by syntax errors in
+of a line, so indentation will tend to be less affected by syntax errors in
some earlier unrelated piece of code. Parsing forward on the other hand
is usually easier and has the advantage of making it possible to
reindent efficiently a whole region at a time, with a single parse.
@end itemize
When @var{arg} is a token, the function is called with point just before
-that token. A return value of nil always means to fallback on the
-default behavior, so the function should return nil for arguments it
+that token. A return value of @code{nil} always means to fallback on the
+default behavior, so the function should return @code{nil} for arguments it
does not expect.
@var{offset} can be:
@itemize
@item
The first case indicates the basic indentation increment to use.
-If @code{sample-indent-basic} is nil, then SMIE uses the global
+If @code{sample-indent-basic} is @code{nil}, then SMIE uses the global
setting @code{smie-indent-basic}. The major mode could have set
@code{smie-indent-basic} buffer-locally instead, but that
is discouraged.