ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \processassignmentlist inside a \setup... or related
@ 2021-04-20  2:23 Jairo A. del Rio
  2021-04-20  7:00 ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Jairo A. del Rio @ 2021-04-20  2:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 994 bytes --]

Hi, list! I hope my example shows clearly enough what I intend to do:

\startluacode

userdata = userdata or {}

userdata.mydata = {}


local function registermydata(data,...)

table.insert(userdata.mydata, data)

end


interfaces.implement{

name = "registermydata",

arguments = "2 strings",

actions = registermydata

}

\stopluacode


\unprotect

\def\mysetups[#1]%

{\getdummyparameters[#1]%

\processassignmentlist[#1]\clf_registermydata}

\protect

\starttext

\mysetups[love=nice,hate=awful]%


\dummyparameter{love}


\cldcontext{userdata.mydata[2]}

\stoptext

What I want to know is if there's a less hackish way to pass keys (yep,
only keys, not values) to Lua using \getdummyparameters (actually I'm using
an user-defined \setupsomething, but it's more or less the same) and
\processassignmentlist. Is it possible, for instance, to automatically pass
a key to Lua when it's set in \setupsomething? Thanks in advance.

Jairo

PS: Sorry if I missed something in the test suite again

[-- Attachment #1.2: Type: text/html, Size: 3007 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \processassignmentlist inside a \setup... or related
  2021-04-20  2:23 \processassignmentlist inside a \setup... or related Jairo A. del Rio
@ 2021-04-20  7:00 ` Hans Hagen
  2021-04-20 11:28   ` Jairo A. del Rio
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2021-04-20  7:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jairo A. del Rio

On 4/20/2021 4:23 AM, Jairo A. del Rio wrote:
> Hi, list! I hope my example shows clearly enough what I intend to do:
> 
> \startluacode
> 
> userdata = userdata or {}
> 
> userdata.mydata = {}
> 
> 
> local function registermydata(data,...)
> 
> table.insert(userdata.mydata, data)
> 
> end
> 
> 
> interfaces.implement{
> 
> name = "registermydata",
> 
> arguments = "2 strings",
> 
> actions = registermydata
> 
> }
> 
> \stopluacode
> 
> 
> \unprotect
> 
> \def\mysetups[#1]%
> 
> {\getdummyparameters[#1]%
> 
> \processassignmentlist[#1]\clf_registermydata}
> 
> \protect
> 
> \starttext
> 
> \mysetups[love=nice,hate=awful]%
> 
> 
> \dummyparameter{love}
> 
> 
> \cldcontext{userdata.mydata[2]}
> 
> \stoptext
> 
> What I want to know is if there's a less hackish way to pass keys (yep, 
> only keys, not values) to Lua using \getdummyparameters (actually I'm 
> using an user-defined \setupsomething, but it's more or less the same) 
> and \processassignmentlist. Is it possible, for instance, to 
> automatically pass a key to Lua when it's set in \setupsomething? Thanks 
> in advance.
> 
> Jairo
> 
> PS: Sorry if I missed something in the test suite again
It's probably somewhere ...

\startluacode

userdata = userdata or { }
userdata.mydataA = { }
userdata.mydataB = { }

interfaces.implement {
	name      = "RegisterMyDataA",
     public    = true,
	arguments = { "hash" },
	actions   = function(t)
         for k, v in pairs(t) do
             table.insert(userdata.mydataA,k)
         end
     end,
}

interfaces.implement {
	name      = "RegisterMyDataB",
     public    = true,
	arguments = { "array" },
	actions   = function(t)
         for k, v in ipairs(t) do
             table.insert(userdata.mydataB,string.split(v,"=")[1])
         end
     end,
}

\stopluacode


\unprotect

\protect

\starttext

\RegisterMyDataA[love=nice,hate=awful]%
\RegisterMyDataB[love=nice,hate=awful]%

\cldcontext{userdata.mydataA[2]} % unordered
\cldcontext{userdata.mydataB[1]} % ordered

\stoptext

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \processassignmentlist inside a \setup... or related
  2021-04-20  7:00 ` Hans Hagen
@ 2021-04-20 11:28   ` Jairo A. del Rio
  2021-04-20 11:38     ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Jairo A. del Rio @ 2021-04-20 11:28 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3029 bytes --]

Oh, that's nice, but the \setupsomething part is still missing, i.e. I
still want to be able to invoke \somethingparameter{...}. My question is
about merging two tasks in one in a better way than the one I proposed, if
possible. Thanks for the help.

Jairo

El mar, 20 de abr. de 2021 a la(s) 02:00, Hans Hagen (j.hagen@xs4all.nl)
escribió:

> On 4/20/2021 4:23 AM, Jairo A. del Rio wrote:
> > Hi, list! I hope my example shows clearly enough what I intend to do:
> >
> > \startluacode
> >
> > userdata = userdata or {}
> >
> > userdata.mydata = {}
> >
> >
> > local function registermydata(data,...)
> >
> > table.insert(userdata.mydata, data)
> >
> > end
> >
> >
> > interfaces.implement{
> >
> > name = "registermydata",
> >
> > arguments = "2 strings",
> >
> > actions = registermydata
> >
> > }
> >
> > \stopluacode
> >
> >
> > \unprotect
> >
> > \def\mysetups[#1]%
> >
> > {\getdummyparameters[#1]%
> >
> > \processassignmentlist[#1]\clf_registermydata}
> >
> > \protect
> >
> > \starttext
> >
> > \mysetups[love=nice,hate=awful]%
> >
> >
> > \dummyparameter{love}
> >
> >
> > \cldcontext{userdata.mydata[2]}
> >
> > \stoptext
> >
> > What I want to know is if there's a less hackish way to pass keys (yep,
> > only keys, not values) to Lua using \getdummyparameters (actually I'm
> > using an user-defined \setupsomething, but it's more or less the same)
> > and \processassignmentlist. Is it possible, for instance, to
> > automatically pass a key to Lua when it's set in \setupsomething? Thanks
> > in advance.
> >
> > Jairo
> >
> > PS: Sorry if I missed something in the test suite again
> It's probably somewhere ...
>
> \startluacode
>
> userdata = userdata or { }
> userdata.mydataA = { }
> userdata.mydataB = { }
>
> interfaces.implement {
>         name      = "RegisterMyDataA",
>      public    = true,
>         arguments = { "hash" },
>         actions   = function(t)
>          for k, v in pairs(t) do
>              table.insert(userdata.mydataA,k)
>          end
>      end,
> }
>
> interfaces.implement {
>         name      = "RegisterMyDataB",
>      public    = true,
>         arguments = { "array" },
>         actions   = function(t)
>          for k, v in ipairs(t) do
>              table.insert(userdata.mydataB,string.split(v,"=")[1])
>          end
>      end,
> }
>
> \stopluacode
>
>
> \unprotect
>
> \protect
>
> \starttext
>
> \RegisterMyDataA[love=nice,hate=awful]%
> \RegisterMyDataB[love=nice,hate=awful]%
>
> \cldcontext{userdata.mydataA[2]} % unordered
> \cldcontext{userdata.mydataB[1]} % ordered
>
> \stoptext
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>

[-- Attachment #1.2: Type: text/html, Size: 4123 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: \processassignmentlist inside a \setup... or related
  2021-04-20 11:28   ` Jairo A. del Rio
@ 2021-04-20 11:38     ` Hans Hagen
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2021-04-20 11:38 UTC (permalink / raw)
  To: Jairo A. del Rio; +Cc: mailing list for ConTeXt users

On 4/20/2021 1:28 PM, Jairo A. del Rio wrote:
> Oh, that's nice, but the \setupsomething part is still missing, i.e. I 
> still want to be able to invoke \somethingparameter{...}. My question is 
> about merging two tasks in one in a better way than the one I proposed, 
> if possible. Thanks for the help.

\def\mystuff[#1]%
   {\getdummyparameters{#1]%
    \RegisterMyDataA[#1]}

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-20 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  2:23 \processassignmentlist inside a \setup... or related Jairo A. del Rio
2021-04-20  7:00 ` Hans Hagen
2021-04-20 11:28   ` Jairo A. del Rio
2021-04-20 11:38     ` Hans Hagen

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