[Dev-luatex] tex.currentgrouplevel

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Fri Aug 22 09:53:47 CEST 2008


Hello, 

> What one would need is something like a unique group _id_, and a means
> to check whether a certain group id is dead (the group has ended) or
> not.  Something like that.

Maybe a callback could be created:

	function group_callback(type, where)

where "type" would denote if the group was opened/closed using
\begingroup/
\endgroup or { }, and "where" would be "before_begin", "after_begin",
"before_end", "after_end", so code could be executed inside and outside
the group. This callback could then manage group_ids as well as a stack
with all living groups:

	\begingroup (id 1 => stack: 1)
	  \begingroup (id 2 => stack: 1 2)
	  \endgroup (stack: 1)
	\endgroup (stack: empty)
	\begingroup (id 3 => stack: 3)
	...

Also, with this callback, one could create a multi-token aftergroup
(since
the \endgroup would already have been consumed, anything printed to TeX
would be inserted after the end of the group):

	function group_callback(type, where)
	  if where == "before_end" then
	    -- Assume there is a toks register \aftergroupToks
	    tex.sprint(tex.toks["aftergroupToks"])
	  end
	end

Example:

	\begingroup
	  \aftergroupToks={\foo\bar}
	\endgroup
	% Now \foo\bar would be inserted here

Of course, catcodes would be reassigned. Maybe not what is desired.


> David Kastrup

Jonathan



More information about the dev-luatex mailing list