(eplain.info)Hooks
7.6.3 Hooks
-----------
A "hook" is simply a name for a group of actions which is executed in
certain places--presumably when it is most useful to allow customization
or modification. TeX already provides many builtin hooks; for example,
the '\every ...' token lists are all examples of hooks.
Eplain provides several macros for adding actions to hooks. They all
take two arguments: the name of the hook and the new actions.
'hookaction NAME ACTIONS'
'hookappend NAME ACTIONS'
'hookprepend NAME ACTIONS'
Each of these adds ACTIONS to the hook NAME. (Any
previously-defined actions are retained.) NAME is not a control
sequence, but rather the characters of the name.
'hookactiononce NAME \CS'
'\hookactiononce' adds CS to NAME, like the macros above, but first
it adds
\global\let \CS \relax
to the definition of \CS. (This implies \CS must be a true
expandable macro, not a control sequence '\let' to a primitive or
some other such thing.) Thus, \CS is expanded the next time the
hook NAME is run, but it will disappear after that.
The '\global' is useful because '\hookactiononce' is most useful
when the grouping structure of the TeX code could be anything.
Neither this nor the other hook macros do global assignments to the
hook variable itself, so TeX's usual grouping rules apply.
The companion macro to defining hook actions is '\hookrun', for
running them. This takes a single argument, the name of the hook. If no
actions for the hook are defined, no error ensues.
Here is a skeleton of general '\begin' and '\end' macros that run
hooks, and a couple of calls to define actions. The use of
'\hookprepend' for the begin action and '\hookappend' for the end action
ensures that the actions are executed in proper sequence with other
actions (as long as the other actions use '\hookprepend' and
'\hookappend' also).
\def\begin#1{ ... \hookrun{begin} ... }
\def\end#1{ ... \hookrun{end} ... }
\hookprepend{begin}\start_underline
\hookappend{end}\finish_underline
automatically generated by info2www version 1.2.2.9