From ca07dd609c306a6448ec301168a87df28aa250f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 5 Nov 2010 18:56:02 +0100 Subject: Fix listhandler again. --- luatexbase-mcb.dtx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'luatexbase-mcb.dtx') diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx index 39551eb..9af132f 100644 --- a/luatexbase-mcb.dtx +++ b/luatexbase-mcb.dtx @@ -165,15 +165,16 @@ See source file '\inFileName' for details. % (possibly modified): the functions are called in order, and each is % passed the return value of the previous (and the other arguments % untouched, if any). The return value is that of the last function; -% \item[list] is for functions taking the head of a node list as their first -% argument (and possibly other arguments) and returning either a modified -% node list or |true| or |false|. If a function returns a node -% list, then this node list is passed as the first argument to the next -% function, along with the original remaining arguments; if it returns -% |true|, the original node list is passed to the next function; if it -% returns false, then no the other functions are \emph{not} called, a -% warning is issued and |false| is immediately returned. Otherwise, the -% return value of the last function is returned. +% \item[list] is a specialized variant of \emph{data} for functions +% filtering node lists. Such functions may return either the head of a +% modified node list, or the boolean values |true| or |false|. The +% functions are chained the same way as for \emph{data} except that for +% the following. If +% one function returns |false|, then |false| is immediately return and the +% following functions are \emph{not} called. If one function returns +% |true|, then the same head is passed to the next function. If all +% functions return |true|, then |true| is returned, otherwise the return +% value of the last function not returning |true| is used. % \item[first] is for functions with more complex signatures; functions in % this type of callback are \emph{not} combined: only the first one % (according to priorities) is executed. @@ -512,6 +513,7 @@ end local function listhandler (name) return function(head,...) local ret + local alltrue = true for _, f in ipairs(callbacklist[name]) do ret = f.func(head, ...) if ret == false then @@ -520,10 +522,11 @@ local function listhandler (name) break end if ret ~= true then + alltrue = false head = ret end end - return ret + return alltrue and true or head end end % \end{macrocode} -- cgit v1.2.3