[Dev-luatex] register a callback on macro expansion?

Hans Hagen pragma at wxs.nl
Tue Feb 20 12:56:29 CET 2007


Jjgod Jiang wrote:
> Hi,
>
> 2007/2/20, Hans Hagen <pragma at wxs.nl>:
>> this is state independent, so state 1 should work; indeed the 
>> slunicode lib is there as is lfs
>
> I've tried with
>
> \directlua 0 {
>    function hello(str)
>        tex.print(str)
>    end
> }
>
> \def\hello#1{\directlua 0 {hello("#1")}}
>
> \hello{hi}
> \bye
>
> But only got:
>
> ! LuaTeX error [string "luas[0]"]:1: attempt to index global 'tex' (a 
> nil value
> ).
> \hello #1->\directlua 0 {hello("#1")}
>
> l.9 \hello{hi}
\starttext

\directlua 0 { function hello(str) tex.print(str) end }
\directlua 5 { function hello(str) tex.print(str) end }

\directlua 0 { tex.print("HELLO") }
\directlua 5 { tex.print("HELLO") }

\directlua 0 { hello("HELLO") }
\directlua 5 { hello("HELLO") }

\def\hello#1{\directlua 5 {hello("#1")}}

\hello{HELLO}

\stoptext

works ok here (1 too) so there is another problem; it could be that luatex is not in luatex mode or that somehow the tex table gets messed up 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the dev-luatex mailing list