diff options
| author | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-29 15:07:49 +0100 | 
|---|---|---|
| committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-29 15:07:49 +0100 | 
| commit | 84473fa4bd42deecedd6e8e5befc8a0174f0f1b8 (patch) | |
| tree | cf9abe604e20f452dd19659915931039d8cdc391 | |
| parent | d6cc5e4f2097aae25c013efa73c64033566529f6 (diff) | |
| download | luatexbase-84473fa4bd42deecedd6e8e5befc8a0174f0f1b8.tar.gz | |
[mcb] implement callback_descriptions()
Addresses https://github.com/lualatex/luatexbase/issues/17
| -rw-r--r-- | luatexbase-mcb.dtx | 33 | 
1 files changed, 33 insertions, 0 deletions
diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx index 557f41d..532cfbb 100644 --- a/luatexbase-mcb.dtx +++ b/luatexbase-mcb.dtx @@ -925,6 +925,39 @@ luatexbase.is_active_callback = function (name, description)  end  %    \end{macrocode}  % +%    |callback_descriptions| returns a table containing all +%    descriptions of the functions registered for a given callback in +%    the order of their priority. +% +%    The function raises an error if the callback name is missing or +%    invalid. +%    If there is no function registered for the callback, an empty +%    table is returned. +% +%    \begin{macrocode} +--- string -> string list option +luatexbase.callback_descriptions = function (name) +    if not name then +        err ("unable to check for callback:\nno proper name passed") +        return +    elseif not callbacktypes [name] then +        err ("unable to check for callback %q:\nis not a valid callback", name) +        return +    end +    local lst        = callbacklist [name] +    local registered = { } +    if lst then +        for i = 1, #lst do +            local itm = lst [i] +            if i then +                registered [i] = itm.description +            end +        end +    end +    return registered +end +%    \end{macrocode} +%  %    That's all folks!  %  %    \begin{macrocode}  | 
