diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-02-16 10:59:14 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-02-16 10:59:14 +0100 |
commit | 8e11d447440b44990432ac838953a8cde4ef914f (patch) | |
tree | f30b2ff2d8a10f1aff50e1522d968618a97f067c /doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex | |
parent | 43fc66771a0c9d27cc0b7fe7a69392ea313bd0ca (diff) | |
download | context-8e11d447440b44990432ac838953a8cde4ef914f.tar.gz |
2020-02-11 16:39:00
Diffstat (limited to 'doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex')
-rw-r--r-- | doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex b/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex index e713d13c3..e3e2a91e1 100644 --- a/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex +++ b/doc/context/sources/general/manuals/luametatex/luametatex-callbacks.tex @@ -13,6 +13,7 @@ \libindex{register} \libindex{list} \libindex{find} +\libindex{known} This library has functions that register, find and list callbacks. Callbacks are \LUA\ functions that are called in well defined places. There are two kind of @@ -28,18 +29,14 @@ but in the end might not give the user the expected outcome. The first thing you need to do is registering a callback: \startfunctioncall -id, error = - callback.register(<string> callback_name, <function> func) -id, error = - callback.register(<string> callback_name, nil) -id, error = - callback.register(<string> callback_name, false) +id = callback.register(<string> callback_name, <function> func) +id = callback.register(<string> callback_name, nil) +id = callback.register(<string> callback_name, false) \stopfunctioncall Here the \syntax {callback_name} is a predefined callback name, see below. The function returns the internal \type {id} of the callback or \type {nil}, if the -callback could not be registered. In the latter case, \type {error} contains an -error message, otherwise it is \type {nil}. +callback could not be registered. \LUATEX\ internalizes the callback function in such a way that it does not matter if you redefine a function accidentally. @@ -65,7 +62,12 @@ The keys in the table are the known callback names, the value is a boolean where <function> f = callback.find(callback_name) \stopfunctioncall -If the callback is not set, \type {find} returns \type {nil}. +If the callback is not set, \type {find} returns \type {nil}. The \type {known} +function can be used to check if a callback is supported. + +\startfunctioncall +if callback.known("foo") then ... end +\stopfunctioncall \stopsection |