[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

23.2.7 Mode Hooks

Every major mode function should finish by running its mode hook and the mode-independent normal hook after-change-major-mode-hook. It does this by calling run-mode-hooks. If the major mode is a derived mode, that is if it calls another major mode (the parent mode) in its body, it should do this inside delay-mode-hooks so that the parent won't run these hooks itself. Instead, the derived mode's call to run-mode-hooks runs the parent's mode hook too. Voir la section Major Mode Conventions.

Emacs versions before Emacs 22 did not have delay-mode-hooks. When user-implemented major modes have not been updated to use it, they won't entirely follow these conventions: they may run the parent's mode hook too early, or fail to run after-change-major-mode-hook. If you encounter such a major mode, please correct it to follow these conventions.

When you defined a major mode using define-derived-mode, it automatically makes sure these conventions are followed. If you define a major mode “by hand,” not using define-derived-mode, use the following functions to handle these conventions automatically.

Function: run-mode-hooks &rest hookvars

Major modes should run their mode hook using this function. It is similar to run-hooks (voir la section Hooks), but it also runs after-change-major-mode-hook.

When this function is called during the execution of a delay-mode-hooks form, it does not run the hooks immediately. Instead, it arranges for the next call to run-mode-hooks to run them.

Macro: delay-mode-hooks body…

When one major mode command calls another, it should do so inside of delay-mode-hooks.

This macro executes body, but tells all run-mode-hooks calls during the execution of body to delay running their hooks. The hooks will actually run during the next call to run-mode-hooks after the end of the delay-mode-hooks construct.

Variable: after-change-major-mode-hook

This is a normal hook run by run-mode-hooks. It is run at the very end of every properly-written major mode function.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.