Mercurial > emacs
comparison lispref/modes.texi @ 22252:40089afa2b1d
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 26 May 1998 18:56:56 +0000 |
parents | d4ac295a98b3 |
children | dfac7398266b |
comparison
equal
deleted
inserted
replaced
22251:5989fa41cda6 | 22252:40089afa2b1d |
---|---|
58 Text mode except that it provides three additional commands. Its | 58 Text mode except that it provides three additional commands. Its |
59 definition is distinct from that of Text mode, but was derived from it. | 59 definition is distinct from that of Text mode, but was derived from it. |
60 | 60 |
61 Rmail Edit mode offers an example of changing the major mode | 61 Rmail Edit mode offers an example of changing the major mode |
62 temporarily for a buffer, so it can be edited in a different way (with | 62 temporarily for a buffer, so it can be edited in a different way (with |
63 ordinary Emacs commands rather than Rmail). In such cases, the | 63 ordinary Emacs commands rather than Rmail commands). In such cases, the |
64 temporary major mode usually has a command to switch back to the | 64 temporary major mode usually has a command to switch back to the |
65 buffer's usual mode (Rmail mode, in this case). You might be tempted to | 65 buffer's usual mode (Rmail mode, in this case). You might be tempted to |
66 present the temporary redefinitions inside a recursive edit and restore | 66 present the temporary redefinitions inside a recursive edit and restore |
67 the usual ones when the user exits; but this is a bad idea because it | 67 the usual ones when the user exits; but this is a bad idea because it |
68 constrains the user's options when it is done in more than one buffer: | 68 constrains the user's options when it is done in more than one buffer: |
821 @item | 821 @item |
822 @cindex mode variable | 822 @cindex mode variable |
823 Make a variable whose name ends in @samp{-mode} to control the minor | 823 Make a variable whose name ends in @samp{-mode} to control the minor |
824 mode. We call this the @dfn{mode variable}. The minor mode command | 824 mode. We call this the @dfn{mode variable}. The minor mode command |
825 should set this variable (@code{nil} to disable; anything else to | 825 should set this variable (@code{nil} to disable; anything else to |
826 enable.) | 826 enable). |
827 | 827 |
828 If it is possible, implement the mode so that setting the variable | 828 If it is possible, implement the mode so that setting the variable |
829 automatically enables or disables the mode. Then the minor mode command | 829 automatically enables or disables the mode. Then the minor mode command |
830 does not need to do anything except the variable. | 830 does not need to do anything except set the variable. |
831 | 831 |
832 This variable is used in conjunction with the @code{minor-mode-alist} to | 832 This variable is used in conjunction with the @code{minor-mode-alist} to |
833 display the minor mode name in the mode line. It can also enable | 833 display the minor mode name in the mode line. It can also enable |
834 or disable a minor mode keymap. Individual commands or hooks can also | 834 or disable a minor mode keymap. Individual commands or hooks can also |
835 check the variable's value. | 835 check the variable's value. |
884 (setq minor-mode-alist | 884 (setq minor-mode-alist |
885 (cons '(leif-mode " Leif") minor-mode-alist))) | 885 (cons '(leif-mode " Leif") minor-mode-alist))) |
886 @end group | 886 @end group |
887 @end smallexample | 887 @end smallexample |
888 @end itemize | 888 @end itemize |
889 | |
890 You can also use @code{add-to-list} to add an element to this list | |
891 just once (@pxref{Setting Variables}). | |
889 | 892 |
890 @node Keymaps and Minor Modes | 893 @node Keymaps and Minor Modes |
891 @subsection Keymaps and Minor Modes | 894 @subsection Keymaps and Minor Modes |
892 | 895 |
893 Each minor mode can have its own keymap, which is active when the mode | 896 Each minor mode can have its own keymap, which is active when the mode |
1133 '(-3 . "%p") | 1136 '(-3 . "%p") |
1134 "-%-")) | 1137 "-%-")) |
1135 @end group | 1138 @end group |
1136 @end example | 1139 @end example |
1137 | 1140 |
1141 @noindent | |
1142 (The variables @code{line-number-mode}, @code{column-number-mode} | |
1143 and @code{which-func-mode} enable particular minor modes; as usual, | |
1144 these variable names are also the minor mode command names.) | |
1145 | |
1138 @node Mode Line Variables | 1146 @node Mode Line Variables |
1139 @subsection Variables Used in the Mode Line | 1147 @subsection Variables Used in the Mode Line |
1140 | 1148 |
1141 This section describes variables incorporated by the | 1149 This section describes variables incorporated by the |
1142 standard value of @code{mode-line-format} into the text of the mode | 1150 standard value of @code{mode-line-format} into the text of the mode |
1172 frame at a time. | 1180 frame at a time. |
1173 @end defvar | 1181 @end defvar |
1174 | 1182 |
1175 @defvar mode-line-buffer-identification | 1183 @defvar mode-line-buffer-identification |
1176 This variable identifies the buffer being displayed in the window. Its | 1184 This variable identifies the buffer being displayed in the window. Its |
1177 default value is @code{("%12b")}, which means that it usually | 1185 default value is @code{("%12b")}, which means that it usually displays |
1178 displays @samp{Emacs:} followed by seventeen characters of the buffer | 1186 twelve characters of the buffer name. |
1179 name. (In a terminal frame, it displays the frame name instead of | |
1180 @samp{Emacs}; this has the effect of showing the frame number.) You may | |
1181 want to change this in modes such as Rmail that do not behave like a | |
1182 ``normal'' Emacs. | |
1183 @end defvar | 1187 @end defvar |
1184 | 1188 |
1185 @defvar global-mode-string | 1189 @defvar global-mode-string |
1186 This variable holds a mode line spec that appears in the mode line by | 1190 This variable holds a mode line spec that appears in the mode line by |
1187 default, just after the buffer name. The command @code{display-time} | 1191 default, just after the buffer name. The command @code{display-time} |
1238 @defvar mode-line-process | 1242 @defvar mode-line-process |
1239 This buffer-local variable contains the mode line information on process | 1243 This buffer-local variable contains the mode line information on process |
1240 status in modes used for communicating with subprocesses. It is | 1244 status in modes used for communicating with subprocesses. It is |
1241 displayed immediately following the major mode name, with no intervening | 1245 displayed immediately following the major mode name, with no intervening |
1242 space. For example, its value in the @samp{*shell*} buffer is | 1246 space. For example, its value in the @samp{*shell*} buffer is |
1243 @code{(":@: %s")}, which allows the shell to display its status along | 1247 @code{(":%s")}, which allows the shell to display its status along |
1244 with the major mode as: @samp{(Shell:@: run)}. Normally this variable | 1248 with the major mode as: @samp{(Shell:@: run)}. Normally this variable |
1245 is @code{nil}. | 1249 is @code{nil}. |
1246 @end defvar | 1250 @end defvar |
1247 | 1251 |
1248 @defvar default-mode-line-format | 1252 @defvar default-mode-line-format |
1454 Setting this variable makes it buffer-local in the current buffer. | 1458 Setting this variable makes it buffer-local in the current buffer. |
1455 @end defvar | 1459 @end defvar |
1456 | 1460 |
1457 @defvar imenu-syntax-alist | 1461 @defvar imenu-syntax-alist |
1458 This variable is an alist of syntax table modifiers to use while | 1462 This variable is an alist of syntax table modifiers to use while |
1459 executing @code{imenu--generic-function} to override the syntax table of | 1463 processing @code{imenu-generic-expression}, to override the syntax table |
1460 the current buffer. Each element should have this form: | 1464 of the current buffer. Each element should have this form: |
1461 | 1465 |
1462 @example | 1466 @example |
1463 (@var{characters} . @var{syntax-description}) | 1467 (@var{characters} . @var{syntax-description}) |
1464 @end example | 1468 @end example |
1465 | 1469 |
1476 @example | 1480 @example |
1477 (setq imenu-syntax-alist '(("_$" . "w"))) | 1481 (setq imenu-syntax-alist '(("_$" . "w"))) |
1478 @end example | 1482 @end example |
1479 | 1483 |
1480 The @code{imenu-generic-expression} patterns can then use @samp{\\sw+} | 1484 The @code{imenu-generic-expression} patterns can then use @samp{\\sw+} |
1481 instead of @samp{\\(\\sw\\|\\s_\\)\\}. Note that this technique may be | 1485 instead of @samp{\\(\\sw\\|\\s_\\)+}. Note that this technique may be |
1482 inconvenient to use when the mode needs to limit the initial character | 1486 inconvenient to use when the mode needs to limit the initial character |
1483 of a name to a smaller set of characters | 1487 of a name to a smaller set of characters |
1484 | 1488 |
1485 Setting this variable makes it buffer-local in the current buffer. | 1489 Setting this variable makes it buffer-local in the current buffer. |
1486 @end defvar | 1490 @end defvar |
2079 | 2083 |
2080 @defun run-hook-with-args-until-failure hook &rest args | 2084 @defun run-hook-with-args-until-failure hook &rest args |
2081 This function is the way to run an abnormal hook which passes arguments | 2085 This function is the way to run an abnormal hook which passes arguments |
2082 to the hook functions, and stops as soon as any hook function fails. It | 2086 to the hook functions, and stops as soon as any hook function fails. It |
2083 calls each of the hook functions, passing each of them the arguments | 2087 calls each of the hook functions, passing each of them the arguments |
2084 @var{args}, until some hook function returns @code{nil}. Then it stops. | 2088 @var{args}, until some hook function returns @code{nil}. Then it stops, |
2089 and returns @code{nil} if some hook function did, and otherwise | |
2090 returns a non-@code{nil} value. | |
2085 @end defun | 2091 @end defun |
2086 | 2092 |
2087 @defun run-hook-with-args-until-success hook &rest args | 2093 @defun run-hook-with-args-until-success hook &rest args |
2088 This function is the way to run an abnormal hook which passes arguments | 2094 This function is the way to run an abnormal hook which passes arguments |
2089 to the hook functions, and stops as soon as any hook function succeeds. | 2095 to the hook functions, and stops as soon as any hook function succeeds. |
2090 It calls each of the hook functions, passing each of them the arguments | 2096 It calls each of the hook functions, passing each of them the arguments |
2091 @var{args}, until some hook function returns non-@code{nil}. Then it | 2097 @var{args}, until some hook function returns non-@code{nil}. Then it |
2092 stops. | 2098 stops, and returns whatever was returned by the last hook function |
2099 that was called. | |
2093 @end defun | 2100 @end defun |
2094 | 2101 |
2095 @defun add-hook hook function &optional append local | 2102 @defun add-hook hook function &optional append local |
2096 This function is the handy way to add function @var{function} to hook | 2103 This function is the handy way to add function @var{function} to hook |
2097 variable @var{hook}. The argument @var{function} may be any valid Lisp | 2104 variable @var{hook}. The argument @var{function} may be any valid Lisp |