]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/modes.texi
* lisp/textmodes/paragraphs.el (mark-paragraph): Doc fix.
[gnu-emacs] / doc / lispref / modes.texi
index 3c5fbfb22c9edcc3cb77cb9da07acb4b2849f5d6..7093f7fe336a2a7218008ce860588e69eaa39b49 100644 (file)
@@ -1,9 +1,9 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998-1999, 2001-2012  Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2013 Free Software
+@c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
-@setfilename ../../info/modes
-@node Modes, Documentation, Keymaps, Top
+@node Modes
 @chapter Major and Minor Modes
 @cindex mode
 
@@ -38,7 +38,7 @@ user.  For related topics such as keymaps and syntax tables, see
 to be called on a particular occasion by an existing program.  Emacs
 provides hooks for the sake of customization.  Most often, hooks are set
 up in the init file (@pxref{Init File}), but Lisp programs can set them also.
-@xref{Standard Hooks}, for a list of standard hook variables.
+@xref{Standard Hooks}, for a list of some standard hook variables.
 
 @cindex normal hook
   Most of the hooks in Emacs are @dfn{normal hooks}.  These variables
@@ -71,9 +71,9 @@ called.  You can use @code{add-hook} to add a function to an abnormal
 hook, but you must write the function to follow the hook's calling
 convention.
 
-  By convention, abnormal hook names end in @samp{-functions} or
-@samp{-hooks}.  If the variable's name ends in @samp{-function}, then
-its value is just a single function, not a list of functions.
+  By convention, abnormal hook names end in @samp{-functions}.  If the
+variable's name ends in @samp{-function}, then its value is just a single
+function, not a list of functions.
 
 @menu
 * Running Hooks::    How to run a hook.
@@ -284,9 +284,10 @@ buffer is put in Fundamental mode (@pxref{Major Mode Conventions}).
 * Derived Modes::           Defining a new major mode based on another major
                               mode.
 * Basic Major Modes::       Modes that other modes are often derived from.
+* Mode Hooks::              Hooks run at the end of major mode functions.
+* Tabulated List Mode::     Parent mode for buffers containing tabulated data.
 * Generic Modes::           Defining a simple major mode that supports
                               comment syntax and Font Lock mode.
-* Mode Hooks::              Hooks run at the end of major mode commands.
 * Example Major Modes::     Text mode and Lisp modes.
 @end menu
 
@@ -384,7 +385,7 @@ reserved for users.
 
 A major mode can also rebind the keys @kbd{M-n}, @kbd{M-p} and
 @kbd{M-s}.  The bindings for @kbd{M-n} and @kbd{M-p} should normally
-be some kind of ``moving forward and backward,'' but this does not
+be some kind of ``moving forward and backward'', but this does not
 necessarily mean cursor motion.
 
 It is legitimate for a major mode to rebind a standard key sequence if
@@ -524,6 +525,10 @@ mode when creating new buffers (@pxref{Auto Major Mode}), but with such
 @code{special} modes, Fundamental mode is used instead.  Modes such as
 Dired, Rmail, and Buffer List use this feature.
 
+The function @code{view-buffer} does not enable View mode in buffers
+whose mode-class is special, because such modes usually provide their
+own View-like bindings.
+
 The @code{define-derived-mode} macro automatically marks the derived
 mode as special if the parent mode is special.  Special mode is a
 convenient parent for such modes to inherit from; @xref{Basic Major
@@ -608,7 +613,7 @@ variables section specifying a mode for that particular file.  This
 should not be applied to the containing tar file.  Similarly, a tiff
 image file might just happen to contain a first line that seems to
 match the @w{@samp{-*-}} pattern.  For these reasons, both these file
-extensions are members of the list @var{inhibit-local-variables-regexps}.
+extensions are members of the list @code{inhibit-local-variables-regexps}.
 Add patterns to this list to prevent Emacs searching them for local
 variables of any kind (not just mode specifiers).
 
@@ -623,7 +628,7 @@ have set.
 This function sets the major mode of @var{buffer} to the default value of
 @code{major-mode}; if that is @code{nil}, it uses the
 current buffer's major mode (if that is suitable).  As an exception,
-if @var{buffer}'s name is @samp{*scratch*}, it sets the mode to
+if @var{buffer}'s name is @file{*scratch*}, it sets the mode to
 @code{initial-major-mode}.
 
 The low-level primitives for creating buffers do not use this function,
@@ -632,9 +637,9 @@ but medium-level commands such as @code{switch-to-buffer} and
 @end defun
 
 @defopt initial-major-mode
-@cindex @samp{*scratch*}
+@cindex @file{*scratch*}
 The value of this variable determines the major mode of the initial
-@samp{*scratch*} buffer.  The value should be a symbol that is a major
+@file{*scratch*} buffer.  The value should be a symbol that is a major
 mode command.  The default value is @code{lisp-interaction-mode}.
 @end defopt
 
@@ -730,13 +735,15 @@ modes.  It is normally bound to @kbd{C-h m}.  It uses the value of the
 variable @code{major-mode} (@pxref{Major Modes}), which is why every
 major mode command needs to set that variable.
 
-@deffn Command describe-mode
-This function displays the documentation of the current major mode.
+@deffn Command describe-mode &optional buffer
+This command displays the documentation of the current buffer's major
+mode and minor modes.  It uses the @code{documentation} function to
+retrieve the documentation strings of the major and minor mode
+commands (@pxref{Accessing Documentation}).
 
-The @code{describe-mode} function calls the @code{documentation}
-function using the value of @code{major-mode} as an argument.  Thus, it
-displays the documentation string of the major mode command.
-(@xref{Accessing Documentation}.)
+If called from Lisp with a non-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
 
 @node Derived Modes
@@ -799,10 +806,10 @@ You can also specify @code{nil} for @var{parent}.  This gives the new
 mode no parent.  Then @code{define-derived-mode} behaves as described
 above, but, of course, omits all actions connected with @var{parent}.
 
-The argument @var{docstring} specifies the documentation string for
-the new mode.  @code{define-derived-mode} adds some general
-information about the mode's hook, followed by the mode's keymap, at
-the end of this docstring.  If you omit @var{docstring},
+The argument @var{docstring} specifies the documentation string for the
+new mode.  @code{define-derived-mode} adds some general information
+about the mode's hook, followed by the mode's keymap, at the end of this
+documentation string.  If you omit @var{docstring},
 @code{define-derived-mode} generates a documentation string.
 
 The @var{keyword-args} are pairs of keywords and values.  The values
@@ -859,7 +866,7 @@ derived from any of the major modes given by the symbols @var{modes}.
 
   Apart from Fundamental mode, there are three major modes that other
 major modes commonly derive from: Text mode, Prog mode, and Special
-mode.  While Text mode is useful in its own right (e.g. for editing
+mode.  While Text mode is useful in its own right (e.g., for editing
 files ending in @file{.txt}), Prog mode and Special mode exist mainly to
 let other modes derive from them.
 
@@ -867,8 +874,8 @@ let other modes derive from them.
   As far as possible, new major modes should be derived, either directly
 or indirectly, from one of these three modes.  One reason is that this
 allows users to customize a single mode hook
-(e.g. @code{prog-mode-hook}) for an entire family of relevant modes
-(e.g. all programming language modes).
+(e.g., @code{prog-mode-hook}) for an entire family of relevant modes
+(e.g., all programming language modes).
 
 @deffn Command text-mode
 Text mode is a major mode for editing human languages.  It defines the
@@ -893,74 +900,22 @@ Prog mode binds @code{parse-sexp-ignore-comments} to @code{t}
 
 @deffn Command special-mode
 Special mode is a basic major mode for buffers containing text that is
-produced specially by Emacs, rather than from a file.  Major modes
-derived from Special mode are given a @code{mode-class} property of
-@code{special} (@pxref{Major Mode Conventions}).
+produced specially by Emacs, rather than directly from a file.  Major
+modes derived from Special mode are given a @code{mode-class} property
+of @code{special} (@pxref{Major Mode Conventions}).
 
 Special mode sets the buffer to read-only.  Its keymap defines several
-common bindings, including @kbd{q} for @code{quit-window}, @kbd{z} for
-@code{kill-this-buffer}, and @kbd{g} for @code{revert-buffer}
-(@pxref{Reverting}).
+common bindings, including @kbd{q} for @code{quit-window} and @kbd{g}
+for @code{revert-buffer} (@pxref{Reverting}).
 
 An example of a major mode derived from Special mode is Buffer Menu
-mode, which is used by the @samp{*Buffer List*} buffer.  @xref{List
+mode, which is used by the @file{*Buffer List*} buffer.  @xref{List
 Buffers,,Listing Existing Buffers, emacs, The GNU Emacs Manual}.
 @end deffn
 
-@cindex tables of data
-@deffn Command tabulated-list-mode
-Tabulated List mode is another mode that derives from Special mode.  It
-displays tabulated data, i.e. a series of rows and columns, where each
-row represents a particular entry, whose properties are displayed in the
-various columns.  It provides a general mechanism for sorting on
-columns.  You can use Tabulated List mode as the basis for other modes
-that need to display lists.  For example, the @samp{*Packages*} buffer
-uses this (@pxref{Packages,,, emacs, The GNU Emacs Manual}). The
-documentation of the @code{tabulated-list-mode} function explains what
-you need to do to use it.  At a minimum, specify the column format via
-the @code{tabulated-list-format} variable.
-@end deffn
-
-@node Generic Modes
-@subsection Generic Modes
-@cindex generic mode
-
-  @dfn{Generic modes} are simple major modes with basic support for
-comment syntax and Font Lock mode.  To define a generic mode, use the
-macro @code{define-generic-mode}.  See the file @file{generic-x.el}
-for some examples of the use of @code{define-generic-mode}.
-
-@defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring
-This macro defines a generic mode command named @var{mode} (a symbol,
-not quoted).  The optional argument @var{docstring} is the
-documentation for the mode command.  If you do not supply it,
-@code{define-generic-mode} generates one by default.
-
-The argument @var{comment-list} is a list in which each element is
-either a character, a string of one or two characters, or a cons cell.
-A character or a string is set up in the mode's syntax table as a
-``comment starter.''  If the entry is a cons cell, the @sc{car} is set
-up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.''
-(Use @code{nil} for the latter if you want comments to end at the end
-of the line.)  Note that the syntax table mechanism has limitations
-about what comment starters and enders are actually possible.
-@xref{Syntax Tables}.
-
-The argument @var{keyword-list} is a list of keywords to highlight
-with @code{font-lock-keyword-face}.  Each keyword should be a string.
-Meanwhile, @var{font-lock-list} is a list of additional expressions to
-highlight.  Each element of this list should have the same form as an
-element of @code{font-lock-keywords}.  @xref{Search-based
-Fontification}.
-
-The argument @var{auto-mode-list} is a list of regular expressions to
-add to the variable @code{auto-mode-alist}.  They are added by the execution
-of the @code{define-generic-mode} form, not by expanding the macro call.
-
-Finally, @var{function-list} is a list of functions for the mode
-command to call for additional setup.  It calls these functions just
-before it runs the mode hook variable @code{@var{mode}-hook}.
-@end defmac
+  In addition, modes for buffers of tabulated data can inherit from
+Tabulated List mode, which is in turn derived from Special mode.
+@xref{Tabulated List Mode}.
 
 @node Mode Hooks
 @subsection Mode Hooks
@@ -985,7 +940,7 @@ such a major mode, please correct it to follow these conventions.
 
   When you defined a major mode using @code{define-derived-mode}, it
 automatically makes sure these conventions are followed.  If you
-define a major mode ``by hand,'' not using @code{define-derived-mode},
+define a major mode ``by hand'', not using @code{define-derived-mode},
 use the following functions to handle these conventions automatically.
 
 @defun run-mode-hooks &rest hookvars
@@ -1021,6 +976,177 @@ This is a normal hook run by @code{run-mode-hooks}.  It is run at the
 very end of every properly-written major mode command.
 @end defvar
 
+@node Tabulated List Mode
+@subsection Tabulated List mode
+@cindex Tabulated List mode
+
+  Tabulated List mode is a major mode for displaying tabulated data,
+i.e., data consisting of @dfn{entries}, each entry occupying one row of
+text with its contents divided into columns.  Tabulated List mode
+provides facilities for pretty-printing rows and columns, and sorting
+the rows according to the values in each column.  It is derived from
+Special mode (@pxref{Basic Major Modes}).
+
+  Tabulated List mode is intended to be used as a parent mode by a more
+specialized major mode.  Examples include Process Menu mode
+(@pxref{Process Information}) and Package Menu mode (@pxref{Package
+Menu,,, emacs, The GNU Emacs Manual}).
+
+@findex tabulated-list-mode
+  Such a derived mode should use @code{define-derived-mode} in the usual
+way, specifying @code{tabulated-list-mode} as the second argument
+(@pxref{Derived Modes}).  The body of the @code{define-derived-mode}
+form should specify the format of the tabulated data, by assigning
+values to the variables documented below; then, it should call the
+function @code{tabulated-list-init-header} to initialize the header
+line.
+
+  The derived mode should also define a @dfn{listing command}.  This,
+not the mode command, is what the user calls (e.g., @kbd{M-x
+list-processes}).  The listing command should create or switch to a
+buffer, turn on the derived mode, specify the tabulated data, and
+finally call @code{tabulated-list-print} to populate the buffer.
+
+@defvar tabulated-list-format
+This buffer-local variable specifies the format of the Tabulated List
+data.  Its value should be a vector.  Each element of the vector
+represents a data column, and should be a list @code{(@var{name}
+@var{width} @var{sort})}, where
+
+@itemize
+@item
+@var{name} is the column's name (a string).
+
+@item
+@var{width} is the width to reserve for the column (an integer).  This
+is meaningless for the last column, which runs to the end of each line.
+
+@item
+@var{sort} specifies how to sort entries by the column.  If @code{nil},
+the column cannot be used for sorting.  If @code{t}, the column is
+sorted by comparing string values.  Otherwise, this should be a
+predicate function for @code{sort} (@pxref{Rearrangement}), which
+accepts two arguments with the same form as the elements of
+@code{tabulated-list-entries} (see below).
+@end itemize
+@end defvar
+
+@defvar tabulated-list-entries
+This buffer-local variable specifies the entries displayed in the
+Tabulated List buffer.  Its value should be either a list, or a
+function.
+
+If the value is a list, each list element corresponds to one entry, and
+should have the form @w{@code{(@var{id} @var{contents})}}, where
+
+@itemize
+@item
+@var{id} is either @code{nil}, or a Lisp object that identifies the
+entry.  If the latter, the cursor stays on the ``same'' entry when
+re-sorting entries.  Comparison is done with @code{equal}.
+
+@item
+@var{contents} is a vector with the same number of elements as
+@code{tabulated-list-format}.  Each vector element is either a string,
+which is inserted into the buffer as-is, or a list @code{(@var{label}
+. @var{properties})}, which means to insert a text button by calling
+@code{insert-text-button} with @var{label} and @var{properties} as
+arguments (@pxref{Making Buttons}).
+
+There should be no newlines in any of these strings.
+@end itemize
+
+Otherwise, the value should be a function which returns a list of the
+above form when called with no arguments.
+@end defvar
+
+@defvar tabulated-list-revert-hook
+This normal hook is run prior to reverting a Tabulated List buffer.  A
+derived mode can add a function to this hook to recompute
+@code{tabulated-list-entries}.
+@end defvar
+
+@defvar tabulated-list-printer
+The value of this variable is the function called to insert an entry at
+point, including its terminating newline.  The function should accept
+two arguments, @var{id} and @var{contents}, having the same meanings as
+in @code{tabulated-list-entries}.  The default value is a function which
+inserts an entry in a straightforward way; a mode which uses Tabulated
+List mode in a more complex way can specify another function.
+@end defvar
+
+@defvar tabulated-list-sort-key
+The value of this variable specifies the current sort key for the
+Tabulated List buffer.  If it is @code{nil}, no sorting is done.
+Otherwise, it should have the form @code{(@var{name} . @var{flip})},
+where @var{name} is a string matching one of the column names in
+@code{tabulated-list-format}, and @var{flip}, if non-@code{nil}, means
+to invert the sort order.
+@end defvar
+
+@defun tabulated-list-init-header
+This function computes and sets @code{header-line-format} for the
+Tabulated List buffer (@pxref{Header Lines}), and assigns a keymap to
+the header line to allow sort entries by clicking on column headers.
+
+Modes derived from Tabulated List mode should call this after setting
+the above variables (in particular, only after setting
+@code{tabulated-list-format}).
+@end defun
+
+@defun tabulated-list-print &optional remember-pos
+This function populates the current buffer with entries.  It should be
+called by the listing command.  It erases the buffer, sorts the entries
+specified by @code{tabulated-list-entries} according to
+@code{tabulated-list-sort-key}, then calls the function specified by
+@code{tabulated-list-printer} to insert each entry.
+
+If the optional argument @var{remember-pos} is non-@code{nil}, this
+function looks for the @var{id} element on the current line, if any, and
+tries to move to that entry after all the entries are (re)inserted.
+@end defun
+
+@node Generic Modes
+@subsection Generic Modes
+@cindex generic mode
+
+  @dfn{Generic modes} are simple major modes with basic support for
+comment syntax and Font Lock mode.  To define a generic mode, use the
+macro @code{define-generic-mode}.  See the file @file{generic-x.el}
+for some examples of the use of @code{define-generic-mode}.
+
+@defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring
+This macro defines a generic mode command named @var{mode} (a symbol,
+not quoted).  The optional argument @var{docstring} is the
+documentation for the mode command.  If you do not supply it,
+@code{define-generic-mode} generates one by default.
+
+The argument @var{comment-list} is a list in which each element is
+either a character, a string of one or two characters, or a cons cell.
+A character or a string is set up in the mode's syntax table as a
+``comment starter''.  If the entry is a cons cell, the @sc{car} is set
+up as a ``comment starter'' and the @sc{cdr} as a ``comment ender''.
+(Use @code{nil} for the latter if you want comments to end at the end
+of the line.)  Note that the syntax table mechanism has limitations
+about what comment starters and enders are actually possible.
+@xref{Syntax Tables}.
+
+The argument @var{keyword-list} is a list of keywords to highlight
+with @code{font-lock-keyword-face}.  Each keyword should be a string.
+Meanwhile, @var{font-lock-list} is a list of additional expressions to
+highlight.  Each element of this list should have the same form as an
+element of @code{font-lock-keywords}.  @xref{Search-based
+Fontification}.
+
+The argument @var{auto-mode-list} is a list of regular expressions to
+add to the variable @code{auto-mode-alist}.  They are added by the execution
+of the @code{define-generic-mode} form, not by expanding the macro call.
+
+Finally, @var{function-list} is a list of functions for the mode
+command to call for additional setup.  It calls these functions just
+before it runs the mode hook variable @code{@var{mode}-hook}.
+@end defmac
+
 @node Example Major Modes
 @subsection Major Mode Examples
 
@@ -1108,8 +1234,8 @@ each calls the following function to set various variables:
 
 @smallexample
 @group
-(defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive)
-  (when lisp-syntax
+(defun lisp-mode-variables (&optional syntax keywords-case-insensitive)
+  (when syntax
     (set-syntax-table lisp-mode-syntax-table))
   (setq local-abbrev-table lisp-mode-abbrev-table)
   @dots{}
@@ -1182,9 +1308,9 @@ or to switch back to an existing one.
 Entry to this mode calls the value of `lisp-mode-hook'
 if that value is non-nil."
   (lisp-mode-variables nil t)
-  (set (make-local-variable 'find-tag-default-function) 'lisp-find-tag-default)
-  (make-local-variable 'comment-start-skip)
-  (setq comment-start-skip
+  (set (make-local-variable 'find-tag-default-function)
+       'lisp-find-tag-default)
+  (set (make-local-variable 'comment-start-skip)
        "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
   (setq imenu-case-fold-search t))
 @end group
@@ -1234,7 +1360,7 @@ follow them is to use the macro @code{define-minor-mode}.
 @cindex mode variable
 Define a variable whose name ends in @samp{-mode}.  We call this the
 @dfn{mode variable}.  The minor mode command should set this variable.
-The value will be @code{nil} is the mode is disabled, and non-@code{nil}
+The value will be @code{nil} if the mode is disabled, and non-@code{nil}
 if the mode is enabled.  The variable should be buffer-local if the
 minor mode is buffer-local.
 
@@ -1252,11 +1378,11 @@ the mode's features.
 
 The mode command should accept one optional argument.  If called
 interactively with no prefix argument, it should toggle the mode
-(i.e.@: enable if it is disabled, and disable if it is enabled).  If
+(i.e., enable if it is disabled, and disable if it is enabled).  If
 called interactively with a prefix argument, it should enable the mode
 if the argument is positive and disable it otherwise.
 
-If the mode command is called from Lisp (i.e.@: non-interactively), it
+If the mode command is called from Lisp (i.e., non-interactively), it
 should enable the mode if the argument is omitted or @code{nil}; it
 should toggle the mode if the argument is the symbol @code{toggle};
 otherwise it should treat the argument in the same way as for an
@@ -1446,8 +1572,8 @@ rather than buffer-local.  It defaults to @code{nil}.
 
 One of the effects of making a minor mode global is that the
 @var{mode} variable becomes a customization variable.  Toggling it
-through the Custom interface turns the mode on and off, and its value
-can be saved for future Emacs sessions (@pxref{Saving
+through the Customize interface turns the mode on and off, and its
+value can be saved for future Emacs sessions (@pxref{Saving
 Customizations,,, emacs, The GNU Emacs Manual}.  For the saved
 variable to work, you should ensure that the @code{define-minor-mode}
 form is evaluated each time Emacs starts; for packages that are not
@@ -1469,19 +1595,24 @@ of the mode.  If you specify this, the @var{mode} variable is not
 defined, and any @var{init-value} argument is unused.  @var{place}
 can be a different named variable (which you must define yourself), or
 anything that can be used with the @code{setf} function
-(@pxref{Generalized Variables,,, cl, Common Lisp Extensions}).
+(@pxref{Generalized Variables}).
 @var{place} can also be a cons @code{(@var{get} . @var{set})},
 where @var{get} is an expression that returns the current state,
 and @var{set} is a function of one argument (a state) that sets it.
+
+@item :after-hook @var{after-hook}
+This defines a single Lisp form which is evaluated after the mode hooks
+have run.  It should not be quoted.
 @end table
 
 Any other keyword arguments are passed directly to the
 @code{defcustom} generated for the variable @var{mode}.
 
-The command named @var{mode} first performs the standard actions such
-as setting the variable named @var{mode} and then executes the
-@var{body} forms, if any.  It finishes by running the mode hook
-variable @code{@var{mode}-hook}.
+The command named @var{mode} first performs the standard actions such as
+setting the variable named @var{mode} and then executes the @var{body}
+forms, if any.  It then runs the mode hook variable
+@code{@var{mode}-hook} and finishes by evaluating any form in
+@code{:after-hook}.
 @end defmac
 
   The initial value must be @code{nil} except in cases where (1) the
@@ -1519,7 +1650,7 @@ See the command \\[hungry-electric-delete]."
 @end smallexample
 
 @noindent
-This defines a minor mode named ``Hungry mode,'' a command named
+This defines a minor mode named ``Hungry mode'', a command named
 @code{hungry-mode} to toggle it, a variable named @code{hungry-mode}
 which indicates whether the mode is enabled, and a variable named
 @code{hungry-mode-map} which holds the keymap that is active when the
@@ -1561,7 +1692,7 @@ Fundamental mode; but it does not detect the creation of a new buffer
 in Fundamental mode.
 
 This defines the customization option @var{global-mode} (@pxref{Customization}),
-which can be toggled in the Custom interface to turn the minor mode on
+which can be toggled in the Customize interface to turn the minor mode on
 and off.  As with @code{define-minor-mode}, you should ensure that the
 @code{define-globalized-minor-mode} form is evaluated each time Emacs
 starts, for example by providing a @code{:require} keyword.
@@ -1712,9 +1843,9 @@ properties specified by @var{props} to the result.  The argument
 A list whose first element is a symbol that is not a keyword specifies
 a conditional.  Its meaning depends on the value of @var{symbol}.  If
 @var{symbol} has a non-@code{nil} value, the second element,
-@var{then}, is processed recursively as a mode line element.
+@var{then}, is processed recursively as a mode line construct.
 Otherwise, the third element, @var{else}, is processed recursively.
-You may omit @var{else}; then the mode line element displays nothing
+You may omit @var{else}; then the mode line construct displays nothing
 if the value of @var{symbol} is @code{nil} or void.
 
 @item (@var{width} @var{rest}@dots{})
@@ -1861,14 +1992,14 @@ default value also displays the recursive editing level, information
 on the process status, and whether narrowing is in effect.
 @end defopt
 
-@defopt mode-line-remote
+@defvar mode-line-remote
 This variable is used to show whether @code{default-directory} for the
 current buffer is remote.
-@end defopt
+@end defvar
 
-@defopt mode-line-client
+@defvar mode-line-client
 This variable is used to identify @code{emacsclient} frames.
-@end defopt
+@end defvar
 
   The following three variables are used in @code{mode-line-modes}:
 
@@ -1886,7 +2017,7 @@ identify the mode name in the mode line, use @code{format-mode-line}
 This buffer-local variable contains the mode line information on process
 status in modes used for communicating with subprocesses.  It is
 displayed immediately following the major mode name, with no intervening
-space.  For example, its value in the @samp{*shell*} buffer is
+space.  For example, its value in the @file{*shell*} buffer is
 @code{(":%s")}, which allows the shell to display its status along
 with the major mode as: @samp{(Shell:run)}.  Normally this variable
 is @code{nil}.
@@ -1955,11 +2086,16 @@ specifies addition of text properties.
 @subsection @code{%}-Constructs in the Mode Line
 
   Strings used as mode line constructs can use certain
-@code{%}-constructs to substitute various kinds of data.  Here is a
-list of the defined @code{%}-constructs, and what they mean.  In any
-construct except @samp{%%}, you can add a decimal integer after the
-@samp{%} to specify a minimum field width.  If the width is less, the
-field is padded with spaces to the right.
+@code{%}-constructs to substitute various kinds of data.  The
+following is a list of the defined @code{%}-constructs, and what they
+mean.
+
+  In any construct except @samp{%%}, you can add a decimal integer
+after the @samp{%} to specify a minimum field width.  If the width is
+less, the field is padded to that width.  Purely numeric constructs
+(@samp{c}, @samp{i}, @samp{I}, and @samp{l}) are padded by inserting
+spaces to the left, and others are padded by inserting spaces to the
+right.
 
 @table @code
 @item %b
@@ -2186,10 +2322,10 @@ definitions, or other named portions of the buffer; then the user can
 choose one of them and move point to it.  Major modes can add a menu
 bar item to use Imenu using @code{imenu-add-to-menubar}.
 
-@defun imenu-add-to-menubar name
+@deffn Command imenu-add-to-menubar name
 This function defines a local menu bar item named @var{name}
 to run Imenu.
-@end defun
+@end deffn
 
   The user-level commands for using Imenu are described in the Emacs
 Manual (@pxref{Imenu,, Imenu, emacs, the Emacs Manual}).  This section
@@ -2949,7 +3085,7 @@ for comments.
 
 @item font-lock-comment-delimiter-face
 @vindex font-lock-comment-delimiter-face
-for comments delimiters, like @samp{/*} and @samp{*/} in C.  On most
+for comments delimiters, like @samp{/*} and @samp{*/} in C@.  On most
 terminals, this inherits from @code{font-lock-comment-face}.
 
 @item font-lock-type-face
@@ -3027,7 +3163,7 @@ outside of any comment, string, or sexp (@pxref{Position Parse}).
 
 This variable is semi-obsolete; we usually recommend setting
 @code{syntax-begin-function} instead.  One of its uses is to tune the
-behavior of syntactic fontification, e.g.@: to ensure that different
+behavior of syntactic fontification, e.g., to ensure that different
 kinds of strings or comments are highlighted differently.
 
 The specified function is called with no arguments.  It should leave
@@ -3245,7 +3381,7 @@ Another one is SMIE which takes an approach in the spirit
 of Lisp sexps and adapts it to non-Lisp languages.
 
 @menu
-* SMIE::                        A simple minded indentation engine
+* SMIE::                        A simple minded indentation engine.
 @end menu
 
 @node SMIE
@@ -3271,14 +3407,14 @@ languages cannot be parsed correctly using SMIE, at least not without
 resorting to some special tricks (@pxref{SMIE Tricks}).
 
 @menu
-* SMIE setup::                  SMIE setup and features
-* Operator Precedence Grammars::  A very simple parsing technique
-* SMIE Grammar::                Defining the grammar of a language
-* SMIE Lexer::                  Defining tokens
-* SMIE Tricks::                 Working around the parser's limitations
-* SMIE Indentation::            Specifying indentation rules
-* SMIE Indentation Helpers::    Helper functions for indentation rules
-* SMIE Indentation Example::    Sample indentation rules
+* SMIE setup::                  SMIE setup and features.
+* Operator Precedence Grammars::  A very simple parsing technique.
+* SMIE Grammar::                Defining the grammar of a language.
+* SMIE Lexer::                  Defining tokens.
+* SMIE Tricks::                 Working around the parser's limitations.
+* SMIE Indentation::            Specifying indentation rules.
+* SMIE Indentation Helpers::    Helper functions for indentation rules.
+* SMIE Indentation Example::    Sample indentation rules.
 @end menu
 
 @node SMIE setup
@@ -3403,7 +3539,7 @@ T1 = T2, or T1 > T2.
 @item
 A token can be an @code{opener} (something similar to an open-paren),
 a @code{closer} (like a close-paren), or @code{neither} of the two
-(e.g. an infix operator, or an inner token like @code{"else"}).
+(e.g., an infix operator, or an inner token like @code{"else"}).
 @end itemize
 
 Precedence conflicts can be resolved via @var{resolvers}, which
@@ -3616,7 +3752,7 @@ Finally, in many cases some conflicts will remain despite all efforts to
 restructure the grammar.  Do not despair: while the parser cannot be
 made more clever, you can make the lexer as smart as you want.  So, the
 solution is then to look at the tokens involved in the conflict and to
-split one of those tokens into 2 (or more) different tokens.  E.g. if
+split one of those tokens into 2 (or more) different tokens.  E.g., if
 the grammar needs to distinguish between two incompatible uses of the
 token @code{"begin"}, make the lexer return different tokens (say
 @code{"begin-fun"} and @code{"begin-plain"}) depending on which kind of
@@ -3731,9 +3867,9 @@ Return non-@code{nil} if the current token's parent is among @var{parents}.
 @end defun
 
 @defun smie-rule-sibling-p
-Return non-nil if the current token's parent is actually a sibling.
-This is the case for example when the parent of a @code{","} is just the
-previous @code{","}.
+Return non-@code{nil} if the current token's parent is actually a
+sibling.  This is the case for example when the parent of a @code{","}
+is just the previous @code{","}.
 @end defun
 
 @defun smie-rule-parent &optional offset
@@ -3747,7 +3883,7 @@ Indent current token as a @emph{separator}.
 
 By @emph{separator}, we mean here a token whose sole purpose is to
 separate various elements within some enclosing syntactic construct, and
-which does not have any semantic significance in itself (i.e. it would
+which does not have any semantic significance in itself (i.e., it would
 typically not exist as a node in an abstract syntax tree).
 
 Such a token is expected to have an associative syntax and be closely
@@ -3903,9 +4039,3 @@ and it should return the restored buffer.
 Here @var{desktop-buffer-misc} is the value returned by the function
 optionally bound to @code{desktop-save-buffer}.
 @end defvar
-
-@ignore
-   Local Variables:
-   fill-column: 72
-   End:
-@end ignore