# [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

Then one can say