[luatex] On category code tables

Steve Hafner steve.b.hafner at gmail.com
Sat Jul 10 22:58:07 CEST 2010


On Sat, Jul 10, 2010 at 11:59 AM, Joseph Wright
<joseph.wright at morningstar2.co.uk> wrote:
> Hello all,
>
> I'm taking a look at the category code table primitives provided by LuaTeX
> (\completable, \initcatcodetable and \savecatcodetable). I'm not entirely
> clear on a few things.
>
> I'd initially imagined when I first saw about category code tables that
> you'd be able to set up a table then use it to reset a large number of
> category codes in one go. However, I pick up from
>
>  http://tug.org/mailman/htdig/luatex/2010-March/001389.html
>
> that if I have something like
>
>  \catcodetable<number>\relax
>  \catcode<char> <code>\relax
>
> then the category code change will become part of the table in force, i.e.
> without an explicit \savecatcodetable<number> instruction. At the same time,
> there does not seem to be a way to copy category codes from one table to
> another. So how do I achieve:
>
>  \savecatcodetable<number>\relax % Fixed table of codes
>  \catcode<x> <y>
>  ...
>  \catcodetable<number>
>
> such that I can treat category code table <number> as a fixed set of
> category codes that will never be accidentally altered? This also seems to
> be an issue in that
>
>  \catcodetable<number>\relax
>  \catcode<x> <y>
>  \catcodetable<number>\relax
>
> doesn't reset the code for <x>. I must be missing something, as this
> otherwise undermines the entire point, as far as I can see.

I have little experience, but here is an idea ...

Keep one table position reserved for the "current" catcode table,
suppose this is position 1. Then define all your other "immutable"
tables in other positions. For this example assume we have a table
that we don't want altered in position 2. Then define a command such
as

\def\loadcatcodetable#1{\catcodetable#1\savecatcodetable1\catecodetable1}

Then one can say

\loadcatcodetable2

and a copy of table 2 will be placed in table 1 and table 1 will be
made current. Now, as you indicated in the rest of your post its not
good to have the table numbers hard coded, and so I think you need
some other macros to manage that (see my previous response).



More information about the luatex mailing list