diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-11-05 00:19:30 +0100 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-11-11 15:50:31 +0100 |
commit | d575aeff5dc21fdb66c5f8c589bf5e694d320ea9 (patch) | |
tree | 9faa78006c348531f45281cc22149e960b20604d | |
parent | c1be5706a3752f24ab779f1116b476b206f298cc (diff) | |
download | luatexbase-d575aeff5dc21fdb66c5f8c589bf5e694d320ea9.tar.gz |
make priority_in_callback bhave as the doc says
-rw-r--r-- | luatexbase-mcb.dtx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx index 21786a3..c8c23b0 100644 --- a/luatexbase-mcb.dtx +++ b/luatexbase-mcb.dtx @@ -566,7 +566,7 @@ function add_to_callback (name,func,description,priority) name) return end - if priority_in_callback(name, description) ~= 0 then + if priority_in_callback(name, description) then warning("function '%s' already registered\nin callback '%s'", description, name) end @@ -753,20 +753,20 @@ function priority_in_callback (name, description) if not name or name == "" or not callbacktypes[name] or not description then - return 0 + return false end local l = callbacklist[name] - if not l then return 0 end + if not l then return false end for p, f in pairs(l) do if f.description == description then return p end end - return 0 + return false end % \end{macrocode} % -% Finally, overwrite \code{callback.register} so that bails out in error. +% Finally, overwrite |callback.register| so that bails out in error. % % \begin{macrocode} callback.register = function () @@ -799,11 +799,11 @@ end luatexbase.add_to_callback("hpack_filter", sample, "sample function one", 1) luatexbase.add_to_callback("hpack_filter", sample, "sample function two", 2) luatexbase.add_to_callback("hpack_filter", sample, "sample function three", 1) - texio.write_nl(prio("hpack_filter", "sample function three")) + assert(prio("hpack_filter", "sample function three")) luatexbase.remove_from_callback("hpack_filter", "sample function three") - texio.write_nl(prio("hpack_filter", "sample function three")) + assert(not prio("hpack_filter", "sample function three")) luatexbase.reset_callback("hpack_filter") - texio.write_nl(prio("hpack_filter", "sample function one")) + assert(not prio("hpack_filter", "sample function one")) local function data_one(s) texio.write_nl("I'm data 1 whith argument: "..s) @@ -818,7 +818,6 @@ end return s end ---[[ luatexbase.create_callback("fooback", "data", data_one) luatexbase.call_callback("fooback", "default") luatexbase.add_to_callback("fooback", data_two, "my sample function two", 2) @@ -828,7 +827,6 @@ end luatexbase.call_callback("fooback", "all but three") luatexbase.reset_callback("fooback") luatexbase.call_callback("fooback", "default") - --]] } %</testplain,testlatex> %<testplain>\bye |