* What is the replacement for the 'stop_run' callback?
@ 2010-10-17 14:06 Tad Ashlock
2010-10-17 16:24 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Tad Ashlock @ 2010-10-17 14:06 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 1582 bytes --]
Hi All,
I'm trying to update a ConTeXt module of mine. It does some data gathering
during the ConTeXt run, and then processes it after the run is complete.
This used to work last year:
local id, err = callback.register('stop_run', new_stop_run_function)
But now err is set to "callback 'stop_run' is frozen (actions performed at
the end of a run)".
I see from the mailing list archive that registering user callbacks was
disallowed in February of this year (2010). I also saw some advice for
installing other new user processing (like 'pre_linebreak_filter'), but no
general advice for adapting to the lack of callbacks. (
http://archive.contextgarden.net/message/20100219.130524.b3857a0a.en.html)
After trying various approaches for a couple of hours, I'm calling for help.
:)
Here's what I ended up with:
\startluacode
print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST1')
local function after_run (head, groupcode)
print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST2')
return head, true
end
nodes.tasks.appendaction('finalizers','after','after_run')
\stopluacode
\starttext
\input knuth
\stoptext
In the output, I see the TEST1 line, but not the TEST2 line.
I don't know what "head" and "groupcode" are, but those seem to be the
expected parameters for an action. I don't know why it returns "head,
true", but that was recommended in a posting (
http://archive.contextgarden.net/message/20100410.005025.76ac9efd.en.html).
I have no idea if 'finalizers' is the right parameter, but I didn't see any
others that looked like it could be synonymous with 'stop_run'.
[-- Attachment #1.2: Type: text/html, Size: 2296 bytes --]
[-- Attachment #2: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: What is the replacement for the 'stop_run' callback?
2010-10-17 14:06 What is the replacement for the 'stop_run' callback? Tad Ashlock
@ 2010-10-17 16:24 ` Hans Hagen
2010-10-19 12:52 ` Tad Ashlock
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2010-10-17 16:24 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 17-10-2010 4:06, Tad Ashlock wrote:
> I'm trying to update a ConTeXt module of mine. It does some data gathering
> during the ConTeXt run, and then processes it after the run is complete.
> This used to work last year:
>
> local id, err = callback.register('stop_run', new_stop_run_function)
>
> But now err is set to "callback 'stop_run' is frozen (actions performed at
> the end of a run)".
indeed
> After trying various approaches for a couple of hours, I'm calling for help.
> :)
> Here's what I ended up with:
>
> \startluacode
> print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST1')
> local function after_run (head, groupcode)
> print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST2')
> return head, true
> end
> nodes.tasks.appendaction('finalizers','after','after_run')
> \stopluacode
> \starttext
> \input knuth
> \stoptext
>
> In the output, I see the TEST1 line, but not the TEST2 line.
because after_run is not seen,
function myprivatenamespace.after_run ...
nodes.tasks.appendaction('finalizers','after','myprivatenamespace.after_run')
> I don't know what "head" and "groupcode" are, but those seem to be the
> expected parameters for an action. I don't know why it returns "head,
> true", but that was recommended in a posting (
> http://archive.contextgarden.net/message/20100410.005025.76ac9efd.en.html).
whatever, it's not the place to hook in your finalizer as there
finalizers are just a specific place in node list processing
> I have no idea if 'finalizers' is the right parameter, but I didn't see any
> others that looked like it could be synonymous with 'stop_run'.
You can use (preferable no messages there):
luatex.registerstopactions(yourfunction)
or for messages:
statistics.register("banner",function() return "text" end)
in this case returning false (or nil) will not show the statistic which
makes sense if there's nothing useful to report.
At some point there will be a formal description for this.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: What is the replacement for the 'stop_run' callback?
2010-10-17 16:24 ` Hans Hagen
@ 2010-10-19 12:52 ` Tad Ashlock
0 siblings, 0 replies; 3+ messages in thread
From: Tad Ashlock @ 2010-10-19 12:52 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 2847 bytes --]
On Sun, Oct 17, 2010 at 10:24, Hans Hagen <pragma@wxs.nl> wrote:
> On 17-10-2010 4:06, Tad Ashlock wrote:
>
> I'm trying to update a ConTeXt module of mine. It does some data
>> gathering
>> during the ConTeXt run, and then processes it after the run is complete.
>> This used to work last year:
>>
>> local id, err = callback.register('stop_run', new_stop_run_function)
>>
>> But now err is set to "callback 'stop_run' is frozen (actions performed at
>> the end of a run)".
>>
>
> indeed
>
>
> After trying various approaches for a couple of hours, I'm calling for
>> help.
>> :)
>>
>
> Here's what I ended up with:
>>
>> \startluacode
>> print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST1')
>> local function after_run (head, groupcode)
>> print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST2')
>> return head, true
>> end
>> nodes.tasks.appendaction('finalizers','after','after_run')
>> \stopluacode
>> \starttext
>> \input knuth
>> \stoptext
>>
>> In the output, I see the TEST1 line, but not the TEST2 line.
>>
>
> because after_run is not seen,
>
> function myprivatenamespace.after_run ...
>
>
> nodes.tasks.appendaction('finalizers','after','myprivatenamespace.after_run')
>
>
> I don't know what "head" and "groupcode" are, but those seem to be the
>> expected parameters for an action. I don't know why it returns "head,
>> true", but that was recommended in a posting (
>> http://archive.contextgarden.net/message/20100410.005025.76ac9efd.en.html
>> ).
>>
>
> whatever, it's not the place to hook in your finalizer as there finalizers
> are just a specific place in node list processing
>
>
> I have no idea if 'finalizers' is the right parameter, but I didn't see
>> any
>> others that looked like it could be synonymous with 'stop_run'.
>>
>
> You can use (preferable no messages there):
>
> luatex.registerstopactions(yourfunction)
>
> or for messages:
>
> statistics.register("banner",function() return "text" end)
>
> in this case returning false (or nil) will not show the statistic which
> makes sense if there's nothing useful to report.
>
> At some point there will be a formal description for this.
>
> Hans
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
> | www.pragma-pod.nl
> -----------------------------------------------------------------
>
Hans,
The registerstopactions() function was the solution I was looking for, but
I've verified that both of the solutions work as expected. I tested them
with both a single ConTeXt source file and a set of files in a Project ->
Product -> Component structure.
I'll wiki this soon.
Thanks,
Tad
[-- Attachment #1.2: Type: text/html, Size: 4550 bytes --]
[-- Attachment #2: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-19 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-17 14:06 What is the replacement for the 'stop_run' callback? Tad Ashlock
2010-10-17 16:24 ` Hans Hagen
2010-10-19 12:52 ` Tad Ashlock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).