diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/luat-ini.mkiv | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-ini.mkiv b/Master/texmf-dist/tex/context/base/luat-ini.mkiv index c9d88bf4fcf..a79ef6a02ac 100644 --- a/Master/texmf-dist/tex/context/base/luat-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/luat-ini.mkiv @@ -53,30 +53,6 @@ \ifx\obeyedline \undefined \let\obeyedline \relax \fi \ifx\obeyspaces \undefined \let\obeyspaces \relax \fi \ifx\obeyedspace \undefined \let\obeyedspace \relax \fi -\ifx\outputnewlinechar\undefined \let\outputnewlinechar\relax \fi - -%D A previous version used a bit less code and no catcode table, -%D simply becaus ethey were not around at the time of writing. -% -% we keep it around for archival purposes -% -% \def\obeylualines -% {\obeylines \let\obeyedline \outputnewlinechar -% \obeyspaces \let\obeyedspace\space} -% -% \def\obeyluatokens % todo: make this a proper catcode table, use let's -% {\catcode`\%=12 \catcode`\#=12 -% \catcode`\_=12 \catcode`\^=12 -% \catcode`\&=12 \catcode`\|=12 -% \catcode`\{=12 \catcode`\}=12 -% \catcode`\~=12 \catcode`\$=12 -% \def\\{\string\\}\def\|{\string\|}\def\-{\string\-}% -% \def\({\string\(}\def\){\string\)}\def\{{\string\{}\def\}{\string\}}% -% \def\'{\string\'}\def\"{\string\"}% -% \def\n{\string\n}\def\r{\string\r}\def\f{\string\f}\def\t{\string\t}% -% \def\a{\string\a}\def\b{\string\b}\def\v{\string\v}\def\s{\string\s}% -% \def\1{\string\1}\def\2{\string\2}\def\3{\string\3}\def\4{\string\4}\def\5{\string\5}% -% \def\6{\string\6}\def\7{\string\7}\def\8{\string\8}\def\9{\string\9}\def\0{\string\0}} \let\obeylualines\relax @@ -135,17 +111,20 @@ \csname dodostartnamed#1\v!code\endcsname} \unexpanded\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet - {\scratchcounter\ctxlua{lua.registername("#1","#3")}% - \normalexpanded{\long\edef\csname dodostartnamed#1\v!code\endcsname##1\csname\e!stop#1\v!code\endcsname}% - {\endgroup\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}% - \long\expandafter\def \csname\e!start#1\v!code\endcsname {\dostartnamedluacode{#1}}% - \long\expandafter\edef\csname #1\v!code\endcsname##1{\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}} + {\ifcsname dodostartnamed#1\v!code\endcsname\else + \scratchcounter\ctxlua{lua.registername("#1","#3")}% + \normalexpanded{\long\edef\csname dodostartnamed#1\v!code\endcsname##1\csname\e!stop#1\v!code\endcsname}% + {\endgroup\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}% + \long\expandafter\def \csname\e!start#1\v!code\endcsname {\dostartnamedluacode{#1}}% + \long\expandafter\edef\csname #1\v!code\endcsname##1{\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}% + \fi} %D We predefine a few. +% \definenamedlua[module][module instance] % not needed + \definenamedlua[user] [private user instance] \definenamedlua[third] [third party module instance] -\definenamedlua[module] [module instance] \definenamedlua[isolated][isolated instance] %D In practice this works out as follows: @@ -230,14 +209,33 @@ % tree=true % \stopluaparameterset % -% options=u3d:myset:display:1 +% option=u3d:myset:display:1 % % or: % -% options=\luaparameterset{u3d:myset:display:1}{toolbar=false,tree=true} +% option=\luaparameterset{u3d:myset:display:1}{toolbar=false,tree=true} %D A Handy helper: \def\luaconditional#1{\ifcase#1tru\else fals\fi e} +%D Goodie: +%D +%D \starttyping +%D \ctxluacode{context("%0.5f",1/3)} +%D \stoptyping + +\long\def\ctxluacode + {\begingroup + \obeylualines + \obeyluatokens + \catcode\leftbraceasciicode \plusone + \catcode\rightbraceasciicode\plustwo + \afterassignment\doctxluacode + \scratchtoks=} + +\def\doctxluacode + {\normalexpanded{\endgroup\noexpand\directlua\zerocount\expandafter{\the\scratchtoks}}} + + \protect \endinput |