[latex3-commits] [git/LaTeX3-latex3-latex2e] newluacmd: Add \newluacmd & \newprotectedluacmd (c1430f3c)
Marcel Fabian Krüger
tex at 2krueger.de
Mon Nov 15 14:11:03 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : newluacmd
Link : https://github.com/latex3/latex2e/commit/c1430f3c1fbf57e383ef00bd51574c43990505ec
>---------------------------------------------------------------
commit c1430f3c1fbf57e383ef00bd51574c43990505ec
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Mon Mar 22 16:11:03 2021 +0100
Add \newluacmd & \newprotectedluacmd
>---------------------------------------------------------------
c1430f3c1fbf57e383ef00bd51574c43990505ec
base/ltluatex.dtx | 27 +++++++++++++++++++++++++++
base/ltoutenc.dtx | 5 ++---
base/ltshipout.dtx | 5 ++---
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/base/ltluatex.dtx b/base/ltluatex.dtx
index 258ac482..91df1068 100644
--- a/base/ltluatex.dtx
+++ b/base/ltluatex.dtx
@@ -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$.
@@ -722,6 +733,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\newluacmd, \newprotectedluacmd}
+% \changes{v?.?}{2021/03/22}{Macros added}
+% Additionally two variants are provided to make the passed control
+% sequence call the function directly.
+% \begin{macrocode}
+\def\newluacmd{%
+ \e at alloc\luafunction\luadef
+ \e at alloc@luafunction at count\m at ne\e at alloc@top
+}
+\def\newprotectedluacmd{%
+ \e at alloc\luafunction{\protected\luadef}
+ \e at alloc@luafunction at count\m at ne\e at alloc@top
+}
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Custom whatsits}
%
% \begin{macro}{\newwhatsit}
diff --git a/base/ltoutenc.dtx b/base/ltoutenc.dtx
index 61ea3818..1a1dd5f9 100644
--- a/base/ltoutenc.dtx
+++ b/base/ltoutenc.dtx
@@ -2949,14 +2949,14 @@
\endgroup
}
\else
- \newluafunction\@remove at tlig@@@@
+ \newprotectedluacmd\@remove at tlig@@@
% \end{macrocode}
% Now we can define the function. Mostly we just have to insert a protected glyph
% node, which is a glyph node with subtype 256. But we have to keep track of the
% current mode to avoid inserting the glyph into a vlist.
% \begin{macrocode}
\now at and@everyjob{\directlua{
- local rawchar_func = token.create'@remove at tlig@@@@'.index
+ local rawchar_func = token.create'@remove at tlig@@@'.index
local forcehmode = tex.forcehmode
local put_next = token.put_next
local glyph_id = node.id'glyph'
@@ -2972,7 +2972,6 @@
n.char = token.scan_int()
return node.write(n)
end
- token.set_lua('@remove at tlig@@@', rawchar_func, 'global', 'protected')
}}
% \end{macrocode}
% Now \verb+\remove at tlig+ can be implemented almost as in XeTeX.
diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx
index 7f6555d1..ff8a7dc5 100644
--- a/base/ltshipout.dtx
+++ b/base/ltshipout.dtx
@@ -734,13 +734,13 @@
% \begin{macrocode}
\sys_if_engine_luatex:TF
{
- \newluafunction \@@_finalize_box:
+ \newprotectedluacmd \@@_finalize_box:
\exp_args:Nx \everyjob {
\exp_not:V \everyjob
\exp_not:N \lua_now:n {
luatexbase.create_callback('pre_shipout_filter', 'list')
local~call, getbox, setbox = luatexbase.call_callback, tex.getbox, tex.setbox~
- lua.get_functions_table()[\the \@@_finalize_box:] = function()
+ lua.get_functions_table()[\the \allocationnumber] = function()
local~result = call('pre_shipout_filter', getbox(\the \l_shipout_box))
if~not (result == true) then~
setbox(\the \l_shipout_box, result~or~nil)
@@ -748,7 +748,6 @@
end
}
}
- \protected \luadef \@@_finalize_box: \the \@@_finalize_box:
} {
\cs_set_eq:NN \@@_finalize_box: \scan_stop:
}
More information about the latex3-commits
mailing list.