From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/110885 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christoph Reller Newsgroups: gmane.comp.tex.context Subject: Re: Typing within doifmode leads to error Date: Fri, 19 Mar 2021 07:59:32 +0100 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7957104441504125065==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19403"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Mar 19 08:00:14 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 1lN97G-0004xP-Ib for gctc-ntg-context-518@m.gmane-mx.org; Fri, 19 Mar 2021 08:00:14 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B228D2818A6; Fri, 19 Mar 2021 07:59:52 +0100 (CET) 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 wpMuYOtz_pAS; Fri, 19 Mar 2021 07:59:51 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CA984281A87; Fri, 19 Mar 2021 07:59:51 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5DCD22818A6 for ; Fri, 19 Mar 2021 07:59:50 +0100 (CET) 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 zVuf6n2yy_NF for ; Fri, 19 Mar 2021 07:59:49 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.52; helo=mail-lf1-f52.google.com; envelope-from=christoph.reller@gmail.com; receiver= Original-Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 6EBC62817D5 for ; Fri, 19 Mar 2021 07:59:49 +0100 (CET) Original-Received: by mail-lf1-f52.google.com with SMTP id b83so8413687lfd.11 for ; Thu, 18 Mar 2021 23:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=EL2Q1d+FFUd3dvGn0kFKM+xxeQk7ngEoRTLEkVaWxrM=; b=KU8UGyVRm+Vkyxa5SViEzzF5vZDYOCXAhc90aosP/G+12+IjddQSq79uXYWK73TslK cWyFH4B4rmCbvhGB3LigBGuwFqyLi+fYEzgjDSjTwOYBLSw9uSHmDFEMsMzW+wBHBNa5 qmZopkv12gmVSqIyNFFrMG3oEX3eu/cA1A5yQa0rkK45bRedzojsW1WeCA/yAZZf4/8e ebkRKbJAHCVreXshUSYzodkaBf0OnG5jY8OokBTY/6VZGrML/nYLNGHZ15TE3LXseIDh /yeJnJt0Rs+H0wIb0Me41MC1g0J+Hi7+FFu69aaT/g4Ein4DF1ADkS/W36Li23ubprG6 YHwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=EL2Q1d+FFUd3dvGn0kFKM+xxeQk7ngEoRTLEkVaWxrM=; b=dkc4WAEl+ZsqQQhU9xzIiNF3e1yRBxqK3W/Gi3Lb2m+h4P+bJiwVB8LYxo5j2Y4zoR 4lFKjxY7d+EWttTBwsrmy5FbOhOGGaXiA3eJMoW8Nr8HptetQUGR0oMfhXHO30XNyeJU H2Q6Yr3v1k40OVzoY2qLvp0S83kcFlNi58d13SEDRlVVv8ifataAN5As0R5+Q1DgXsu3 CyaE9MN18rvbyxizZt7QV4wVb1CRMIgkp2aPu8ztvrb9sh9oat7Vw6QInCMhpxJjiS2B ModwMnj9kem+STJeJKfzQIWx2vH3leqMg7FlhGGYPRjiuISlOPyYGqBhDwHJurUhFG8C /mCA== X-Gm-Message-State: AOAM530C/dvPO5u501W/qGIfcE//81P1SJ8yTEAtleAOVE4F7NWf1mdw 1yKWxYxASiyHFzx9lXZ5f1LFLFXOXYj9rWR8E5kqGMGf X-Google-Smtp-Source: ABdhPJxx1MS9eLJAncMCpuTcCCK9HUPU26spwyzJBoF2Fatkgeu/MZcSonOArw/V2j5j/4zwzCSYelSqvlFDqb0vPrA= X-Received: by 2002:ac2:5446:: with SMTP id d6mr7374293lfn.527.1616137188553; Thu, 18 Mar 2021 23:59:48 -0700 (PDT) In-Reply-To: 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:110885 Archived-At: --===============7957104441504125065== Content-Type: multipart/alternative; boundary="00000000000008363c05bdde4328" --00000000000008363c05bdde4328 Content-Type: text/plain; charset="UTF-8" On Fri, Mar 19, 2021 at 5:38 AM Aditya Mahajan wrote: > On Fri, 19 Mar 2021, Christoph Reller wrote: > > > Consider the following MWE: > > > > \definetyping[T] > > \definemode[mode][yes] > > \starttext > > \doifmode{mode}{% > > \startT > > Bla > > \stopT} > > \stoptext > > > > Compilation with the currently latest ConTeXt LMTX (ver: 2021.03.17 17:46 > > LMTX fmt: 2021.3.18) fails with: > > > > tex error > runaway error: end of file encountered > > mtx-context | fatal error: return code: 1 > > > > Compilation is successful if I replace doifmode{mode}{...} by > > \startmode[mode]...\stopmode. > > Has to be with how tex works. The argument of any macro > (\doifmode{mode}{...} in this case) is scanned under the current catcode > regime. So, any environment (like typing) which changes catcodes does work > inside the argument to another macro. > I see. Strangely, the MWE did work in older versions of ConTeXt ;-) > So, either use the environment version of \doifmode (which doesn't > _capture_ it content): > > \definetyping[T] > \definemode[mode][yes] > \starttext > \startmode[mode] > \startT > Bla > \stopT > \stopmode > \stoptext > > Or use buffers (to avoid catcode all together): > > \definetyping[T] > \definemode[mode][yes] > \starttext > \startbuffer[code] > \startT > Bla > \stopT > \stopbuffer > > \doifmode{mode}{\getbuffer[code]} > \stoptext > > or (note type**T**buffer so that the output is formatting according to the > options of \definetyping[T]) > > \definetyping[T] > \definemode[mode][yes] > \starttext > \startbuffer[code] > Bla > \stopbuffer > > \doifmode{mode}{\typeTbuffer[code]} > \stoptext > > Perhaps this should be added to the FAQ on the wiki. > > Aditya > Thank you for your ultra-speedy and very helpful response! Christoph --00000000000008363c05bdde4328 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Mar 19, 2021 at 5:38 AM Adity= a Mahajan <adityam@umich.edu>= ; wrote:
On Fri,= 19 Mar 2021, Christoph Reller wrote:

> Consider the following MWE:
>
> \definetyping[T]
> \definemode[mode][yes]
> \starttext
> \doifmode{mode}{%
>=C2=A0 =C2=A0\startT
>=C2=A0 =C2=A0 =C2=A0Bla
>=C2=A0 =C2=A0\stopT}
> \stoptext
>
> Compilation with the currently latest ConTeXt LMTX (ver: 2021.03.17 17= :46
> LMTX=C2=A0 fmt: 2021.3.18) fails with:
>
> tex error=C2=A0 =C2=A0 =C2=A0 =C2=A0> runaway error: end of file en= countered
> mtx-context=C2=A0 =C2=A0 =C2=A0| fatal error: return code: 1
>
> Compilation is successful if I replace doifmode{mode}{...} by
> \startmode[mode]...\stopmode.

Has to be with how tex works. The argument of any macro (\doifmode{mode}{..= .} in this case) is scanned under the current catcode regime. So, any envir= onment (like typing) which changes catcodes does work inside the argument t= o another macro.

I see. Strangely, the = MWE did work in older versions of ConTeXt ;-)
=C2=A0
So, either use the environment version of \doifmode (which doesn't _cap= ture_ it content):

\definetyping[T]
\definemode[mode][yes]
\starttext
\startmode[mode]
=C2=A0 \startT
=C2=A0 =C2=A0 Bla
=C2=A0 \stopT
\stopmode
\stoptext

Or use buffers (to avoid catcode all together):

\definetyping[T]
\definemode[mode][yes]
\starttext
\startbuffer[code]
\startT
=C2=A0 =C2=A0 Bla
\stopT
\stopbuffer

\doifmode{mode}{\getbuffer[code]}
\stoptext

or (note type**T**buffer so that the output is formatting according to the = options of \definetyping[T])

\definetyping[T]
\definemode[mode][yes]
\starttext
\startbuffer[code]
=C2=A0 =C2=A0 Bla
\stopbuffer

\doifmode{mode}{\typeTbuffer[code]}
\stoptext

Perhaps this should be added to the FAQ on the wiki.

Aditya

=C2=A0Thank you for your ultra-s= peedy and very helpful response!

Christoph
--00000000000008363c05bdde4328-- --===============7957104441504125065== 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== --===============7957104441504125065==--