Hi,

\installcommandhandler nicely provides (among others) \define<name> and \setup<name> commands. Thus it is easy to provide a key with \setup...[key=value] and to read the value of such a key with \<name>parameter{key}.

My question is: How do I read the value of a key defined with \setup...[key=value] on the lua side? If I use
  context.<name>parameter("key")
then the value of key is printed directly. I want to be able to read that value and use it in lua with something like
  myvariable = context.?whatfunction?("key")

Here is some example code:

\unprotect

\startluacode
  function myfun(parameters,content)
    context("From lua: Parameters: ")
    context(parameters)
    context.elemparameter("gkey") -- directly prints the parameter
    context.par()
  end
\stopluacode

\installnamespace{elem}
\installcommandhandler \????elem {elem} \????elem
\appendtoks
  \setuevalue{\currentelem}{\elem_cmd{\currentelem}}%
\to \everydefineelem

\unexpanded\def\elem_cmd#environment{%
  \edef\currentelem{#environment}%
  \dosingleempty\elem_cmd_parameters}

\def\elem_cmd_parameters[#parameters]#content{%
  \setupcurrentelem[#parameters]
  From \TeX\: Parameters: key=\elemparameter{key}, gkey=\elemparameter{gkey}\par
  \ctxlua{myfun(\!!bs#parameters\!!es,\!!bs\normalunexpanded{#content}\!!es)}
}

\defineelem[base]
\setupelem[gkey=gval]

\protect

\starttext

\base[key=val]{Hello}

\stoptext

Thank you for any feedback,

Christoph Reller