ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: callback.register
       [not found] <mailman.450.1270787806.4277.ntg-context@ntg.nl>
@ 2010-04-09  9:59 ` Wolfgang Werners-Lucchini
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Werners-Lucchini @ 2010-04-09  9:59 UTC (permalink / raw)
  To: ntg-context

> > I tried the following
> >
> > --------------------------------------
> > \starttext
> > \startluacode
> > local OldPreLB
> >
> > function MyPreLB(head,gc)
> > ?texio.write_nl("########### Here I am!")
> > ?OldPreLB(head,gc)
> > end
> >
> > OldPreLB = callback.find('pre_linebreak_filter')
> > callback.register('pre_linebreak_filter',MyPreLB)
> > \stopluacode
> >
> > Test
> > \stoptext
> > --------------------------------------
> >
> > but MyPreLB() is not called.
> > What I am doing wrong here?
> 
> Hi Wolfgang,
> 
> see http://www.ntg.nl/pipermail/ntg-context/2010/047018.html
> 
> -- 
> Best regards,
> 
> Li Yanrui (???)

I see!

From the info found there
-----------------------------------------
there are two user hooks:

tasks.appendaction("processors","before","modules.mine.whatever_a")
tasks.appendaction("processors","after","modules.mine.whatever_b")
-----------------------------------------
it is not clear for me how to use this.

So it seems that the luatex reference is useless for a context user.
Is there an other documentation on this?

I have found an other mechanism in 'luat-cbk.lua' which offers a pair 
of functions 'callbacks.push()' and 'callbacks.pop()'. But I have not 
made any attempts to use them. Are they useable or are they disabled 
too?

Wolfgang
___________________________________________________________________________________
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] 7+ messages in thread

* Re: callback.register
  2010-04-09 20:48 ` callback.register Wolfgang Werners-Lucchini
@ 2010-04-10  0:50   ` Li Yanrui (李延瑞)
  0 siblings, 0 replies; 7+ messages in thread
From: Li Yanrui (李延瑞) @ 2010-04-10  0:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/4/10 Wolfgang Werners-Lucchini <wwl@musensturm.de>:
>> there are two user hooks:
>>
>> tasks.appendaction("processors","before","modules.mine.whatever_a")
>> tasks.appendaction("processors","after","modules.mine.whatever_b")
>> -----------------------------------------
>
> My example looks now
>
> \starttext
> \startluacode
> function MyPreLB(head,gc)
>  texio.write("\n")
>  for n in node.traverse(head) do
>    if node.type(n.id) == "glyph" then
>      texio.write(string.char(n.char))
>    elseif node.type(n.id) == "glue" then
>      texio.write(' ')
>    end
>  end
>  texio.write("\n")
>  return head
> end
> tasks.appendaction("processors","before","MyPreLB")
> \stopluacode
> Dies ist ein Test.
> \stoptext
>
> Is it correct to return 'head'?
>

Maybe 'return head, true', because I found a few functions in the beta
do so. Such as 'scripts.preprocess'.

-- 
Best regards,

Li Yanrui (李延瑞)
___________________________________________________________________________________
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] 7+ messages in thread

* Re: callback.register
       [not found] <mailman.1.1270807202.19357.ntg-context@ntg.nl>
@ 2010-04-09 20:48 ` Wolfgang Werners-Lucchini
  2010-04-10  0:50   ` callback.register Li Yanrui (李延瑞)
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Werners-Lucchini @ 2010-04-09 20:48 UTC (permalink / raw)
  To: ntg-context

> there are two user hooks:
> 
> tasks.appendaction("processors","before","modules.mine.whatever_a")
> tasks.appendaction("processors","after","modules.mine.whatever_b")
> -----------------------------------------

My example looks now

\starttext
\startluacode
function MyPreLB(head,gc)
  texio.write("\n")
  for n in node.traverse(head) do
    if node.type(n.id) == "glyph" then
      texio.write(string.char(n.char))
    elseif node.type(n.id) == "glue" then
      texio.write(' ')
    end
  end
  texio.write("\n")
  return head
end
tasks.appendaction("processors","before","MyPreLB")
\stopluacode
Dies ist ein Test.
\stoptext

Is it correct to return 'head'?

Wolfgang
___________________________________________________________________________________
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] 7+ messages in thread

* Re: callback.register
       [not found] <mailman.460.1270827309.4277.ntg-context@ntg.nl>
@ 2010-04-09 18:11 ` Wolfgang Werners-Lucchini
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Werners-Lucchini @ 2010-04-09 18:11 UTC (permalink / raw)
  To: ntg-context

> Hello,
> 
> Here a patch for luat-cbk.lua:
> 
> function callbacks.register(name,func,freeze)
>     if frozen[name] then
>         if trace_callbacks then
>             frozenmessage("registering",name)
>         end
>         return nil, name .. " is frozen"
>     elseif freeze then
>         frozen[name] = (type(freeze) == "string" and freeze) or
> "registered"
>         return register_callback(name,func)
>     else
>         return register_callback(name,func)
>     end
> end
> 
> function callback.register(name,func) -- original
>     if frozen[name] then
>         if trace_callbacks then
>             frozenmessage("registering",name)
>         end
>         return nil, name .. " is frozen"
>     else
>         return register_callback(name,func)
>     end
> end
> 
> (Untested...)
> 
> Cheers, Peter

and

function callbacks.report()
    local list = callback.list()
    for name, func in table.sortedpairs(list) do
        local str = frozen[name]
        if str then
            logs.report("callbacks","%s: %s -> 
%s",state(name),name,str)
        else
            logs.report("callbacks","%s: %s",state(name),name)
        end
    end
end

Wolfgang
___________________________________________________________________________________
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] 7+ messages in thread

* Re: callback.register
  2010-04-08 18:28 callback.register Wolfgang Werners-Lucchini
  2010-04-08 20:20 ` callback.register Peter Münster
@ 2010-04-09  0:30 ` Li Yanrui (李延瑞)
  1 sibling, 0 replies; 7+ messages in thread
From: Li Yanrui (李延瑞) @ 2010-04-09  0:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2010/4/9 Wolfgang Werners-Lucchini <wwl@musensturm.de>:
> Hallo,
>
> I tried the following
>
> --------------------------------------
> \starttext
> \startluacode
> local OldPreLB
>
> function MyPreLB(head,gc)
>  texio.write_nl("########### Here I am!")
>  OldPreLB(head,gc)
> end
>
> OldPreLB = callback.find('pre_linebreak_filter')
> callback.register('pre_linebreak_filter',MyPreLB)
> \stopluacode
>
> Test
> \stoptext
> --------------------------------------
>
> but MyPreLB() is not called.
> What I am doing wrong here?

Hi Wolfgang,

see http://www.ntg.nl/pipermail/ntg-context/2010/047018.html

-- 
Best regards,

Li Yanrui (李延瑞)
___________________________________________________________________________________
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] 7+ messages in thread

* Re: callback.register
  2010-04-08 18:28 callback.register Wolfgang Werners-Lucchini
@ 2010-04-08 20:20 ` Peter Münster
  2010-04-09  0:30 ` callback.register Li Yanrui (李延瑞)
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Münster @ 2010-04-08 20:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Apr 08 2010, Wolfgang Werners-Lucchini wrote:

> [...]
> 
> but MyPreLB() is not called.
> What I am doing wrong here?

Hello Wolfgang,

I don't know, but I've played a bit with your example file:

\starttext
\startluacode
local OldPreLB
function MyPreLB(head,gc)
  tex.print("Here I am!")
  return OldPreLB(head,gc)
end
local id, error = callback.register('pre_linebreak_filter', MyPreLB)
if id == nil then
   tex.print("Error string:", type(error), "\\par")
end
\stopluacode
Problem: callback.register returns nil, but no error message.
\stoptext

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
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] 7+ messages in thread

* callback.register
@ 2010-04-08 18:28 Wolfgang Werners-Lucchini
  2010-04-08 20:20 ` callback.register Peter Münster
  2010-04-09  0:30 ` callback.register Li Yanrui (李延瑞)
  0 siblings, 2 replies; 7+ messages in thread
From: Wolfgang Werners-Lucchini @ 2010-04-08 18:28 UTC (permalink / raw)
  To: ntg-context

Hallo,

I tried the following

--------------------------------------
\starttext
\startluacode
local OldPreLB

function MyPreLB(head,gc)
  texio.write_nl("########### Here I am!")
  OldPreLB(head,gc)
end

OldPreLB = callback.find('pre_linebreak_filter')
callback.register('pre_linebreak_filter',MyPreLB)
\stopluacode

Test
\stoptext
--------------------------------------

but MyPreLB() is not called.
What I am doing wrong here?

Wolfgang
___________________________________________________________________________________
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] 7+ messages in thread

end of thread, other threads:[~2010-04-10  0:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.450.1270787806.4277.ntg-context@ntg.nl>
2010-04-09  9:59 ` callback.register Wolfgang Werners-Lucchini
     [not found] <mailman.1.1270807202.19357.ntg-context@ntg.nl>
2010-04-09 20:48 ` callback.register Wolfgang Werners-Lucchini
2010-04-10  0:50   ` callback.register Li Yanrui (李延瑞)
     [not found] <mailman.460.1270827309.4277.ntg-context@ntg.nl>
2010-04-09 18:11 ` callback.register Wolfgang Werners-Lucchini
2010-04-08 18:28 callback.register Wolfgang Werners-Lucchini
2010-04-08 20:20 ` callback.register Peter Münster
2010-04-09  0:30 ` callback.register Li Yanrui (李延瑞)

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).