ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: ntg-context@ntg.nl
Subject: Re: How to get parameters in lua
Date: Sun, 21 Sep 2014 13:04:20 +0200	[thread overview]
Message-ID: <541EB0B4.7040502@wxs.nl> (raw)
In-Reply-To: <CAO8LnPH21ssKQE868ORAy9f-_YmVVTo08b7jT3J_duoh5sXE5A@mail.gmail.com>

On 9/20/2014 2:45 PM, Christoph Reller wrote:
> Two general questions arise (if your permit):
>
> 1. Where are the key-value pairs stored?
> In your first solution you handle the key setting by explicitly calling
> lua on every \setup<name> call.  It seems that all key-value pairs (that
> are set with \installcommandhandler-generated \setup<name>) are stored
> on the TeX side and not on the lua side.  Is this correct?

yes and getting the macro meaning at the lua end is not efficient as it 
is tokenized

> 2. Calling \ctxlua from lua.
> I was tempted to add another level of indirection to your second (the
> "synchronize") solution.  I.e: in the lua code (in a separate lua file
> to avoid the do ... end introduced by \startluacode .... \stopluacode) I
> have:
>
> n = ""
> v = ""
> function getkey(name,value)
>     n = name
>     v = value
> end
> function myfun(parameters,content)
>     context([[\ctxlua{getkey("gkey","\elemparameter{gkey}")}]])
>     context(" name=")
>     context(n)
>     context(", value=")
>     context(v)
> end
>
> The above does not work because the value obtained "lags behind", i.e.
> initially v will be "", on the second call v will have the value of the
> first \setupelem[gkey=gval], and so on.  I guess this lag is due to the
> way TeX and lua communicate to each other?

indeed, all printed to tex is injected into the input after the lua call 
ends

> A small question: What do you mean by "there is no grouping in lua"?

\bgroup
   ... some assignment at the tex end
   ... followed by setting it in lua
\bgroup

... forgotten at the tex end
... still set at the lua end

> Thank you anyway for your valuable input.
>
> Regards, Christoph
>
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           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
___________________________________________________________________________________


  reply	other threads:[~2014-09-21 11:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-20 12:45 Christoph Reller
2014-09-21 11:04 ` Hans Hagen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-09-19  7:30 Christoph Reller
2014-09-19  8:03 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=541EB0B4.7040502@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).