Skip to content

Commit

Permalink
minor doc corrections and adding a luamcallbacks.get_priority function
Browse files Browse the repository at this point in the history
  • Loading branch information
eroux committed Mar 10, 2009
1 parent 404c353 commit 0d14348
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions luamcallbacks/luamcallbacks.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: luamcallbacks 2009/02/26 v0.9 LuaTeX multiple callbacks package}
\Msg{* Package: luamcallbacks 2009/03/10 v0.91 LuaTeX multiple callbacks package}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax

\preamble
This is a generated file.

Expand All @@ -43,6 +45,8 @@ and the derived files

\endpreamble

\let\MetaPrefix\DoubleperCent

\generate{%
\file{luamcallbacks.drv}{\from{luamcallbacks.dtx}{driver}}%
\usedir{doc/luatex/luamcallbacks}%
Expand All @@ -53,21 +57,6 @@ and the derived files

\def\MetaPrefix{-- }

% we have to redefine the preamble to get the good comments.

\preamble
This is a generated file.

Copyright (C) 2009 by Elie Roux <[email protected]>

This work is under the CC0 license.

This work consists of the main source file luamcallbacks.dtx
and the derived files
luamcallbacks.lua luamcallbacks.drv, luamcallbacks-test.tex,
luamcallbacks.pdf.
\endpreamble

\def\luapostamble{%
\MetaPrefix^^J%
\MetaPrefix\space End of File `\outFileName'.%
Expand Down Expand Up @@ -98,7 +87,7 @@ and the derived files
%<driver>
%<driver>\NeedsTeXFormat{LaTeX2e}
%<driver>\ProvidesPackage{luamcallbacks.sty}
%<driver> [2009/02/26 v0.9 LuaTeX multiple callbacks package]
%<driver> [2009/03/10 v0.91 LuaTeX multiple callbacks package]
%<driver>
% \fi
%<*driver>
Expand Down Expand Up @@ -132,7 +121,7 @@ and the derived files
% \GetFileInfo{luamcallbacks.drv}
%
% \title{The \textsf{luamcallbacks} package}
% \date{2009/02/26 v0.9}
% \date{2009/03/10 v0.91}
% \author{Elie Roux \\ \texttt{[email protected]}}
%
% \maketitle
Expand All @@ -152,7 +141,7 @@ and the derived files
%
%The functions are called in a certain order, and when a package registers a callback it can assign a priority to its function. Conflicts can still remain even with the priority mechanism, for example in the case where two packages want to have the highest priority. In these cases the packages have to solve the conflicts themselves.
%
% This package contains only a \texttt{.lua} file, that can be called by another lua script. For example, this script is called in \textsc{luatextra}.
% This package contains only a \texttt{.lua} file, that can be called by another lua script. For example, this script is called in \textsf{luatextra}.
%
%\subsubsection{Limitations}
%
Expand Down Expand Up @@ -181,8 +170,8 @@ luamcallbacks = { }

luamcallbacks.module = {
name = "luamcallbacks",
version = 0.9,
date = "2009/03/06",
version = 0.91,
date = "2009/03/10",
description = "Module to register several functions in a callback.",
author = "Hans Hagen & Elie Roux",
copyright = "Hans Hagen & Elie Roux",
Expand Down Expand Up @@ -322,7 +311,6 @@ function luamcallbacks.add (name,func,description,priority)
name))
return
end

if not description or description == "" then
luamcallbacks.error(
format("unable to add function to '%s', no proper description passed",
Expand Down Expand Up @@ -365,6 +353,30 @@ function luamcallbacks.add (name,func,description,priority)
description,priority,name))
end

% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{luamcallbacks.get priority}
%
% This function tells if a function has already been registered in a callback, and gives its current priority. The arguments are the name of the callback and the description of the function. If it has already been registered, it gives its priority, and if not it returns false.
%
% \begin{macrocode}

function luamcallbacks.get_priority (name, description)
if not name or name == "" or not callbacktypes[name] or not description then
return false
end
local l = luamcallbacks.callbacklist[name]
if not l then return false end
for p, f in pairs(l) do
if f.description == description then
return p
end
end
return false
end

% \end{macrocode}
%
% \end{macro}
Expand Down Expand Up @@ -558,6 +570,7 @@ end
callback.add = luamcallbacks.add
callback.remove = luamcallbacks.remove
callback.reset = luamcallbacks.reset
callback.get_priority = luamcallbacks.get_priority

callback.register = function (...)
luamcallbacks.error("function callback.register has been deleted by luamcallbacks, please use callback.add instead.")
Expand Down

0 comments on commit 0d14348

Please sign in to comment.