From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106770 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: Trying to understand this ctxlua error Date: Mon, 6 Apr 2020 11:48:03 +0200 Message-ID: <8060B154-2C22-41CB-ABDC-50FFC82E238C@rna.nl> References: <2EBF1308-12F4-4EF1-B309-89B403D3FAD6@rna.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============7075878520412222474==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="84624"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mailing list for ConTeXt users To: Wolfgang Schuster Original-X-From: ntg-context-bounces@ntg.nl Mon Apr 06 11:48:45 2020 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 1jLON2-000Ltn-Gc for gctc-ntg-context-518@m.gmane-mx.org; Mon, 06 Apr 2020 11:48:44 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 51EDC1830D9; Mon, 6 Apr 2020 11:48:08 +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 6DOGCbaQ8QuK; Mon, 6 Apr 2020 11:48:06 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3B4681830DA; Mon, 6 Apr 2020 11:48:06 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 860961830D0 for ; Mon, 6 Apr 2020 11:48:05 +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 Jj4DnexKP4OZ for ; Mon, 6 Apr 2020 11:48:04 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id C7021183072 for ; Mon, 6 Apr 2020 11:48:04 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id 291BB3CE8395; Mon, 6 Apr 2020 11:48:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586166484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TD7sSPLiuJ24fOek0ZZP5+rSVkp2tmpXDl6PJam3yxM=; b=c96WIPhH1L5Rl1acvqQF2t/lP1KXUHgUWlTgYkhXB2SjKAUpnGlM7XP0ZdlyUzQsczbEay TW7mJNxqHhEypS4xhWubnEUhClH6vlcvziOoHhH0SpPpNEtgghICllWpUCJj62RqnZG7XO N1MboTKSbmF5Mk5ZooELw/Ac8pR6fLGmxGPcYktzq8wbnaIfviW3djoscoyOC5cJ4bu++Z Bh3VPmfI4jKWL70P9lIrWKTr8Go05ujD2vKMAEEsEqPX4kbGu5Nr+CGJQA1c8PBvTs6YI8 XtC7lbO9p6A+Huz1FpDQKXwqBDcvCPL6aZWSKD8VHVTN5rOXXo1iN2eVixvF5w== In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) 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:106770 Archived-At: --===============7075878520412222474== Content-Type: multipart/alternative; boundary="Apple-Mail=_20C8E298-D2B5-4937-BEE9-AF702A1D2BF0" --Apple-Mail=_20C8E298-D2B5-4937-BEE9-AF702A1D2BF0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 6 Apr 2020, at 02:54, Wolfgang Schuster = wrote: >=20 > Gerben Wierda schrieb am 06.04.2020 um 00:41: >> I got this error after I had changed some lua code: >> tex error > tex error on line 272 in file archimate-lua.new: ! = Undefined control sequence >> warnIfVerbose( "Breaking off the processing of node %s\nNo >> l...eak = xsi:type", node) >> \luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand = \directlua {#1 >> = }} >> l.272 \stopluacode >> >> The control sequence at the end of the top line of your error message = was never >> \def'ed. You can just continue as I'll forget about whatever was = undefined. >> I have been looking at that code for over two hours, not seeing = anything wrong with it. But I=E2=80=99ve now finally found the culprit = and I still do not get it. >> The culprit was: >> warnIfVerbose( "Breaking off the processing of %s\n No = elementRef", node) >> The problem goes away when I use: >> warnIfVerbose( "Breaking off the processing of %s\nNo = elementRef", node) >> (I don=E2=80=99t want the line after the node is printed to begin = with a space). >> But the lack of space between \n and N kills lua (apparently). For = completeness (as string.format and texio.write_nl are also in play): >> function warnWithLabelIfVerbose( str, ... ) >> if verboseProgram then >> texio.write_nl( str .. string.format(...)) >> end >> end >> function warnIfVerbose( ... ) >> warnWithLabelIfVerbose("-----> ", ...) >> end >> Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why = is reported that on line 272 (where \stopluacode is) is the error? Or is = the error message indeed helpful and do I just lack the know how to = interpret it? >=20 > ConTeXt expands TeX commands in a luacode-environment > and when you have \n followed by text you create a new > command with starts with \n but since it isn't defined > you get a error message. >=20 > In the example below the commented block produces > the same error message as you get. >=20 > \starttext >=20 > %\startluacode > %print("text\ntext") > %\stopluacode >=20 > \startluacode > print("text\n text") > \stopluacode >=20 > \stoptext OK, thanks. This means the ConTeXt environment mixes standard TeX (where = \nfoo would be considered a TeX command) and lua string substitution = (where \nfoo would mean a newline followed by foo), correct? I = understand why that happens (otherwise one would have to escape all \ = characters directed at TeX) but it really took me hours (because I did = not understand the error message that correctly told me \Nno was the = problem). It=E2=80=99s what you see depends on what you are looking for, = I guess. Maybe a warning in the documentation (or maybe there is one and I missed = it) G --Apple-Mail=_20C8E298-D2B5-4937-BEE9-AF702A1D2BF0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On = 6 Apr 2020, at 02:54, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:

Gerben Wierda schrieb am = 06.04.2020 um 00:41:
I got this error after I had changed = some lua code:
tex error       > tex = error on line 272 in file archimate-lua.new: ! Undefined control = sequence
        warnIfVerbose( "Breaking = off the processing of node %s\nNo
    =   l...eak =             &n= bsp;           &nbs= p;            =             &n= bsp;              =     xsi:type", node)
\luat_start_lua_code_indeed = ...ormalexpanded {\endgroup \noexpand \directlua {#1
          &nb= sp;            = ;            &= nbsp;           &nb= sp;            = ;            &= nbsp;        }}
l.272 \stopluacode
<empty file>
The control sequence at the = end of the top line of your error message was never
\def'ed.= You can just continue as I'll forget about whatever was undefined.
I have been looking at that code for over two hours, not = seeing anything wrong with it. But I=E2=80=99ve now finally found the = culprit and I still do not get it.
The culprit was:
          warnIfVerbose( "Breaking = off the processing of %s\n No elementRef", node)
The = problem goes away when I use:
        =   warnIfVerbose( = "Breaking off the processing of %s\nNo elementRef", node)
(I= don=E2=80=99t want the line after the node is printed to begin with a = space).
But the lack of space between \n and N kills lua = (apparently). For completeness (as string.format and texio.write_nl are = also in play):
function warnWithLabelIfVerbose( str, ... = )
  if verboseProgram then
    texio.write_nl( str .. = string.format(...))
  end
end
function warnIfVerbose( ... )
  warnWithLabelIfVerbose("-----= > ", ...)
end
Is this a lua bug? A = ConTeXt bug? Expected behaviour? And if so, why is reported that on line = 272 (where \stopluacode is) is the error? Or is the error message indeed = helpful and do I just lack the know how to interpret it?

ConTeXt expands TeX commands in a = luacode-environment
and when you have \n followed by text you create a = new
command with = starts with \n but since it isn't defined
you get a error message.

In the example below the commented block produces
the same error message as you = get.

\starttext

%\startluacode
%print("text\ntext")
%\stopluacode

\startluacode
print("text\n text")
\stopluacode

\stoptext

OK, thanks. This means the ConTeXt environment = mixes standard TeX (where \nfoo would be considered a TeX command) and = lua string substitution (where \nfoo would mean a newline followed by = foo), correct? I understand why that happens (otherwise one would have = to escape all \ characters directed at TeX) but it really took me hours = (because I did not understand the error message that correctly told me = \Nno was the problem). It=E2=80=99s what you see depends on what you are = looking for, I guess.

Maybe a = warning in the documentation (or maybe there is one and I missed = it)

G

= --Apple-Mail=_20C8E298-D2B5-4937-BEE9-AF702A1D2BF0-- --===============7075878520412222474== 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== --===============7075878520412222474==--