Closed eroux closed 10 years ago
Hans changed luatex-mplib.lua
quite a bit since it was last imported -- wouldn’t it make more sense to first try and sync it with current Context? Compared to the font loader it will be bit harder to merge changes because everything is kept in a dtx, but not impossible.
Sure, an update is definitely something to do before any other test or improvements.
I’ve just pulled the changes into luamplib.lua -- there weren’t really any major changes. Anyways I can’t test it because luatex dumps core on the tests:
luatex: ../../../texk/web2c/mplibdir/mp.w:5488: do_set_attr_head: Assertion `A->type==mp_structured' failed.
(./luamplib.lua))Aborted (core dumped)
which resembles this error from an earlier Context: http://www.ntg.nl/pipermail/ntg-context/2012/070567.html and it happens with Context from TL 2013 too, but not with the beta. Maybe a Luatex bug?
Hmm... this doesn't make things easy... is the LuaTeX binary in latest beta the same as in TeXLive 2013? If it's different, maybe we can ask Karl for an update of the binary? Otherwise, if it's the same, Hans should easily know how we could work it around...
Context minimals:
[14:36:10=>phg@phlegethon=> ~] /home/phg/context/tex/texmf-linux-64/bin/luatex --version
This is LuaTeX, Version beta-0.76.0-2013040516 (TeX Live 2013/dev)(rev 4627)
TL pretest:
[14:37:15=>phg@phlegethon=> ~] /home/phg/src/texlive2013/bin/x86_64-linux/luatex --version
This is LuaTeX, Version beta-0.76.0-2013042316 (TeX Live 2013) (rev 4627)
Same revision.
So, at least theorically, there should be a way to make it work... Hans certainly remembers the chages, it seems the best source of information to me... Anyway, if there is no real bug in your code, this shouldn't happen so it's worth reporting in on LuaTeX bugtracker...
False alarm. I just ran a full update of the pretest and now it works.
I created a gist of the style and lua file that I got mplib working with: https://gist.github.com/phi-gamma/5509115
Beware that I had to exclude %
from the mplib catcode table because otherwise I’d get only empty strings on the Lua end. This must be solved otherwise.
I'm not sure having to exlude % is blocking, I think you can go ahead like this in a first time... are Kim's improvements easy to merge with it?
I have imported btex ... etex code to latest luatex-mplib by Hans: http://ktug.org/~nomos/stuffs/luamplib.zip
@dohyunkim Thank you, I will look into it.
@dohyunkim : I've made a first version of the merge here: https://github.com/eroux/luamplib, but I realized I have no test file... can you test it and provide one please?
Hmm. I'm sorry that I have to say it does not work. Anyway, I have just included a test file into http://ktug.org/~nomos/stuffs/luamplib.zip
@dohyunkim I've made some modifications and adapated some code, but it still doesn't work... I have to say it's difficult for me to dig into the code. I can do it but I'm pretty sure you know it quite well already. As you have a github account, what about forking and making a pull request?
I’m on it.
Ok. It almost works with my latest push (see the modified test file for LaTeX), but I now have weird errors in the pdf...
@eroux can you test my master?
@dohyunkim thanks for the patches, just one comment: please next time don’t mix tabs and spaces, it made the patch hard to adapt.
@phi-gamma apart from a few easy to fix typos, it seems to work ok, I'll adapt it, thanx!
I’ve just given you access to my repo, do what you think is best.
Thanks: I did the same changes as on my repo, but more slowly, so I managed to find the bug, it was because I changed
\directlua{
luamplib.settexboxes([===[\unexpanded{#1}]===])
}%
\directlua{
local data = luamplib.gettexboxes([===[\unexpanded{#1}]===])
luamplib.process(data)
}%
to
\directlua{
luamplib.settexboxes([===[\unexpanded{#1}]===])
local data = luamplib.gettexboxes([===[\unexpanded{#1}]===])
luamplib.process(data)
}%
I have to say I don't really understand why it makes such a bug... if you have an explanation I'd be glad to hear it, otherwise I think I'm done for today, you can continue if you want, and even upload on CTAN.
@dohyunkim can you test https://github.com/phi-gamma/luamplib?
The difference is that each call to \directlua
creates a new Lua closure that is compiled and evaluated at the end of the TeX group that is the argument to \directlua
. While the Lua snippet is run, TeX is practically inactive. So you cannot do something like
\let\\=\relax
\directlua{
tex.sprint"\\newcount\\foo"
tex.count.foo = 23
tex.sprint("·",tostring(tex.count.foo),"·")
}
\bye
but TeX has to take over again, even if it looks as though it remains idle:
\let\\=\relax
\directlua{
tex.sprint"\\newcount\\foo"
}
%% end of closure; TeX kicks in and creates the register
\directlua{
tex.count.foo = 23
tex.sprint("·",tostring(tex.count.foo),"·")
}
\bye
Same goes for boxes and other TeX resources.
Ok, I see now... Thank you!
Works great! Thanks a lot. BTW, what is the use of the macro \FV@hack?
I have to say I'm not sure, maybe the code is dead since we changed the environment. By the way, changing it we added a bug: https://github.com/lualatex/luamplib/issues/3. I'll be away this evening and tomorrow, if someone has time to look at this...
See http://tug.org/pipermail/lualatex-dev/2013-April/001504.html