ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Subject: Re: LMTX problem with doifmode in \setuplayout
Date: Tue, 8 Jun 2021 22:48:35 +0200	[thread overview]
Message-ID: <ea62eb7c-2cbc-9634-0cf4-92fc85577f9d@xs4all.nl> (raw)
In-Reply-To: <15b30ada-da1b-5d3b-13bd-86948a380054@gmail.com>

On 6/8/2021 10:11 PM, Wolfgang Schuster wrote:
> Rik Kabel schrieb am 08.06.2021 um 18:14:
>>
>> Hello all,
>>
>> Odd issue with LMTX (works fine with --luatex). \doifelsemode causes a 
>> failure if it is used to set a simple value such as on, off, yes, no, 
>> ..., but works with a dimension. Perhaps better illustrated by an example:
>>
>>     \definemode        [aaa]
>>                        [keep]
>>     \setuplayout       [
>>                         marking=\doifmodeelse{aaa}{off}{on},
>>     %                   marking=on,
>>                         grid=\doifmodeelse{aaa}{yes}{no},
>>     %                   grid=yes,
>>                         bottom=\doifmodeelse{aaa}{10mm}{20mm},
>>                        ]
>>     \starttext
>>        This is only a test.
>>     \stoptext
>>
>> The problem occurs whether or not the mode is enabled. In the example, 
>> it fails with the mode test in the either the marking= or grid= keys, 
>> but has no problem with it in the bottom= key.
>>
>> The error message says:
>>
>>     The control sequence marked <to be read again> should not appear
>>     between \csname and \endcsname.
>>
>> pointing to the enabled \doifmodeelse line.
>>
>> The same issue occurs with the following, using \doifmode:
>>
>>     \definemode        [aaa]
>>                        [keep]
>>     \setuplayout       [
>>                         marking=on,
>>                         marking=\doifmode{aaa}{off},
>>                        ]
>>     \starttext
>>        This is only a test.
>>     \stoptext
>>
>> This did work without complaint a few months ago.
>>
> 
> You can never be sure if these combinations (\doifXXX within \setupXXX) 
> work without problems. The only reliable method in this case is:
> 
> % default setup
> 
> \setuplayout
>      [marking=on]
> 
> % mode dependent setup
> 
> \startmode[aaa]
> 
>      \setuplayout
>          [marking=off]
> 
> \stopmode
Indeed. I'll make the test more robust (not come up with an error) but 
as Wolfgang says, it won't work anyway because \doifmode is a protected 
macro.

There is actually a trick:

   \expand\doifmode{aaa}{on}

will ignore the protection .. compare

   \edef\foo{\doifmode{aaa}{on}}        [[\meaningless\foo]]

   \edef\foo{\expand\doifmode{aaa}{on}} [[\meaningless\foo]]

only in luametatex/lmtx

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
___________________________________________________________________________________

  reply	other threads:[~2021-06-08 20:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 16:14 Rik Kabel
2021-06-08 20:11 ` Wolfgang Schuster
2021-06-08 20:48   ` Hans Hagen [this message]
2021-06-08 21:01   ` Rik Kabel
2021-06-08 21:44     ` Wolfgang Schuster
2021-06-08 22:08       ` Hans Hagen
2021-06-08 22:16         ` Wolfgang Schuster

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=ea62eb7c-2cbc-9634-0cf4-92fc85577f9d@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=wolfgang.schuster.lists@gmail.com \
    /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).