summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/toks-aux.mkiv
blob: 817a5aba9516fc47eeee1343e2e9b39b70b935b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
%D \module
%D   [       file=toks-aux,
%D        version=2018.11.29,
%D          title=\CONTEXT\ Token Support,
%D       subtitle=Helpers,
%D         author=Wolfgang Schuster,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Token Support / Helpers}

\unprotect

% The older \type {\scantokens} overload has been replace by a more modern
% one (in \LMTX):
%
% \protected\def\whatever#1[#2](#3)\relax{oeps #1 and #2 and #3 done ## error}
% \scratchtoks{foo \framed{\red 123}456}
%
% \showluatokens{123\what}
% \showluatokens\whatever
% \showluatokens\framed
%
% \showluatokens\scratchtoks
% \showluatokens\everypar

\ifcase\contextlmtxmode \or
    \registerctxluafile{toks-aux}{autosuffix}
\fi

\installcorenamespace {tokenlist}

\unexpanded\def\definetokenlist[#1]%
  {\ifcsname\??tokenlist#1\endcsname
     \global\lastnamedcs\emptytoks
   \else
     \expandafter\newtoks\csname\??tokenlist#1\endcsname
   \fi}

\unexpanded\def\starttokenlist[#1]#2\stoptokenlist
  {\ifcsname\??tokenlist#1\endcsname \else
     \expandafter\newtoks\csname\??tokenlist#1\endcsname
   \fi
   \toksapp\lastnamedcs{#2}}

\let\stoptokenlist\relax

\def\gettokenlist[#1]%
  {\ifcsname\??tokenlist#1\endcsname
     \the\lastnamedcs
   \fi}

\def\settokenlist[#1]#2%
  {\ifcsname\??tokenlist#1\endcsname \else
     \expandafter\newtoks\csname\??tokenlist#1\endcsname
   \fi
   \toksapp\lastnamedcs{#2}}

\unexpanded\def\resettokenlist[#1]%
  {\ifcsname\??tokenlist#1\endcsname
     \lastnamedcs\emptytoks
   \fi}

\ifcase\contextlmtxmode \or
    \chardef\discretionarygroupcode = \discgroupcode
\fi

\protect