From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/110981 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Jairo A. del Rio" Newsgroups: gmane.comp.tex.context Subject: Issue with \handletokens\with and Lua-defined macros Date: Mon, 29 Mar 2021 03:54:06 -0500 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7590042101787181593==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7440"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Mar 29 10:54:53 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQnfe-0001aW-Nm for gctc-ntg-context-518@m.gmane-mx.org; Mon, 29 Mar 2021 10:54:50 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 05EFB281F43; Mon, 29 Mar 2021 10:54:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id djAwAyqV1AIZ; Mon, 29 Mar 2021 10:54:20 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0942E281F39; Mon, 29 Mar 2021 10:54:20 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 011DD281F37 for ; Mon, 29 Mar 2021 10:54:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lxaOCDGYPmBV for ; Mon, 29 Mar 2021 10:54:18 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.54; helo=mail-wr1-f54.google.com; envelope-from=jairoadelrio6@gmail.com; receiver= Original-Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 60AEA281F33 for ; Mon, 29 Mar 2021 10:54:18 +0200 (CEST) Original-Received: by mail-wr1-f54.google.com with SMTP id z2so11994132wrl.5 for ; Mon, 29 Mar 2021 01:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=SKIIfwMxzcKribquo4qdq5jNy4YX6ziBwfAprzBs7zQ=; b=jdmFkq0Bd6aSeJmHmWZuhtIJY7e/Q+CqFvJKrVP/FXRzzC++8zME+ddaBjkNgF71a6 7hCWQ984lv2e0TlZrCAI/mHHdZk3lj7vCbMv6+9bPMyJEZjkG7u/ZRDxsFyBciwMyDng psX/s0z3DVjq3Ud5LlSlONyzCH0XatQMorgWs8cG3nYV8Nel3nLU3mzcfbS014C28J4G fiIRdslxYWYLFVHXFBJ1gylGrRCUMCeYJVOSWlSIVBLJrYyB45+lvHvtdPOCq491+P62 fFX6FASyc0czL1NYbF3kB8wn9FqAOYJm5FAX8jTH9c4lhFaNCITSUW4Wzwr+qI1PLh0W 3npA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=SKIIfwMxzcKribquo4qdq5jNy4YX6ziBwfAprzBs7zQ=; b=TR6wnFFNX7foU7a8VFLT5bzt0kbLjsB7J5SXzBaVAEQrnuvH/gg6ZsLUjCqbpZh0IC FkndavpL+P/TxKfp7foTdhx2awmaMygIV05QyNtw7L1BLsf/ZhQ/PQ92JjJfBtEz+UdU eQA1L0i7jdTYydzFdb/GqprmOm197myTwcM5pgNaex3CrIMWNLifFbIoVpD1iW6PUerU Oa8ai/w6MjZjhN/bzLCzpDTVmiyySYWO0S2Era3YC9iVEmPYBHasVufKJDWsgQjXseyD +IaTipVR8L9kyZg3fqFSQLKkmkk2O4TMbtU+SSWPlF0mOvBcAlip9c0QTYPvnSMzJrMq yy2g== X-Gm-Message-State: AOAM531OzYj6VeTZENTsJuZngTJN5bBVabQzYP/JJN0GyQ3ZQ51qYzbg P3WaR7CU1S2v7wRhROCH6QcHDIf5MWsJFdhgx77eux9J+9E= X-Google-Smtp-Source: ABdhPJwtrgtAf9hFGHcZa4lKz7asJgaytKBx+lcH++ogyLvh/sAeNunyj25wdBJ0B8waVaHpdd4wNwyCKvqABUsUxGI= X-Received: by 2002:adf:e391:: with SMTP id e17mr27380324wrm.285.1617008057836; Mon, 29 Mar 2021 01:54:17 -0700 (PDT) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:110981 Archived-At: --===============7590042101787181593== Content-Type: multipart/alternative; boundary="000000000000e2e7a605bea9062a" --000000000000e2e7a605bea9062a Content-Type: text/plain; charset="UTF-8" Hi list! See the following example: \startluacode userdata = userdata or {} --Toy example --My actual function receives an argument, but the problem remains the same userdata.myfunction = function() return "343327959841638047651959775267761420323" .. "657838053757849835434002826851807933276" .. "324327913964298509889902373459201557839" .. "84828001486412574060553756854137069878601" end interfaces.implement{ name = "myfunction", public = true, actions = function () context(userdata.myfunction()) end } \stopluacode \def\colorfulnumbers#1{\colored[h=\luaexpr{40*#1},s=1,v=1]{#1}\ }% \starttext %It doesn't work %\handletokens{\myfunction}\with\colorfulnumbers \expandafter\handletokens\expandafter{\myfunction}\with\colorfulnumbers \stoptext As readily seen from my example, I want to color each figure of the numbers generated by a Lua function. However, the use of \expandafter's is cumbersome in this case. I don't want to loop over the result in Lua because I want to be able to apply \handletokens...\with... (or another macro with a similar purpose) with different macros at the TeX end once Lua has delivered results. How should I do it in ConTeXt? Thanks in advance. Cordially, Jairo --000000000000e2e7a605bea9062a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi list! See the following example:

\startluacode<= /p>

userdata =3D u= serdata or {}


--T= oy example

= --My actual function receives an argument, but the problem remains the same=


userdata.myfun= ction =3D function()

return

"3433279= 59841638047651959775267761420323" ..

"6578380= 53757849835434002826851807933276" ..

"3243279= 13964298509889902373459201557839" ..

"8482800= 1486412574060553756854137069878601"

end


interfaces.imp= lement{

name =3D &q= uot;myfunction",

public =3D tr= ue,

actions =3D <= /p>

function ()

context(user= data.myfunction())

end

}

\stopluacode

\def\colorfuln= umbers#1{\colored[h=3D\luaexpr{40*#1},s=3D1,v=3D1]{#1}\ }%

\starttext

%It doesn'= t work

%\handletokens= {\myfunction}\with\colorfulnumbers

\expandafter\h= andletokens\expandafter{\myfunction}\with\colorfulnumbers

\stoptext

=


As readily seen from= my example, I want to color each figure of the numbers generated by a Lua = function. However, the use of \expandafter's is cumbersome in this case= . I don't want to loop over the result in Lua because I want to be able= to apply \handletokens...\with... (or another macro with a similar purpose= ) with different macros at the TeX end once Lua has delivered results. How = should I do it in ConTeXt?

Thanks in advance. Cordially,

Jairo

--000000000000e2e7a605bea9062a-- --===============7590042101787181593== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============7590042101787181593==--