ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Christoph Reller <christoph.reller@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Typing within doifmode leads to error
Date: Fri, 19 Mar 2021 07:59:32 +0100	[thread overview]
Message-ID: <CAO8LnPGA0F3GnEmdxZ7JQ3u-Wg21q_Yextcf_nEX=4TwJ8z9Lw@mail.gmail.com> (raw)
In-Reply-To: <nycvar.YAK.7.78.908.2103190029590.819312@nqv-guvaxcnq>


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

On Fri, Mar 19, 2021 at 5:38 AM Aditya 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}{%
> >   \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

[-- Attachment #1.2: Type: text/html, Size: 2621 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
___________________________________________________________________________________

  reply	other threads:[~2021-03-19  6:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  3:58 Christoph Reller
2021-03-19  4:37 ` Aditya Mahajan
2021-03-19  6:59   ` Christoph Reller [this message]
2021-03-19  8:49 ` Hans Hagen
2021-03-20  5:24   ` Christoph Reller
2021-03-20  7:24     ` Aditya Mahajan
2021-03-20 11:11       ` Hans Hagen
2021-03-20 15:00         ` Christoph Reller
2021-03-20 17:07           ` Hans Hagen
2021-03-20 20:23             ` Aditya Mahajan
2021-03-20 20:49               ` Hans Hagen
2021-03-20 21:03                 ` Aditya Mahajan
2021-03-21  1:43                   ` Hans Hagen
2021-03-21  2:40                     ` Aditya Mahajan
2021-03-21 14:44             ` Christoph Reller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO8LnPGA0F3GnEmdxZ7JQ3u-Wg21q_Yextcf_nEX=4TwJ8z9Lw@mail.gmail.com' \
    --to=christoph.reller@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).