diff options
| author | Glenn Morris | 2012-02-01 21:57:26 -0500 |
|---|---|---|
| committer | Glenn Morris | 2012-02-01 21:57:26 -0500 |
| commit | 12f381b73de44148af86efd823ff69c637dedeec (patch) | |
| tree | 45feea574b567912406e1039861c837b392511e8 | |
| parent | 44f9273998bc2b42e2b17b4bb35b4e0f0e1cf27d (diff) | |
| download | emacs-12f381b73de44148af86efd823ff69c637dedeec.tar.gz emacs-12f381b73de44148af86efd823ff69c637dedeec.zip | |
Document change-major-mode-after-body-hook
* doc/lispref/hooks.texi (Standard Hooks):
* doc/lispref/modes.texi (Major Mode Conventions, Mode Hooks):
Document change-major-mode-after-body-hook.
* lisp/subr.el (run-mode-hooks): Doc fix.
* etc/NEWS: Markup
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/hooks.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 27 | ||||
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 10 |
6 files changed, 38 insertions, 13 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 6a8b7750f0b..1ba070dccc0 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-02-02 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * hooks.texi (Standard Hooks): | ||
| 4 | * modes.texi (Major Mode Conventions, Mode Hooks): | ||
| 5 | Document change-major-mode-after-body-hook. | ||
| 6 | |||
| 1 | 2012-02-01 Glenn Morris <rgm@gnu.org> | 7 | 2012-02-01 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * modes.texi (Defining Minor Modes): | 9 | * modes.texi (Defining Minor Modes): |
diff --git a/doc/lispref/hooks.texi b/doc/lispref/hooks.texi index 95655324ab4..b311da66110 100644 --- a/doc/lispref/hooks.texi +++ b/doc/lispref/hooks.texi | |||
| @@ -127,6 +127,9 @@ not exactly a hook, but does a similar job. | |||
| 127 | @xref{Calendar Customizing,,, emacs}. | 127 | @xref{Calendar Customizing,,, emacs}. |
| 128 | @end ifnottex | 128 | @end ifnottex |
| 129 | 129 | ||
| 130 | @item change-major-mode-after-body-hook | ||
| 131 | @xref{Mode Hooks}. | ||
| 132 | |||
| 130 | @item change-major-mode-hook | 133 | @item change-major-mode-hook |
| 131 | @xref{Creating Buffer-Local}. | 134 | @xref{Creating Buffer-Local}. |
| 132 | 135 | ||
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index f8a21e003e0..e142be44e0d 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -468,8 +468,9 @@ other packages would interfere with them. | |||
| 468 | @cindex major mode hook | 468 | @cindex major mode hook |
| 469 | Each major mode should have a normal @dfn{mode hook} named | 469 | Each major mode should have a normal @dfn{mode hook} named |
| 470 | @code{@var{modename}-mode-hook}. The very last thing the major mode command | 470 | @code{@var{modename}-mode-hook}. The very last thing the major mode command |
| 471 | should do is to call @code{run-mode-hooks}. This runs the mode hook, | 471 | should do is to call @code{run-mode-hooks}. This runs the normal |
| 472 | and then runs the normal hook @code{after-change-major-mode-hook}. | 472 | hook @code{change-major-mode-after-body-hook}, the mode hook, |
| 473 | and then the normal hook @code{after-change-major-mode-hook}. | ||
| 473 | @xref{Mode Hooks}. | 474 | @xref{Mode Hooks}. |
| 474 | 475 | ||
| 475 | @item | 476 | @item |
| @@ -939,8 +940,9 @@ before it runs the mode hook variable @code{@var{mode}-hook}. | |||
| 939 | @node Mode Hooks | 940 | @node Mode Hooks |
| 940 | @subsection Mode Hooks | 941 | @subsection Mode Hooks |
| 941 | 942 | ||
| 942 | Every major mode command should finish by running its mode hook and | 943 | Every major mode command should finish by running the mode-independent |
| 943 | the mode-independent normal hook @code{after-change-major-mode-hook}. | 944 | normal hook @code{change-major-mode-after-body-hook}, its mode hook, |
| 945 | and the normal hook @code{after-change-major-mode-hook}. | ||
| 944 | It does this by calling @code{run-mode-hooks}. If the major mode is a | 946 | It does this by calling @code{run-mode-hooks}. If the major mode is a |
| 945 | derived mode, that is if it calls another major mode (the parent mode) | 947 | derived mode, that is if it calls another major mode (the parent mode) |
| 946 | in its body, it should do this inside @code{delay-mode-hooks} so that | 948 | in its body, it should do this inside @code{delay-mode-hooks} so that |
| @@ -949,11 +951,12 @@ call to @code{run-mode-hooks} runs the parent's mode hook too. | |||
| 949 | @xref{Major Mode Conventions}. | 951 | @xref{Major Mode Conventions}. |
| 950 | 952 | ||
| 951 | Emacs versions before Emacs 22 did not have @code{delay-mode-hooks}. | 953 | Emacs versions before Emacs 22 did not have @code{delay-mode-hooks}. |
| 952 | When user-implemented major modes have not been updated to use it, | 954 | Versions before 24 did not have @code{change-major-mode-after-body-hook}. |
| 953 | they won't entirely follow these conventions: they may run the | 955 | When user-implemented major modes do not use @code{run-mode-hooks} and |
| 954 | parent's mode hook too early, or fail to run | 956 | have not been updated to use these newer features, they won't entirely |
| 955 | @code{after-change-major-mode-hook}. If you encounter such a major | 957 | follow these conventions: they may run the parent's mode hook too early, |
| 956 | mode, please correct it to follow these conventions. | 958 | or fail to run @code{after-change-major-mode-hook}. If you encounter |
| 959 | such a major mode, please correct it to follow these conventions. | ||
| 957 | 960 | ||
| 958 | When you defined a major mode using @code{define-derived-mode}, it | 961 | When you defined a major mode using @code{define-derived-mode}, it |
| 959 | automatically makes sure these conventions are followed. If you | 962 | automatically makes sure these conventions are followed. If you |
| @@ -963,6 +966,7 @@ use the following functions to handle these conventions automatically. | |||
| 963 | @defun run-mode-hooks &rest hookvars | 966 | @defun run-mode-hooks &rest hookvars |
| 964 | Major modes should run their mode hook using this function. It is | 967 | Major modes should run their mode hook using this function. It is |
| 965 | similar to @code{run-hooks} (@pxref{Hooks}), but it also runs | 968 | similar to @code{run-hooks} (@pxref{Hooks}), but it also runs |
| 969 | @code{change-major-mode-after-body-hook} and | ||
| 966 | @code{after-change-major-mode-hook}. | 970 | @code{after-change-major-mode-hook}. |
| 967 | 971 | ||
| 968 | When this function is called during the execution of a | 972 | When this function is called during the execution of a |
| @@ -982,6 +986,11 @@ The hooks will actually run during the next call to | |||
| 982 | construct. | 986 | construct. |
| 983 | @end defmac | 987 | @end defmac |
| 984 | 988 | ||
| 989 | @defvar change-major-mode-after-body-hook | ||
| 990 | This is a normal hook run by @code{run-mode-hooks}. It is run before | ||
| 991 | the mode hooks. | ||
| 992 | @end defvar | ||
| 993 | |||
| 985 | @defvar after-change-major-mode-hook | 994 | @defvar after-change-major-mode-hook |
| 986 | This is a normal hook run by @code{run-mode-hooks}. It is run at the | 995 | This is a normal hook run by @code{run-mode-hooks}. It is run at the |
| 987 | very end of every properly-written major mode command. | 996 | very end of every properly-written major mode command. |
| @@ -1287,6 +1287,7 @@ should be derived. | |||
| 1287 | modes, e.g. (add-hook 'prog-mode-hook 'flyspell-prog-mode) to enable | 1287 | modes, e.g. (add-hook 'prog-mode-hook 'flyspell-prog-mode) to enable |
| 1288 | on-the-fly spell checking for comments and strings. | 1288 | on-the-fly spell checking for comments and strings. |
| 1289 | 1289 | ||
| 1290 | +++ | ||
| 1290 | *** New hook `change-major-mode-after-body-hook', run by | 1291 | *** New hook `change-major-mode-after-body-hook', run by |
| 1291 | `run-mode-hooks' just before any other mode hooks. | 1292 | `run-mode-hooks' just before any other mode hooks. |
| 1292 | 1293 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cc6aecd7a26..4290c5e820d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-02-02 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (run-mode-hooks): Doc fix. | ||
| 4 | |||
| 1 | 2012-02-02 Juri Linkov <juri@jurta.org> | 5 | 2012-02-02 Juri Linkov <juri@jurta.org> |
| 2 | 6 | ||
| 3 | * image-mode.el (image-toggle-display-image): Remove tautological | 7 | * image-mode.el (image-toggle-display-image): Remove tautological |
diff --git a/lisp/subr.el b/lisp/subr.el index c9e213c86a0..36bca654208 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1539,10 +1539,12 @@ if it is empty or a duplicate." | |||
| 1539 | 1539 | ||
| 1540 | (defun run-mode-hooks (&rest hooks) | 1540 | (defun run-mode-hooks (&rest hooks) |
| 1541 | "Run mode hooks `delayed-mode-hooks' and HOOKS, or delay HOOKS. | 1541 | "Run mode hooks `delayed-mode-hooks' and HOOKS, or delay HOOKS. |
| 1542 | Execution is delayed if the variable `delay-mode-hooks' is non-nil. | 1542 | If the variable `delay-mode-hooks' is non-nil, does not run any hooks, |
| 1543 | Otherwise, runs the mode hooks and then `after-change-major-mode-hook'. | 1543 | just adds the HOOKS to the list `delayed-mode-hooks'. |
| 1544 | Major mode functions should use this instead of `run-hooks' when running their | 1544 | Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', |
| 1545 | FOO-mode-hook." | 1545 | `delayed-mode-hooks' (in reverse order), HOOKS, and finally |
| 1546 | `after-change-major-mode-hook'. Major mode functions should use | ||
| 1547 | this instead of `run-hooks' when running their FOO-mode-hook." | ||
| 1546 | (if delay-mode-hooks | 1548 | (if delay-mode-hooks |
| 1547 | ;; Delaying case. | 1549 | ;; Delaying case. |
| 1548 | (dolist (hook hooks) | 1550 | (dolist (hook hooks) |