summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltluatex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/base/ltluatex.dtx')
-rw-r--r--macros/latex-dev/base/ltluatex.dtx58
1 files changed, 40 insertions, 18 deletions
diff --git a/macros/latex-dev/base/ltluatex.dtx b/macros/latex-dev/base/ltluatex.dtx
index 258ac48297..18623fd677 100644
--- a/macros/latex-dev/base/ltluatex.dtx
+++ b/macros/latex-dev/base/ltluatex.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2015-2021
+% Copyright (C) 2015-2022
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
@@ -28,7 +28,7 @@
\ProvidesFile{ltluatex.dtx}
%</driver>
%<*tex>
-[2021/10/15 v1.1v
+[2021/12/27 v1.1x
%</tex>
%<plain> LuaTeX support for plain TeX (core)
%<*tex>
@@ -120,6 +120,17 @@
% tables from $1$ so |\luafunction0| is not available).
%
% \noindent
+% \DescribeMacro{\newluacmd}
+% |\newluadef{|\meta{function}|}|\\
+% Like \cs{newluafunction}, but defines the command using \cs{luadef}
+% instead of just assigning an integer.
+%
+% \noindent
+% \DescribeMacro{\newprotectedluacmd}
+% |\newluadef{|\meta{function}|}|\\
+% Like \cs{newluacmd}, but the defined command is not expandable.
+%
+% \noindent
% \DescribeMacro{\newwhatsit}
% |\newwhatsit{|\meta{whatsit}|}|\\
% Defines a custom \cs{whatsit}, indexed from~$1$.
@@ -380,7 +391,7 @@
%
% \endgroup
%
-% \StopEventually{}
+% \MaybeStop{}
%
% \section{Implementation}
%
@@ -722,6 +733,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\newluacmd, \newprotectedluacmd}
+% \changes{v1.1x}{2021/12/27}{Macros added}
+% Additionally two variants are provided to make the passed control
+% sequence call the function directly.
+% \begin{macrocode}
+\def\newluacmd{%
+ \e@alloc\luafunction\luadef
+ \e@alloc@luafunction@count\m@ne\e@alloc@top
+}
+\def\newprotectedluacmd{%
+ \e@alloc\luafunction{\protected\luadef}
+ \e@alloc@luafunction@count\m@ne\e@alloc@top
+}
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Custom whatsits}
%
% \begin{macro}{\newwhatsit}
@@ -1351,6 +1378,8 @@ local callbacktypes = callbacktypes or {
% \changes{v1.1k}{2019/10/02}{mlist\_to\_hlist is \texttt{exclusive}}
% \changes{v1.1l}{2020/02/02}{post\_linebreak\_filter is \texttt{reverselist}}
% \changes{v1.1p}{2020/08/01}{new\_graf is \texttt{exclusive}}
+% \changes{v1.1w}{2021/11/17}{hpack\_quality is \texttt{exclusive}}
+% \changes{v1.1w}{2021/11/17}{vpack\_quality is \texttt{exclusive}}
% \begin{macrocode}
contribute_filter = simple,
buildpage_filter = simple,
@@ -1361,8 +1390,8 @@ local callbacktypes = callbacktypes or {
post_linebreak_filter = reverselist,
hpack_filter = list,
vpack_filter = list,
- hpack_quality = list,
- vpack_quality = list,
+ hpack_quality = exclusive,
+ vpack_quality = exclusive,
pre_output_filter = list,
process_rule = exclusive,
hyphenate = simple,
@@ -1516,11 +1545,11 @@ end
% Handler for |list| callbacks.
% \changes{v1.0k}{2015/12/02}{resolve name and i.description (PHG)}
% \changes{v1.1s}{2020/12/02}{Fix return value of list callbacks}
+% \changes{v1.1w}{2021/11/17}{Never pass on \texttt{true} return values for list callbacks}
% \begin{macrocode}
local function list_handler(name)
return function(head, ...)
local ret
- local alltrue = true
for _,i in ipairs(callbacklist[name]) do
ret = i.func(head, ...)
if ret == false then
@@ -1531,18 +1560,17 @@ local function list_handler(name)
return false
end
if ret ~= true then
- alltrue = false
head = ret
end
end
- return alltrue and true or head
+ return head
end
end
% \end{macrocode}
% Default for user-defined |list| and |reverselist| callbacks without explicit default.
% \begin{macrocode}
-local function list_handler_default()
- return true
+local function list_handler_default(head)
+return head
end
% \end{macrocode}
% Handler for |reverselist| callbacks.
@@ -1551,7 +1579,6 @@ end
local function reverselist_handler(name)
return function(head, ...)
local ret
- local alltrue = true
local callbacks = callbacklist[name]
for i = #callbacks, 1, -1 do
local cb = callbacks[i]
@@ -1564,11 +1591,10 @@ local function reverselist_handler(name)
return false
end
if ret ~= true then
- alltrue = false
head = ret
end
end
- return alltrue and true or head
+ return head
end
end
% \end{macrocode}
@@ -1899,14 +1925,10 @@ callback_register("mlist_to_hlist", function(head, display_type, need_penalties)
if current == false then
flush_list(head)
return nil
- elseif current == true then
- current = head
end
current = call_callback("mlist_to_hlist", current, display_type, need_penalties)
local post = call_callback("post_mlist_to_hlist_filter", current, display_type, need_penalties)
- if post == true then
- return current
- elseif post == false then
+ if post == false then
flush_list(current)
return nil
end