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>
Cc: "Marcel Fabian Krüger" <tex@2krueger.de>
Subject: Re: Yet another cornercase of ^^ handling in LuaMetaTeX
Date: Wed, 17 Jun 2020 15:43:49 +0200	[thread overview]
Message-ID: <14f700d0-ac0f-f1e0-104e-eefc4b85ecc7@xs4all.nl> (raw)
In-Reply-To: <20200617101059.3zvwgt5qltufl64v@yoga>

On 6/17/2020 12:10 PM, Marcel Fabian Krüger wrote:
> On Mon, Jun 15, 2020 at 04:16:06PM +0200, Hans Hagen wrote:
>>
>> ah, i removed some doee that i though was never seen; i'll add that bit
>> again
>>
>>> Beside that, I noticed a smaller weird thing when using LuaMetaTeX in ini
>>> mode without Context: The default mathcodes for digits and letters have
>>> their class and family values switched. So e.g. "A" has a default
>>> mathcode of 119537729=0x7200041, indicating class 1 and family 7,
>>> instead of the expected 31457345=0x1E00041, indicating class 7 and
>>> family 1. Of course this isn't really a problem because the format will
>>> normally assign new mathcodes anyway, but especially class 1 seems like
>>> a *very* unnatural default for normal letters.
>> i'll check it (digits get class 0) ... indeed these defaults nowadays never
>> kick in this way
> 
> Thanks. Is there any way to convert either a token number (as given e.g.
> by t.tok) or a numeric cs identifier (as given e.g. by t.tok-cs_token_flag)
> to a token uservalue?
> In LuaTeX I used to use `token.new(tok, 0)` for this, but LuaMetaTeX
> seems to do more checking here.

Indeed there is more checking. So, when you create a token you need to 
use a valid cmd code and a valid chr code.

\ctxlua{
     local t = token.new(string.byte("X"),token.command_id("letter"))
     tex.print(t)
}

The interface might evolve a bit more. Valid commands (at this moment) are:

\ctxlua{
     for k, v in ipairs(token.values("command")) do
         print(k,v)
     end
}

So, things like this should work

\dimen3456=1234pt

\dimen3467=
\ctxlua{
     local t = token.new(3456,token.command_id("register_dimen"))
   % local t = token.new("register_dimen",3456) % in upcoming version
     tex.sprint(t)
}

\the\dimen3467

As does:

\ctxlua{
     local t1 = token.new(string.byte("{"),token.command_id("letter"))
     local t2 = token.new(string.byte("}"),token.command_id("letter"))
     tex.print(t1)
     tex.print(t2)
}

Properties like cs_token_flag are not user level and have no meaning in 
the interface. In fact, the 'token-as-number' is just some 
representation with no intended meaning. Also, tokens that are 
problematic or can interfere badly might become inaccessible in future 
versions.

(I don't expect many users to use the low level token interface anyway 
but it's there as part of the package.)

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
___________________________________________________________________________________

  parent reply	other threads:[~2020-06-17 13:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11  2:06 Changed behavior of ^^ in csname Marcel Fabian Krüger
2020-06-11  8:07 ` Hans Hagen
2020-06-11 10:24   ` Marcel Fabian Krüger
2020-06-11 17:51     ` Hans Hagen
2020-06-11 20:47       ` Marcel Fabian Krüger
2020-06-12  6:04         ` Hans Hagen
2020-06-12 18:05       ` Marcel Fabian Krüger
     [not found]       ` <20200615121737.ytepj47mtvmcujy4@yoga>
     [not found]         ` <98372899-4f2e-447b-c9f1-29c80fcec13d@xs4all.nl>
     [not found]           ` <20200617101059.3zvwgt5qltufl64v@yoga>
2020-06-17 13:43             ` Hans Hagen [this message]
2020-06-17 14:24               ` Yet another cornercase of ^^ handling in LuaMetaTeX Marcel Fabian Krüger
2020-06-17 16:12                 ` Hans Hagen

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=14f700d0-ac0f-f1e0-104e-eefc4b85ecc7@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=tex@2krueger.de \
    /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).