enigma / tex / plain / enigma / enigma.tex

Full commit
\ifcsname ver@enigma.sty\endcsname\else
% \else latex
\catcode`\_=11 % There’s no reason why this shouldn’t be the case.
%D Nice tool from luat-ini.mkiv. This really helps with those annoying
%D string separators of Lua’s that clutter the source.
% this permits \typefile{self} otherwise nested b/e sep problems
%D \startdocsection[title=Prerequisites]
%D \startparagraph
%D Package loading and the namespacing issue are commented on in
%D \identifier{enigma.lua}.
%D \stopparagraph
  packagedata = packagedata or { }
  dofile(kpse.find_file\!!bs enigma.lua\!!es)

%D \startparagraph
%D First, create somthing like \CONTEXT’s asciimode. We found
%D \texmacro{newluatexcatcodetable} in \identifier{luacode.sty} and it
%D seems to get the job done.
%D \stopparagraph
\newluatexcatcodetable \enigmasetupcatcodes
  \def\escapecatcode      {0}
  \def\begingroupcatcode  {1}
  \def\endgroupcatcode    {2}
  \def\spacecatcode      {10}
  \def\lettercatcode     {11}
  \setluatexcatcodetable\enigmasetupcatcodes {
      \catcode`\^^I = \spacecatcode % tab
      \catcode`\    = \spacecatcode
      \catcode`\{   = \begingroupcatcode
      \catcode`\}   = \endgroupcatcode
      \catcode`\^^L = \lettercatcode    % form feed
      \catcode`\^^M = \lettercatcode    % eol
%D \stopdocsection

%D \startdocsection[title=Setups]
%D \startparagraph
%D Once the proper catcodes are in place, the setup macro
%D \texmacro{do_setup_enigma} doesn’t to anything besides passing stuff
%D through to Lua.
%D \stopparagraph
      local enigma = packagedata.enigma
      local current_args = enigma.parse_args(\!!bs\detokenize{#1}\!!es)
      enigma.save_raw_args(current_args, \!!bs\current_enigma_id\!!es)

%D The module setup \texmacro{setupenigma} expects key=value, notation.
%D All the logic is at the Lua end, not much to see here …
    \luatexcatcodetable \enigmasetupcatcodes
%D \stopdocsection

%D \startdocsection[title=Encoding Macros]
%D \startparagraph
%D The environment of \texmacro{start<enigmaid>} and
%D \texmacro{stop<enigmaid>} allow enabling of Enigma encoding in
%D different parts of the document.
%D \stopparagraph

  \@EA\gdef\csname start\current_enigma_id\endcsname{%
      if packagedata.enigma                         and
         packagedata.enigma.machines[ \!!bs#1\!!es] then
          packagedata.enigma.callbacks[ \!!bs#1\!!es],
        print\!!bs ENIGMA: No machine of that name: #1!\!!es
  \@EA\gdef\csname stop\current_enigma_id\endcsname{%
      packagedata.enigma.machines[ \!!bs#1\!!es]:processed_chars()


%D \stopdocsection

\catcode`\_=8  % \popcatcodes
\catcode`\!=12 % reserved according to source2e
% vim:ft=tex:sw=2:ts=2:expandtab:tw=71