aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-02-01 21:57:26 -0500
committerGlenn Morris2012-02-01 21:57:26 -0500
commit12f381b73de44148af86efd823ff69c637dedeec (patch)
tree45feea574b567912406e1039861c837b392511e8
parent44f9273998bc2b42e2b17b4bb35b4e0f0e1cf27d (diff)
downloademacs-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/ChangeLog6
-rw-r--r--doc/lispref/hooks.texi3
-rw-r--r--doc/lispref/modes.texi27
-rw-r--r--etc/NEWS1
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/subr.el10
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 @@
12012-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
12012-02-01 Glenn Morris <rgm@gnu.org> 72012-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
469Each major mode should have a normal @dfn{mode hook} named 469Each 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
471should do is to call @code{run-mode-hooks}. This runs the mode hook, 471should do is to call @code{run-mode-hooks}. This runs the normal
472and then runs the normal hook @code{after-change-major-mode-hook}. 472hook @code{change-major-mode-after-body-hook}, the mode hook,
473and 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
943the mode-independent normal hook @code{after-change-major-mode-hook}. 944normal hook @code{change-major-mode-after-body-hook}, its mode hook,
945and the normal hook @code{after-change-major-mode-hook}.
944It does this by calling @code{run-mode-hooks}. If the major mode is a 946It does this by calling @code{run-mode-hooks}. If the major mode is a
945derived mode, that is if it calls another major mode (the parent mode) 947derived mode, that is if it calls another major mode (the parent mode)
946in its body, it should do this inside @code{delay-mode-hooks} so that 948in 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}.
952When user-implemented major modes have not been updated to use it, 954Versions before 24 did not have @code{change-major-mode-after-body-hook}.
953they won't entirely follow these conventions: they may run the 955When user-implemented major modes do not use @code{run-mode-hooks} and
954parent's mode hook too early, or fail to run 956have 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 957follow these conventions: they may run the parent's mode hook too early,
956mode, please correct it to follow these conventions. 958or fail to run @code{after-change-major-mode-hook}. If you encounter
959such 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
959automatically makes sure these conventions are followed. If you 962automatically 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
964Major modes should run their mode hook using this function. It is 967Major modes should run their mode hook using this function. It is
965similar to @code{run-hooks} (@pxref{Hooks}), but it also runs 968similar 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
968When this function is called during the execution of a 972When this function is called during the execution of a
@@ -982,6 +986,11 @@ The hooks will actually run during the next call to
982construct. 986construct.
983@end defmac 987@end defmac
984 988
989@defvar change-major-mode-after-body-hook
990This is a normal hook run by @code{run-mode-hooks}. It is run before
991the mode hooks.
992@end defvar
993
985@defvar after-change-major-mode-hook 994@defvar after-change-major-mode-hook
986This is a normal hook run by @code{run-mode-hooks}. It is run at the 995This is a normal hook run by @code{run-mode-hooks}. It is run at the
987very end of every properly-written major mode command. 996very end of every properly-written major mode command.
diff --git a/etc/NEWS b/etc/NEWS
index 4aaefe70c4f..0138fa5192e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1287,6 +1287,7 @@ should be derived.
1287modes, e.g. (add-hook 'prog-mode-hook 'flyspell-prog-mode) to enable 1287modes, e.g. (add-hook 'prog-mode-hook 'flyspell-prog-mode) to enable
1288on-the-fly spell checking for comments and strings. 1288on-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 @@
12012-02-02 Glenn Morris <rgm@gnu.org>
2
3 * subr.el (run-mode-hooks): Doc fix.
4
12012-02-02 Juri Linkov <juri@jurta.org> 52012-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.
1542Execution is delayed if the variable `delay-mode-hooks' is non-nil. 1542If the variable `delay-mode-hooks' is non-nil, does not run any hooks,
1543Otherwise, runs the mode hooks and then `after-change-major-mode-hook'. 1543just adds the HOOKS to the list `delayed-mode-hooks'.
1544Major mode functions should use this instead of `run-hooks' when running their 1544Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook',
1545FOO-mode-hook." 1545`delayed-mode-hooks' (in reverse order), HOOKS, and finally
1546`after-change-major-mode-hook'. Major mode functions should use
1547this 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)