diff options
Diffstat (limited to 'tex/context/base/luat-ini.mkiv')
-rw-r--r-- | tex/context/base/luat-ini.mkiv | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/tex/context/base/luat-ini.mkiv b/tex/context/base/luat-ini.mkiv index 168b52095..78a324db2 100644 --- a/tex/context/base/luat-ini.mkiv +++ b/tex/context/base/luat-ini.mkiv @@ -34,7 +34,7 @@ % the \type {\normalexpanded} around \type {\directlua}. Something to discuss % in the team. -\unexpanded\def\startlua % \stoplua +\normalprotected\def\startlua % \stoplua {\begingroup \obeylualines \luat_start_lua_indeed} @@ -42,7 +42,7 @@ \def\luat_start_lua_indeed#1\stoplua {\normalexpanded{\endgroup\noexpand\directlua{#1}}} % \zerocount is default -\unexpanded\def\startluacode % \stopluacode +\normalprotected\def\startluacode % \stopluacode {\begingroup \obeylualines \obeyluatokens @@ -77,7 +77,7 @@ \edef\lua_letter_seven {\string\7} \edef\lua_letter_eight {\string\8} \edef\lua_letter_nine {\string\9} \edef\lua_letter_zero {\string\0} -\appendtoks +\everyluacode {% \appendtoks \let\\\lua_letter_backslash \let\|\lua_letter_bar \let\-\lua_letter_dash \let\(\lua_letter_lparent \let\)\lua_letter_rparent @@ -92,13 +92,12 @@ \let\5\lua_letter_five \let\6\lua_letter_six \let\7\lua_letter_seven \let\8\lua_letter_eight \let\9\lua_letter_nine \let\0\lua_letter_zero -\to \everyluacode +} % \to \everyluacode -\unexpanded\def\obeyluatokens +\normalprotected\def\obeyluatokens {\setcatcodetable\luacatcodes \the\everyluacode} - \edef\luamajorversion{\ctxwrite{_MINORVERSION}} \edef\luaminorversion{\ctxwrite{_MAJORVERSION}} @@ -107,35 +106,30 @@ %D %D We provide an interface for defining instances: -\def\s!lua{lua} \def\v!code{code} \def\!!name{name} \def\s!data{data} +\def\s!lua {lua} +\def\s!code {code} +\def\s!data {data} +\def\s!start{start} +\def\s!stop {stop} %D Beware: because \type {\expanded} is een convert command, the error %D message will show \type{<inserted text>} as part of the message. -\installcorenamespace{luacode} +\installsystemnamespace{luacode} -\unexpanded\def\luat_start_named_lua_code#1% +\normalprotected\def\luat_start_named_lua_code#1% {\begingroup \obeylualines \obeyluatokens \csname\??luacode#1\endcsname} -% \unexpanded\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet / we could use numbers instead (more efficient) -% {\ifcsname\??luacode#1\endcsname \else -% \scratchcounter\ctxlua{lua.registername("#1","#3")}% -% \normalexpanded{\xdef\csname\??luacode#1\endcsname##1\csname\e!stop#1\v!code\endcsname}% -% {\noexpand\normalexpanded{\endgroup\noexpand\directlua\the\scratchcounter{_G=protect("#1\s!data")##1}}}% -% \expandafter\edef\csname\e!start#1\v!code\endcsname {\luat_start_named_lua_code{#1}}% -% \expandafter\edef\csname #1\v!code\endcsname##1{\noexpand\directlua\the\scratchcounter{_G=protect("#1\s!data")##1}}% -% \fi} - -\unexpanded\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet / we could use numbers instead (more efficient) +\normalprotected\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet / we could use numbers instead (more efficient) {\ifcsname\??luacode#1\endcsname \else \expandafter\chardef\csname\??luacode:#1\endcsname\ctxlua{lua.registername("#1","#3")}% - \normalexpanded{\xdef\csname\??luacode#1\endcsname##1\csname\e!stop#1\v!code\endcsname}% + \normalexpanded{\xdef\csname\??luacode#1\endcsname##1\csname\s!stop#1\s!code\endcsname}% {\noexpand\normalexpanded{\endgroup\noexpand\directlua\csname\??luacode:#1\endcsname{_G=protect("#1\s!data")##1}}}% - \expandafter\edef\csname\e!start#1\v!code\endcsname {\luat_start_named_lua_code{#1}}% - \expandafter\edef\csname #1\v!code\endcsname##1{\noexpand\directlua\csname\??luacode:#1\endcsname{_G=protect("#1\s!data")##1}}% + \expandafter\edef\csname\s!start#1\s!code\endcsname {\luat_start_named_lua_code{#1}}% + \expandafter\edef\csname #1\s!code\endcsname##1{\noexpand\directlua\csname\??luacode:#1\endcsname{_G=protect("#1\s!data")##1}}% \fi} %D We predefine a few. @@ -221,7 +215,7 @@ %D Experimental: -\unexpanded\def\startluaparameterset[#1]% +\normalprotected\def\startluaparameterset[#1]% {\begingroup \obeylualines \obeyluatokens @@ -260,7 +254,7 @@ %D \ctxluacode{context("%0.5f",1/3)} %D \stoptyping -\unexpanded\def\ctxluacode +\normalprotected\def\ctxluacode {\begingroup \obeylualines \obeyluatokens @@ -289,7 +283,7 @@ % \dorecurse{10000}{\ctxlua{context(" C3 ")}} \page % \stoptext -\installcorenamespace{ctxfunction} +\installsystemnamespace{ctxfunction} \normalprotected\def\startctxfunctiondefinition #1 % {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_definition_indeed{#1}} @@ -297,17 +291,17 @@ % \def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition % {\endgroup\expandafter\edef\csname#1\endcsname{\noexpand\luafunction\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax}} -\installcorenamespace{luafunction} +\installsystemnamespace{luafunction} \def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition {\endgroup \expandafter\chardef\csname\??luafunction#1\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax \expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} -% \unexpanded\def\setctxluafunction#1#2% experiment +% \normalprotected\def\setctxluafunction#1#2% experiment % {\expandafter\chardef\csname#1\endcsname#2\relax} -\unexpanded\def\setctxluafunction#1#2% experiment +\normalprotected\def\setctxluafunction#1#2% experiment {\expandafter\chardef\csname\??luafunction#1\endcsname#2\relax \expandafter\edef\csname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} |