From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/62734 Path: news.gmane.org!not-for-mail From: Tad Ashlock Newsgroups: gmane.comp.tex.context Subject: Re: What is the replacement for the 'stop_run' callback? Date: Tue, 19 Oct 2010 06:52:12 -0600 Message-ID: References: <4CBB2328.8040509@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1156723636==" X-Trace: dough.gmane.org 1287492758 12270 80.91.229.12 (19 Oct 2010 12:52:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 19 Oct 2010 12:52:38 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Oct 19 14:52:36 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P8BgC-0002jl-7s for gctc-ntg-context-518@m.gmane.org; Tue, 19 Oct 2010 14:52:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A76F2CA702; Tue, 19 Oct 2010 14:52:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4FWT6q8VlwY4; Tue, 19 Oct 2010 14:52:30 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1F4B6CA737; Tue, 19 Oct 2010 14:52:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 58BECCA737 for ; Tue, 19 Oct 2010 14:52:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id JY4-e0Ht7umR for ; Tue, 19 Oct 2010 14:52:17 +0200 (CEST) Original-Received: from filter1-nij.mf.surf.net (filter1-nij.mf.surf.net [195.169.124.152]) by balder.ntg.nl (Postfix) with ESMTP id 25E1FCA702 for ; Tue, 19 Oct 2010 14:52:17 +0200 (CEST) Original-Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) by filter1-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o9JCqDa3006561 for ; Tue, 19 Oct 2010 14:52:16 +0200 Original-Received: by wwa36 with SMTP id 36so1611637wwa.2 for ; Tue, 19 Oct 2010 05:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=rzYiMg02M2G5icyitCd73AGrfzTV2WN91QHoohrkkMU=; b=A5qTr8XCzW9orSd7C1tCWaQfeifk5HseNy+Sn9ob9Fl/j6jiQi1n/sBtWug6za0swP 8wqLWsAhvV9D+u2qV/4RM79po4dbL49tUAQa/R01lZv4MlGkHNSp4LrMoKVtmb5xbRpz yoo1RD1UpCU2Yh5d5DX6XcylTTj69+stX9GUA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=T8fdt8fOJmQjYaly8WWrA8I95AQMJKJosHsA0v5bR9Od0EKqY+d+qXE72f8Jf97wc7 kySzV03dIYkvJgAWznS+YZDsX8VTUZkx3NB33XnyAkDrlvkqzlj44z7HDUXtsH4tAJZa faPOYwr5jEr7JwcCgtJEiQ+rU9hNOMeOWd1oY= Original-Received: by 10.227.135.203 with SMTP id o11mr5974089wbt.162.1287492732757; Tue, 19 Oct 2010 05:52:12 -0700 (PDT) Original-Received: by 10.227.127.81 with HTTP; Tue, 19 Oct 2010 05:52:12 -0700 (PDT) In-Reply-To: <4CBB2328.8040509@wxs.nl> X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=74.125.82.45; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 07DkAQde6 - d026b7c361f2 - 20101019 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.152 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:62734 Archived-At: --===============1156723636== Content-Type: multipart/alternative; boundary=001636832fe6fca8760492f7c216 --001636832fe6fca8760492f7c216 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Oct 17, 2010 at 10:24, Hans Hagen 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 --001636832fe6fca8760492f7c216 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Sun, Oct 17, 2010 at 10:24, Hans Hage= n <pragma@wxs.nl&= gt; wrote:
On 17-10-2010 4:06, Tad Ashlock wrote:

I'm trying to update a ConTeXt module of mine. =A0It does some data gat= hering
during the ConTeXt run, and then processes it after the run is complete. =A0This used to work last year:

local id, err =3D callback.register('stop_run', new_stop_run_functi= on)

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)
=A0 =A0 print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST2')
=A0 =A0 return head, true
end
nodes.tasks.appendaction('finalizers','after','after_ru= n')
\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','myprivat= enamespace.after_run')


I don't know what "head" and "groupcode" are, but t= hose seem to be the
expected parameters for an action. =A0I don't know why it returns "= ;head,
true", but that was recommended in a posting (
http://archive.contextgarden.net/message/201004= 10.005025.76ac9efd.en.html).

whatever, it's not the place to hook in your finalizer as there finaliz= ers are just a specific place in node list processing


I have no idea if 'finalizers' is the right parameter, but I didn&#= 39;t see any
others that looked like it could be synonymous with 'stop_run'.

You can use (preferable no messages there):

=A0luatex.registerstopactions(yourfunction)

or for messages:

=A0statistics.register("banner",function() return "text&quo= t; end)

in this case returning false (or nil) will not show the statistic which mak= es sense if there's nothing useful to report.

At some point there will be a formal description for this.

Hans

-----------------------------------------------------------------
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0Hans Hagen | PRAGMA ADE
=A0 =A0 =A0 =A0 =A0 =A0 =A0Ridderstraat 27 | 8061 GH Hasselt | The Netherl= ands
=A0 =A0tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 | www= .pragma-pod.nl
-----------------------------------------------------------------

Hans,

The registerstopactions() functi= on was the solution I was looking for, but I've verified that both of t= he solutions work as expected.=A0 I tested them with both a single ConTeXt = source file and a set of files in a Project -> Product -> Component s= tructure.

I'll wiki this soon.

Thanks,
Tad
--001636832fe6fca8760492f7c216-- --===============1156723636== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1156723636==--