aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-05-01 19:27:09 +0000
committerRichard M. Stallman1994-05-01 19:27:09 +0000
commitde9f0bd94f691d90c98b0d703f58f9036fdcd40e (patch)
treea826c385b1c28a826bd804a4927bec96c8bb7bd5
parent87b2d5ff029e93b27ab4887608788fd3d2b8c7e7 (diff)
downloademacs-de9f0bd94f691d90c98b0d703f58f9036fdcd40e.tar.gz
emacs-de9f0bd94f691d90c98b0d703f58f9036fdcd40e.zip
*** empty log message ***
-rw-r--r--lispref/modes.texi175
1 files changed, 97 insertions, 78 deletions
diff --git a/lispref/modes.texi b/lispref/modes.texi
index c15ca5a9cd0..69649c4b665 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -99,7 +99,7 @@ should set up the keymap, syntax table, and local variables in an
99existing buffer without changing the buffer's text. 99existing buffer without changing the buffer's text.
100 100
101@item 101@item
102Write a documentation string for this command which describes the 102Write a documentation string for this command that describes the
103special commands available in this mode. @kbd{C-h m} 103special commands available in this mode. @kbd{C-h m}
104(@code{describe-mode}) in your mode will display this string. 104(@code{describe-mode}) in your mode will display this string.
105 105
@@ -140,16 +140,13 @@ should call @code{use-local-map} to install this local map.
140 140
141This keymap should be kept in a global variable named 141This keymap should be kept in a global variable named
142@code{@var{modename}-mode-map}. Normally the library that defines the 142@code{@var{modename}-mode-map}. Normally the library that defines the
143mode sets this variable. Use @code{defvar} to set the variable, so that 143mode sets this variable.
144it is not reinitialized if it already has a value. (Such
145reinitialization could discard customizations made by the user.)
146 144
147@item 145@item
148@cindex syntax tables in modes 146@cindex syntax tables in modes
149The mode may have its own syntax table or may share one with other 147The mode may have its own syntax table or may share one with other
150related modes. If it has its own syntax table, it should store this in 148related modes. If it has its own syntax table, it should store this in
151a variable named @code{@var{modename}-mode-syntax-table}. The reasons 149a variable named @code{@var{modename}-mode-syntax-table}. @xref{Syntax
152for this are the same as for using a keymap variable. @xref{Syntax
153Tables}. 150Tables}.
154 151
155@item 152@item
@@ -160,6 +157,11 @@ a variable named @code{@var{modename}-mode-abbrev-table}. @xref{Abbrev
160Tables}. 157Tables}.
161 158
162@item 159@item
160Use @code{defvar} to set mode-related variables, so that they are not
161reinitialized if they already have a value. (Such reinitialization
162could discard customizations made by the user.)
163
164@item
163@cindex buffer-local variables in modes 165@cindex buffer-local variables in modes
164To make a buffer-local binding for an Emacs customization variable, use 166To make a buffer-local binding for an Emacs customization variable, use
165@code{make-local-variable} in the major mode command, not 167@code{make-local-variable} in the major mode command, not
@@ -223,7 +225,7 @@ include in their @file{.emacs} files.
223 225
224@item 226@item
225@cindex mode loading 227@cindex mode loading
226The top level forms in the file defining the mode should be written so 228The top-level forms in the file defining the mode should be written so
227that they may be evaluated more than once without adverse consequences. 229that they may be evaluated more than once without adverse consequences.
228Even if you never load the file more than once, someone else will. 230Even if you never load the file more than once, someone else will.
229@end itemize 231@end itemize
@@ -234,7 +236,7 @@ does anything else. This gives major modes a way to arrange for
234something special to be done if the user switches to a different major 236something special to be done if the user switches to a different major
235mode. For best results, make this variable buffer-local, so that it 237mode. For best results, make this variable buffer-local, so that it
236will disappear after doing its job and will not interfere with the 238will disappear after doing its job and will not interfere with the
237subsequent major mode. 239subsequent major mode. @xref{Hooks}.
238@end defvar 240@end defvar
239 241
240@node Example Major Modes 242@node Example Major Modes
@@ -424,8 +426,7 @@ variable with @code{defvar} to hold the mode-specific keymap. When this
424void. Then we set up the keymap if the variable is @code{nil}. 426void. Then we set up the keymap if the variable is @code{nil}.
425 427
426 This code avoids changing the keymap or the variable if it is already 428 This code avoids changing the keymap or the variable if it is already
427set up. This lets the user customize the keymap if he or she so 429set up. This lets the user customize the keymap.
428wishes.
429 430
430@smallexample 431@smallexample
431@group 432@group
@@ -461,7 +462,7 @@ Entry to this mode runs the hook `emacs-lisp-mode-hook'."
461 (setq major-mode 'emacs-lisp-mode) ; @r{This is how @code{describe-mode}} 462 (setq major-mode 'emacs-lisp-mode) ; @r{This is how @code{describe-mode}}
462 ; @r{finds out what to describe.} 463 ; @r{finds out what to describe.}
463 (setq mode-name "Emacs-Lisp") ; @r{This goes into the mode line.} 464 (setq mode-name "Emacs-Lisp") ; @r{This goes into the mode line.}
464 (lisp-mode-variables nil) ; @r{This define various variables.} 465 (lisp-mode-variables nil) ; @r{This defines various variables.}
465 (run-hooks 'emacs-lisp-mode-hook)) ; @r{This permits the user to use a} 466 (run-hooks 'emacs-lisp-mode-hook)) ; @r{This permits the user to use a}
466 ; @r{hook to customize the mode.} 467 ; @r{hook to customize the mode.}
467@end group 468@end group
@@ -527,7 +528,7 @@ the user what to do for each file. The default value is @code{maybe}.
527 This function selects the major mode that is appropriate for the 528 This function selects the major mode that is appropriate for the
528current buffer. It may base its decision on the value of the @w{@samp{-*-}} 529current buffer. It may base its decision on the value of the @w{@samp{-*-}}
529line, on the visited file name (using @code{auto-mode-alist}), or on the 530line, on the visited file name (using @code{auto-mode-alist}), or on the
530value of a local variable). However, this function does not look for 531value of a local variable. However, this function does not look for
531the @samp{mode:} local variable near the end of a file; the 532the @samp{mode:} local variable near the end of a file; the
532@code{hack-local-variables} function does that. @xref{Choosing Modes, , 533@code{hack-local-variables} function does that. @xref{Choosing Modes, ,
533How Major Modes are Chosen, emacs, The GNU Emacs Manual}. 534How Major Modes are Chosen, emacs, The GNU Emacs Manual}.
@@ -600,10 +601,11 @@ Here is an example of how to prepend several pattern pairs to
600@group 601@group
601(setq auto-mode-alist 602(setq auto-mode-alist
602 (append 603 (append
603 ;; @r{Filename starts with a dot.} 604 ;; @r{File name starts with a dot.}
604 '(("/\\.[^/]*$" . fundamental-mode) 605 '(("/\\.[^/]*$" . fundamental-mode)
605 ;; @r{Filename has no dot.} 606 ;; @r{File name has no dot.}
606 ("[^\\./]*$" . fundamental-mode) 607 ("[^\\./]*$" . fundamental-mode)
608 ;; @r{File name ends in @samp{.C}.}
607 ("\\.C$" . c++-mode)) 609 ("\\.C$" . c++-mode))
608 auto-mode-alist)) 610 auto-mode-alist))
609@end group 611@end group
@@ -618,8 +620,8 @@ example, @code{("perl" . perl-mode)} is one element present by default.
618The element says to use mode @var{mode} if the file specifies 620The element says to use mode @var{mode} if the file specifies
619@var{interpreter}. 621@var{interpreter}.
620 622
621This variable is applicable only when the file name doesn't indicate 623This variable is applicable only when the @code{auto-mode-alist} does
622which major mode to use. 624not indicate which major mode to use.
623@end defvar 625@end defvar
624 626
625@defun hack-local-variables &optional force 627@defun hack-local-variables &optional force
@@ -628,7 +630,8 @@ variables for the current buffer.
628 630
629 The handling of @code{enable-local-variables} documented for 631 The handling of @code{enable-local-variables} documented for
630@code{normal-mode} actually takes place here. The argument @var{force} 632@code{normal-mode} actually takes place here. The argument @var{force}
631reflects the argument @var{find-file} given to @code{normal-mode}. 633usually comes from the argument @var{find-file} given to
634@code{normal-mode}.
632@end defun 635@end defun
633 636
634@node Mode Help 637@node Mode Help
@@ -654,9 +657,9 @@ displays the documentation string of the major mode function.
654 657
655@defvar major-mode 658@defvar major-mode
656This variable holds the symbol for the current buffer's major mode. 659This variable holds the symbol for the current buffer's major mode.
657This symbol should have a function definition which is the command to 660This symbol should have a function definition that is the command to
658switch to that major mode. The @code{describe-mode} function uses the 661switch to that major mode. The @code{describe-mode} function uses the
659documentation string of this symbol as the documentation of the major 662documentation string of the function as the documentation of the major
660mode. 663mode.
661@end defvar 664@end defvar
662 665
@@ -666,12 +669,12 @@ mode.
666 It's often useful to define a new major mode in terms of an existing 669 It's often useful to define a new major mode in terms of an existing
667one. An easy way to do this is to use @code{define-derived-mode}. 670one. An easy way to do this is to use @code{define-derived-mode}.
668 671
669@defmac define-derived-mode variant parent name doc body@dots{} 672@defmac define-derived-mode variant parent name docstring body@dots{}
670This construct defines @var{variant} as a major mode command, using 673This construct defines @var{variant} as a major mode command, using
671@var{name} as the string form of the mode which. 674@var{name} as the string form of the mode name.
672 675
673The definition of the command is to call the function @var{parent}, then 676The new command @var{variant} is defined to call the function
674override certain aspects of that parent mode: 677@var{parent}, then override certain aspects of that parent mode:
675 678
676@itemize @bullet 679@itemize @bullet
677@item 680@item
@@ -680,13 +683,13 @@ The new mode has its own keymap, named @code{@var{variant}-map}.
680@code{@var{parent}-map}, if it is not already set. 683@code{@var{parent}-map}, if it is not already set.
681 684
682@item 685@item
683The new mode has its own syntax table, taken from the variable 686The new mode has its own syntax table, kept in the variable
684@code{@var{variant}-syntax-table}. 687@code{@var{variant}-syntax-table}.
685@code{define-derived-mode} initializes this variable by copying 688@code{define-derived-mode} initializes this variable by copying
686@code{@var{parent}-syntax-table}, if it is not already set. 689@code{@var{parent}-syntax-table}, if it is not already set.
687 690
688@item 691@item
689The new mode has its own abbrev table, taken from the variable 692The new mode has its own abbrev table, kept in the variable
690@code{@var{variant}-abbrev-table}. 693@code{@var{variant}-abbrev-table}.
691@code{define-derived-mode} initializes this variable by copying 694@code{define-derived-mode} initializes this variable by copying
692@code{@var{parent}-abbrev-table}, if it is not already set. 695@code{@var{parent}-abbrev-table}, if it is not already set.
@@ -699,7 +702,7 @@ of calling @var{parent}.)
699@end itemize 702@end itemize
700 703
701In addition, you can specify how to override other aspects of 704In addition, you can specify how to override other aspects of
702@var{parent-mode} with @var{body}. The command @var{variant} 705@var{parent} with @var{body}. The command @var{variant}
703evaluates the forms in @var{body} after setting up all its usual 706evaluates the forms in @var{body} after setting up all its usual
704overrides, just before running @code{@var{variant}-hook}. 707overrides, just before running @code{@var{variant}-hook}.
705 708
@@ -738,10 +741,9 @@ of the things major modes do.
738 741
739 A minor mode is often much more difficult to implement than a major 742 A minor mode is often much more difficult to implement than a major
740mode. One reason is that you should be able to activate and deactivate 743mode. One reason is that you should be able to activate and deactivate
741minor modes in any order. 744minor modes in any order. A minor mode should be able to have its
742 745desired effect regardless of the major mode and regardless of the other
743and restore the environment of the major mode to the state it was in 746minor modes in effect.
744before the minor mode was activated.
745 747
746 Often the biggest problem in implementing a minor mode is finding a 748 Often the biggest problem in implementing a minor mode is finding a
747way to insert the necessary hook into the rest of Emacs. Minor mode 749way to insert the necessary hook into the rest of Emacs. Minor mode
@@ -794,8 +796,9 @@ list whose @sc{car} is such an integer or symbol; it should turn the
794mode off otherwise. 796mode off otherwise.
795 797
796Here is an example taken from the definition of @code{overwrite-mode}. 798Here is an example taken from the definition of @code{overwrite-mode}.
797It shows the use of @code{overwrite-mode} as a variable which enables or 799It shows the use of @code{overwrite-mode} as a variable that enables or
798disables the mode's behavior. 800disables the mode's behavior, and also shows the proper way to toggle,
801enable or disable the minor mode based on the raw prefix argument value.
799 802
800@smallexample 803@smallexample
801@group 804@group
@@ -814,7 +817,7 @@ following form:
814(@var{mode-variable} @var{string}) 817(@var{mode-variable} @var{string})
815@end smallexample 818@end smallexample
816 819
817Here @var{mode-variable} is the variable that controls enablement of the 820Here @var{mode-variable} is the variable that controls enabling of the
818minor mode, and @var{string} is a short string, starting with a space, 821minor mode, and @var{string} is a short string, starting with a space,
819to represent the mode in the mode line. These strings must be short so 822to represent the mode in the mode line. These strings must be short so
820that there is room for several of them at once. 823that there is room for several of them at once.
@@ -834,7 +837,7 @@ check for an existing element, to avoid duplication. For example:
834@node Keymaps and Minor Modes 837@node Keymaps and Minor Modes
835@subsection Keymaps and Minor Modes 838@subsection Keymaps and Minor Modes
836 839
837As of Emacs version 19, each minor mode can have its own keymap which is 840As of Emacs version 19, each minor mode can have its own keymap, which is
838active when the mode is enabled. @xref{Active Keymaps}. To set up a 841active when the mode is enabled. @xref{Active Keymaps}. To set up a
839keymap for a minor mode, add an element to the alist 842keymap for a minor mode, add an element to the alist
840@code{minor-mode-map-alist}. 843@code{minor-mode-map-alist}.
@@ -856,7 +859,7 @@ This variable is an alist of elements that look like this:
856@end example 859@end example
857 860
858@noindent 861@noindent
859where @var{variable} is the variable which indicates whether the minor 862where @var{variable} is the variable that indicates whether the minor
860mode is enabled, and @var{keymap} is the keymap. The keymap 863mode is enabled, and @var{keymap} is the keymap. The keymap
861@var{keymap} is active whenever @var{variable} has a non-@code{nil} 864@var{keymap} is active whenever @var{variable} has a non-@code{nil}
862value. 865value.
@@ -880,11 +883,11 @@ this properly, the order will not matter.
880@section Mode Line Format 883@section Mode Line Format
881@cindex mode line 884@cindex mode line
882 885
883 Each Emacs window (aside from minibuffer windows) includes a mode line 886 Each Emacs window (aside from minibuffer windows) includes a mode line,
884which displays status information about the buffer displayed in the 887which displays status information about the buffer displayed in the
885window. The mode line contains information about the buffer such as its 888window. The mode line contains information about the buffer, such as its
886name, associated file, depth of recursive editing, and the major and 889name, associated file, depth of recursive editing, and the major and
887minor modes of the buffer. 890minor modes.
888 891
889 This section describes how the contents of the mode line are 892 This section describes how the contents of the mode line are
890controlled. It is in the chapter on modes because much of the 893controlled. It is in the chapter on modes because much of the
@@ -900,8 +903,9 @@ line numbers).
900 The mode line of a window is normally updated whenever a different 903 The mode line of a window is normally updated whenever a different
901buffer is shown in the window, or when the buffer's modified-status 904buffer is shown in the window, or when the buffer's modified-status
902changes from @code{nil} to @code{t} or vice-versa. If you modify any of 905changes from @code{nil} to @code{t} or vice-versa. If you modify any of
903the variables referenced by @code{mode-line-format}, you may want to 906the variables referenced by @code{mode-line-format} (@pxref{Mode Line
904force an update of the mode line so as to display the new information. 907Variables}), you may want to force an update of the mode line so as to
908display the new information.
905 909
906@c Emacs 19 feature 910@c Emacs 19 feature
907@defun force-mode-line-update 911@defun force-mode-line-update
@@ -922,7 +926,7 @@ Force redisplay of the current buffer's mode line.
922@cindex mode line construct 926@cindex mode line construct
923 927
924 The mode line contents are controlled by a data structure of lists, 928 The mode line contents are controlled by a data structure of lists,
925strings, symbols and numbers kept in the buffer-local variable 929strings, symbols, and numbers kept in the buffer-local variable
926@code{mode-line-format}. The data structure is called a @dfn{mode line 930@code{mode-line-format}. The data structure is called a @dfn{mode line
927construct}, and it is built in recursive fashion out of simpler mode line 931construct}, and it is built in recursive fashion out of simpler mode line
928constructs. 932constructs.
@@ -945,9 +949,8 @@ Because of this, very few modes need to alter @code{mode-line-format}.
945For most purposes, it is sufficient to alter the variables referenced by 949For most purposes, it is sufficient to alter the variables referenced by
946@code{mode-line-format}. 950@code{mode-line-format}.
947 951
948 A mode line construct may be a list, cons cell, symbol, or string. If 952 A mode line construct may be a list, a symbol, or a string. If the
949the value is a list, each element may be a list, a cons cell, a symbol, 953value is a list, each element may be a list, a symbol, or a string.
950or a string.
951 954
952@table @code 955@table @code
953@cindex percent symbol in mode line 956@cindex percent symbol in mode line
@@ -959,24 +962,26 @@ is left justified). @xref{%-Constructs}.
959 962
960@item @var{symbol} 963@item @var{symbol}
961A symbol as a mode line construct stands for its value. The value of 964A symbol as a mode line construct stands for its value. The value of
962@var{symbol} is used in place of @var{symbol} unless @var{symbol} is 965@var{symbol} is used as a mode line construct, in place of @var{symbol}.
963@code{t} or @code{nil}, or is void, in which case @var{symbol} is 966However, the symbols @code{t} and @code{nil} are ignored; so is any
964ignored. 967symbol whose value is void.
965 968
966There is one exception: if the value of @var{symbol} is a string, it is 969There is one exception: if the value of @var{symbol} is a string, it is
967processed verbatim in that the @code{%}-constructs are not recognized. 970displayed verbatim: the @code{%}-constructs are not recognized.
968 971
969@item (@var{string} @var{rest}@dots{}) @r{or} (@var{list} @var{rest}@dots{}) 972@item (@var{string} @var{rest}@dots{}) @r{or} (@var{list} @var{rest}@dots{})
970A list whose first element is a string or list, means to concatenate all 973A list whose first element is a string or list means to process all the
971the elements. This is the most common form of mode line construct. 974elements recursively and concatenate the results. This is the most
975common form of mode line construct.
972 976
973@item (@var{symbol} @var{then} @var{else}) 977@item (@var{symbol} @var{then} @var{else})
974A list whose first element is a symbol is a conditional. Its meaning 978A list whose first element is a symbol is a conditional. Its meaning
975depends on the value of @var{symbol}. If the value is non-@code{nil}, 979depends on the value of @var{symbol}. If the value is non-@code{nil},
976the second element of the list (@var{then}) is processed recursively as 980the second element, @var{then}, is processed recursively as a mode line
977a mode line element. But if the value of @var{symbol} is @code{nil}, 981element. But if the value of @var{symbol} is @code{nil}, the third
978the third element of the list (if there is one) is processed 982element, @var{else}, is processed recursively. You may omit @var{else};
979recursively. 983then the mode line element displays nothing if the value of @var{symbol}
984is @code{nil}.
980 985
981@item (@var{width} @var{rest}@dots{}) 986@item (@var{width} @var{rest}@dots{})
982A list whose first element is an integer specifies truncation or 987A list whose first element is an integer specifies truncation or
@@ -987,19 +992,19 @@ concatenated together. Then the result is space filled (if
987if @var{width} is negative) on the right. 992if @var{width} is negative) on the right.
988 993
989For example, the usual way to show what percentage of a buffer is above 994For example, the usual way to show what percentage of a buffer is above
990the top of the window is to use a list like this: @code{(-3 . "%p")}. 995the top of the window is to use a list like this: @code{(-3 "%p")}.
991@end table 996@end table
992 997
993 If you do alter @code{mode-line-format} itself, the new value should 998 If you do alter @code{mode-line-format} itself, the new value should
994use all the same variables that are used by the default value, rather 999use the same variables that appear in the default value (@pxref{Mode
995than duplicating their contents or displaying the information in another 1000Line Variables}), rather than duplicating their contents or displaying
996fashion. This way, customizations made by the user, by libraries (such 1001the information in another fashion. This way, customizations made by
997as @code{display-time}) and by major modes via changes to those 1002the user, by libraries (such as @code{display-time}) and by major modes
998variables remain effective. 1003via changes to those variables remain effective.
999 1004
1000@cindex Shell mode @code{mode-line-format} 1005@cindex Shell mode @code{mode-line-format}
1001 Here is an example of a @code{mode-line-format} that might be 1006 Here is an example of a @code{mode-line-format} that might be
1002useful for @code{shell-mode} since it contains the hostname and default 1007useful for @code{shell-mode}, since it contains the hostname and default
1003directory. 1008directory.
1004 1009
1005@example 1010@example
@@ -1014,10 +1019,11 @@ directory.
1014 'default-directory 1019 'default-directory
1015 " " 1020 " "
1016 'global-mode-string 1021 'global-mode-string
1017 " %[(" 'mode-name 1022 " %[("
1023 'mode-name
1024 'mode-line-process
1018 'minor-mode-alist 1025 'minor-mode-alist
1019 "%n" 1026 "%n"
1020 'mode-line-process
1021 ")%]----" 1027 ")%]----"
1022@group 1028@group
1023 (line-number-mode "L%l--") 1029 (line-number-mode "L%l--")
@@ -1036,10 +1042,10 @@ other variables could have the same effects on the mode line if
1036@code{mode-line-format} were changed to use them. 1042@code{mode-line-format} were changed to use them.
1037 1043
1038@defvar mode-line-modified 1044@defvar mode-line-modified
1039 This variable holds the value of the mode-line construct that displays 1045This variable holds the value of the mode-line construct that displays
1040whether the current buffer is modified. 1046whether the current buffer is modified.
1041 1047
1042 The default value of @code{mode-line-modified} is 1048The default value of @code{mode-line-modified} is
1043@code{("--%1*%1*-")}. This means that the mode line displays 1049@code{("--%1*%1*-")}. This means that the mode line displays
1044@samp{--**-} if the buffer is modified, @samp{-----} if the buffer is 1050@samp{--**-} if the buffer is modified, @samp{-----} if the buffer is
1045not modified, and @samp{--%%-} if the buffer is read only. 1051not modified, and @samp{--%%-} if the buffer is read only.
@@ -1048,10 +1054,11 @@ Changing this variable does not force an update of the mode line.
1048@end defvar 1054@end defvar
1049 1055
1050@defvar mode-line-buffer-identification 1056@defvar mode-line-buffer-identification
1051 This variable identifies the buffer being displayed in the window. 1057This variable identifies the buffer being displayed in the window. Its
1052Its default value is @samp{Emacs: %17b}, which means that it displays 1058default value is @samp{Emacs: %17b}, which means that it displays
1053@samp{Emacs:} followed by the buffer name. You may want to change this 1059@samp{Emacs:} followed by seventeen characters of the buffer name. You
1054in modes such as Rmail that do not behave like a ``normal'' Emacs. 1060may want to change this in modes such as Rmail that do not behave like a
1061``normal'' Emacs.
1055@end defvar 1062@end defvar
1056 1063
1057@defvar global-mode-string 1064@defvar global-mode-string
@@ -1067,13 +1074,13 @@ included directly in the mode line.
1067@end defvar 1074@end defvar
1068 1075
1069@defvar mode-name 1076@defvar mode-name
1070 This buffer-local variable holds the ``pretty'' name of the current 1077This buffer-local variable holds the ``pretty'' name of the current
1071buffer's major mode. Each major mode should set this variable so that the 1078buffer's major mode. Each major mode should set this variable so that the
1072mode name will appear in the mode line. 1079mode name will appear in the mode line.
1073@end defvar 1080@end defvar
1074 1081
1075@defvar minor-mode-alist 1082@defvar minor-mode-alist
1076 This variable holds an association list whose elements specify how the 1083This variable holds an association list whose elements specify how the
1077mode line should indicate that a minor mode is active. Each element of 1084mode line should indicate that a minor mode is active. Each element of
1078the @code{minor-mode-alist} should be a two-element list: 1085the @code{minor-mode-alist} should be a two-element list:
1079 1086
@@ -1120,11 +1127,11 @@ is @code{nil}.
1120@end defvar 1127@end defvar
1121 1128
1122@defvar default-mode-line-format 1129@defvar default-mode-line-format
1123 This variable holds the default @code{mode-line-format} for buffers 1130This variable holds the default @code{mode-line-format} for buffers
1124that do not override it. This is the same as @code{(default-value 1131that do not override it. This is the same as @code{(default-value
1125'mode-line-format)}. 1132'mode-line-format)}.
1126 1133
1127 The default value of @code{default-mode-line-format} is: 1134The default value of @code{default-mode-line-format} is:
1128 1135
1129@example 1136@example
1130@group 1137@group
@@ -1147,11 +1154,19 @@ that do not override it. This is the same as @code{(default-value
1147@end example 1154@end example
1148@end defvar 1155@end defvar
1149 1156
1157@defvar vc-mode
1158The variable @code{vc-mode}, local in each buffer, records whether the
1159buffer's visited file is maintained with version control, and, if so,
1160which kind. Its value is @code{nil} for no version control, or a string
1161that appears in the mode line.
1162@end defvar
1163
1150@node %-Constructs 1164@node %-Constructs
1151@subsection @code{%}-Constructs in the Mode Line 1165@subsection @code{%}-Constructs in the Mode Line
1152 1166
1153 The following table lists the recognized @code{%}-constructs and what 1167 The following table lists the recognized @code{%}-constructs and what
1154they mean. 1168they mean. In any construct except @samp{%%}, you can add a decimal
1169integer after the @samp{%} to specify how many characters to display.
1155 1170
1156@table @code 1171@table @code
1157@item %b 1172@item %b
@@ -1168,7 +1183,7 @@ function. @xref{Buffer File Name}.
1168@samp{-} otherwise. @xref{Buffer Modification}. 1183@samp{-} otherwise. @xref{Buffer Modification}.
1169 1184
1170@item %+ 1185@item %+
1171@samp{*} if the buffer is modified, and otherwise @samp{-}. 1186@samp{*} if the buffer is modified, and @samp{-} otherwise.
1172 1187
1173@item %s 1188@item %s
1174The status of the subprocess belonging to the current buffer, obtained with 1189The status of the subprocess belonging to the current buffer, obtained with
@@ -1241,8 +1256,8 @@ a Function}). Most normal hook variables are initially void;
1241@code{add-hook} knows how to deal with this. 1256@code{add-hook} knows how to deal with this.
1242 1257
1243 As for abnormal hooks, those whose names end in @samp{-function} have 1258 As for abnormal hooks, those whose names end in @samp{-function} have
1244a value which is a single function. Those whose names end in 1259a value that is a single function. Those whose names end in
1245@samp{-hooks} have a value which is a list of functions. Any hook which 1260@samp{-hooks} have a value that is a list of functions. Any hook that
1246is abnormal is abnormal because a normal hook won't do the job; either 1261is abnormal is abnormal because a normal hook won't do the job; either
1247the functions are called with arguments, or their values are meaningful. 1262the functions are called with arguments, or their values are meaningful.
1248The name shows you that the hook is abnormal and that you should look at 1263The name shows you that the hook is abnormal and that you should look at
@@ -1340,7 +1355,8 @@ For example, here's how @code{emacs-lisp-hooks} runs its mode hook:
1340 1355
1341@defun add-hook hook function &optional append 1356@defun add-hook hook function &optional append
1342This function is the handy way to add function @var{function} to hook 1357This function is the handy way to add function @var{function} to hook
1343variable @var{hook}. For example, 1358variable @var{hook}. The argument @var{function} may be any valid Lisp
1359function with the proper number of arguments. For example,
1344 1360
1345@example 1361@example
1346(add-hook 'text-mode-hook 'my-text-hook-function) 1362(add-hook 'text-mode-hook 'my-text-hook-function)
@@ -1349,6 +1365,9 @@ variable @var{hook}. For example,
1349@noindent 1365@noindent
1350adds @code{my-text-hook-function} to the hook called @code{text-mode-hook}. 1366adds @code{my-text-hook-function} to the hook called @code{text-mode-hook}.
1351 1367
1368You can use @code{add-hook} for abnormal hooks as well as for normal
1369hooks.
1370
1352It is best to design your hook functions so that the order in which they 1371It is best to design your hook functions so that the order in which they
1353are executed does not matter. Any dependence on the order is ``asking 1372are executed does not matter. Any dependence on the order is ``asking
1354for trouble.'' However, the order is predictable: normally, 1373for trouble.'' However, the order is predictable: normally,