# [Dev-luatex] \lastnodetype not working as expected in LuaTeX

Hans Hagen pragma at wxs.nl
Mon Jun 11 18:55:07 CEST 2012

On 11-6-2012 17:43, Frank Mittelbach wrote:
> Hans,
>
> my fluency in the linebreak algorithm is a little bit rusty. Are you
> saying that there are other points and stuff in that space that is not
> updated or more on the page builder side of the house?

More in the pagebuilder area where we have this insert stuff (which for
that reason I mostly left for the future). In your case setting the
prevdepth and prevgraf is indeed needed. Actually, you need:

\def\partest {%
\directlua {%
tex.nest[tex.nest.level].prevgraf = 1
tex.nest[tex.nest.level].prevdepth = h.depth
return h
end
callback.register("linebreak_filter", hpackparagraph)
}%
\par
}

btw, Internally the linebreaker is somewhat complicated by the fact that
hz and protrusion play a role. I have a (lua) parbuilder prototype that
gets rid of a lot of that code but Harmut needs time to implement a few
things in the backend (will happen later this year) and that in turn
will make the parbuilder cleaner. We also want systematic usage of
left/rightskip nodes in broken lines so that we can have a more
predictable model of a broken line.

> Or asked differently is there more that needs updating to make my little
> example work, and if so could that be already done through a workaround
> like I did with
>
>
> or would it absolutely need fixes in the program itself?

Sort of. The returned -1 is now a signal that prevdepth has not been set
and that is not something deliberate.

However, the fact that you need to set prevdepth and prefgraf (maybe
more) explicitly gives the possibility to manipulate those depth and
graf parameters. So, in any code that uses the callback one needs to
take care of these variables anyway.

Hans

p.s I remember that there has been some fixes to lastnode(type) so it
might as well that at that time some buglet crept in.

-----------------------------------------------------------------