Usage:
/HOOK event[ pattern] [=
body]
/HOOK [OFF|ON]
Creates a macro which will execute body when event occurs and the event's arguments match the optional pattern. The event may be a single event or a list of events separated by '|'. If omitted, pattern will default to "*".
/hook with no arguments displays the state of the %{hook} flag. /hook with an argument of ON or OFF sets the %{hook} flag, which determines if hooks will execute their associated macros.
The matching style of the hook pattern is determined by %{matching}. This variable is examined when the hook is defined, not when it is executed.
Defining a hook will not replace an existing hook on the same event, but rather creates an additional hook macro on the event. The macro or macros to be executed are chosen by the normal priority rules.
See the section "hooks" for details on hook operation, a list of event names, and examples.
If /hook does not create a new macro, it returns 0. Otherwise, it returns the number of the new macro (useful in /undefn and /edit).
/hook
event[ pattern] [=response]
is equivalent to
/def
-h"event[ pattern]"
[=response]
.
Example:
/hook MAIL = /sh elmwill automatically invoke "elm" to read mail when it arrives.
See: hooks, macros, evaluation, patterns, /def, /unhook