[luatex] multiple callbacks

Hans Hagen pragma at wxs.nl
Sun Jan 4 23:50:06 CET 2009


Elie Roux wrote:
> Hans Hagen a écrit :
>> i hope that this explains it a bit
> 
> It does. I think there was a problem of vocabulary (for me)...  I just 
> find it sad that there is no integrated solution, but if it's your 
> choice... If I come up with these files, where should I send them? To 
> the LuaTeX team, the TeXLive team, the CTAN?

normally it becomes a ctan package (and gets proper entries in the 
database then)

if your solution is plain:

tex/generic/elieroux/<yourfiles>

if you have specific code for latex

tex/latex/elieroux/<yourfiles>

and if you ave fonts or so, they go to the fonts subtree; documentation 
has it sown place (and is often optional in tex installations)

if you want your code to work with latex as well, you should probably 
coordinate with Heiko in order to avoid conflicts; on the other hand. if 
you're the first you might influence the standard way of dealing with 
this kind of things in latex

if you want your code to work with context, well then i have to give you 
the appropriate initialization call (one liner) but it depends omn what 
teh code does which/where stuff gets hooked into

actually, that is one of the main issues: you have to decide where you 
want to hook in your code; say that you inject glue between glyphs 
nodes, then it might be that later calls cannot handle this (i.e. don't 
expect this); if you use attributes as signals, then you need to make 
sure that you use a number that is not taken; this is why you need too 
coordinate this at the macro package level

i must admit that for context i haven't documented such user extensions 
yet (apart from articles that illustrate how to do it)

> Sorry to ask all these questions, but I think it's an important issue, 
> and even though I'm not a TeX guru I'd like to do something to address it.

no problem at all asking questions

in fact, the problem that you bring up is not new and is always occuring 
when new functionaity shows up; take for instance fonts in xetex: xetex 
only provides a way to load fonts and control features, but someone else 
than the author has to provide the embedding in macro package font 
mechanisms; as a result, for latex there is a dedicated package that 
deals with it

attached is another example of an implementation, the tex file produces 
(in context, but it should wotk everywhere); this time a function gets a 
descriptions so that we can remove it too

creating callback list 'lists'
inserting function 'my example function one' at position 1 in 'lists'
inserting function 'my example function two' at position 2 in 'lists'
inserting function 'my example function three' at position 1 in 'lists'
callbacktest   : Test 1
No, I'm number 1
I'm number 1
I'm number 2
inserting function 'an example function' at position 4 in 'lists'
callbacktest   : Test 2
No, I'm number 1
I'm number 1
I'm number 2
This is my function
removing function 'an example function' from 'lists'
callbacktest   : Test 3
No, I'm number 1
I'm number 1
I'm number 2
resetting callback list 'lists'
callbacktest   : Test 4

you can use this stuff (for instance) like:

function MyNameSpace.MyStart()
     callback.add("lists","an example function",whatever)
end

function MyNameSpace.MyStop()
     callback.remove("lists","an example function")
end

and then in your tex style:

\def\MyStart{\directlua0{MyNameSpace.MyStart()}}
\def\MyStop {\par\directlua0{MyNameSpace.MyStop()}}

there is no need to 'reset' the whole callback, esp since one does not 
know what other code is active

now, this file can go into /tex/generic/luatex/examples but that is no 
guarantee that everyone will use it -)

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
-----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: callbacks-1.tex
Type: text/x-tex
Size: 1315 bytes
Desc: not available
Url : http://tug.org/pipermail/luatex/attachments/20090104/a1c43c55/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: callbacks-1.lua
Type: text/x-lua
Size: 3755 bytes
Desc: not available
Url : http://tug.org/pipermail/luatex/attachments/20090104/a1c43c55/attachment-0003.bin 


More information about the luatex mailing list