diff options
| author | Chong Yidong | 2009-03-28 13:38:55 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-03-28 13:38:55 +0000 |
| commit | 41633740578d28ef2e2f7322805781b979986321 (patch) | |
| tree | 6c005eff16b4d818bdabeac86493b576c870aa2f | |
| parent | 3c25a5a986380999e367134756efe2b71553fa70 (diff) | |
| download | emacs-41633740578d28ef2e2f7322805781b979986321.tar.gz emacs-41633740578d28ef2e2f7322805781b979986321.zip | |
(Major Mode Conventions): Note that specialness is inherited.
| -rw-r--r-- | doc/lispref/modes.texi | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 3547dd3e304..4fa843e6743 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -157,13 +157,13 @@ If @var{function} has a non-@code{nil} property | |||
| 157 | changing major modes) won't delete it from the hook variable's local | 157 | changing major modes) won't delete it from the hook variable's local |
| 158 | value. | 158 | value. |
| 159 | 159 | ||
| 160 | It is best to design your hook functions so that the order in which they | 160 | It is best to design your hook functions so that the order in which |
| 161 | are executed does not matter. Any dependence on the order is ``asking | 161 | they are executed does not matter. Any dependence on the order is |
| 162 | for trouble.'' However, the order is predictable: normally, | 162 | asking for trouble. However, the order is predictable: normally, |
| 163 | @var{function} goes at the front of the hook list, so it will be | 163 | @var{function} goes at the front of the hook list, so it will be |
| 164 | executed first (barring another @code{add-hook} call). If the optional | 164 | executed first (barring another @code{add-hook} call). If the |
| 165 | argument @var{append} is non-@code{nil}, the new hook function goes at | 165 | optional argument @var{append} is non-@code{nil}, the new hook |
| 166 | the end of the hook list and will be executed last. | 166 | function goes at the end of the hook list and will be executed last. |
| 167 | 167 | ||
| 168 | @code{add-hook} can handle the cases where @var{hook} is void or its | 168 | @code{add-hook} can handle the cases where @var{hook} is void or its |
| 169 | value is a single function; it sets or changes the value to a list of | 169 | value is a single function; it sets or changes the value to a list of |
| @@ -231,11 +231,11 @@ writing a minor mode, which is often difficult). | |||
| 231 | If the new mode is similar to an old one, it is often unwise to | 231 | If the new mode is similar to an old one, it is often unwise to |
| 232 | modify the old one to serve two purposes, since it may become harder | 232 | modify the old one to serve two purposes, since it may become harder |
| 233 | to use and maintain. Instead, copy and rename an existing major mode | 233 | to use and maintain. Instead, copy and rename an existing major mode |
| 234 | definition and alter the copy---or use @code{define-derived-mode} to | 234 | definition and alter the copy---or use the @code{define-derived-mode} |
| 235 | define a @dfn{derived mode} (@pxref{Derived Modes}). For example, | 235 | macro to define a @dfn{derived mode} (@pxref{Derived Modes}). For |
| 236 | Rmail Edit mode is a major mode that is very similar to Text mode | 236 | example, Rmail Edit mode is a major mode that is very similar to Text |
| 237 | except that it provides two additional commands. Its definition is | 237 | mode except that it provides two additional commands. Its definition |
| 238 | distinct from that of Text mode, but uses that of Text mode. | 238 | is distinct from that of Text mode, but uses that of Text mode. |
| 239 | 239 | ||
| 240 | Even if the new mode is not an obvious derivative of any other mode, | 240 | Even if the new mode is not an obvious derivative of any other mode, |
| 241 | it is convenient to use @code{define-derived-mode} with a @code{nil} | 241 | it is convenient to use @code{define-derived-mode} with a @code{nil} |
| @@ -460,9 +460,9 @@ and then runs the normal hook @code{after-change-major-mode-hook}. | |||
| 460 | The major mode command may start by calling some other major mode | 460 | The major mode command may start by calling some other major mode |
| 461 | command (called the @dfn{parent mode}) and then alter some of its | 461 | command (called the @dfn{parent mode}) and then alter some of its |
| 462 | settings. A mode that does this is called a @dfn{derived mode}. The | 462 | settings. A mode that does this is called a @dfn{derived mode}. The |
| 463 | recommended way to define one is to use @code{define-derived-mode}, | 463 | recommended way to define one is to use the @code{define-derived-mode} |
| 464 | but this is not required. Such a mode should call the parent mode | 464 | macro, but this is not required. Such a mode should call the parent |
| 465 | command inside a @code{delay-mode-hooks} form. (Using | 465 | mode command inside a @code{delay-mode-hooks} form. (Using |
| 466 | @code{define-derived-mode} does this automatically.) @xref{Derived | 466 | @code{define-derived-mode} does this automatically.) @xref{Derived |
| 467 | Modes}, and @ref{Mode Hooks}. | 467 | Modes}, and @ref{Mode Hooks}. |
| 468 | 468 | ||
| @@ -488,6 +488,12 @@ in Funny mode should not inherit Funny mode, in case | |||
| 488 | @code{default-major-mode} is @code{nil}. Modes such as Dired, Rmail, | 488 | @code{default-major-mode} is @code{nil}. Modes such as Dired, Rmail, |
| 489 | and Buffer List use this feature. | 489 | and Buffer List use this feature. |
| 490 | 490 | ||
| 491 | The @code{define-derived-mode} macro automatically marks the derived | ||
| 492 | mode as special if the parent mode is special. The special mode | ||
| 493 | @code{special-mode} provides a convenient parent for other special | ||
| 494 | modes to inherit from; it sets @code{buffer-read-only} to @code{t}, | ||
| 495 | and does nothing else. | ||
| 496 | |||
| 491 | @item | 497 | @item |
| 492 | If you want to make the new mode the default for files with certain | 498 | If you want to make the new mode the default for files with certain |
| 493 | recognizable names, add an element to @code{auto-mode-alist} to select | 499 | recognizable names, add an element to @code{auto-mode-alist} to select |