summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/supp-lat.mkii
blob: 576121327cb6bb041889720448625e48fbb75910 (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
%D \module
%D   [       file=syst-ltx,
%D        version=2009.10.13,
%D          title=\CONTEXT\ System Macros,
%D       subtitle=General,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D The bib module assumes that sometimes this command is used but
%D in \MKIV\ we no longer assume that.
%D
%D \macros
%D   {newcommand}
%D
%D This module replaces \type {t-bibltx} and implements the
%D \LATEX\ newcommand (sort of). This command is not to be
%D used directly but only is there for the occasional
%D \BIBTEX\ file that uses it.
%D
%D \starttyping
%D \newcommand\oeps             {oeps}
%D \newcommand\oeps[6]          {oeps[#1]#6}
%D \newcommand\oeps[6][whatever]{oeps[#1]#6}
%D \stoptyping

\unprotect

\def\newcommand#1%
  {\dotripleempty\donewcommand[#1]}

\def\donewcommand
  {\ifthirdargument
     \expandafter\donewcommandtwo
   \else\ifsecondargument
     \expandafter\expandafter\expandafter\donewcommandone
   \else
     \expandafter\expandafter\expandafter\donewcommandzero
   \fi\fi}

\def\donewcommandzero[#1][#2][#3]%
  {\long\def#1}

\def\donewcommandone[#1][#2][#3]%
  {\scratchtoks{\long\def#1}%
   \dorecurse{#2}{\scratchtoks\expandafter{\the\scratchtoks######1}}%
   \the\scratchtoks}

\def\donewcommandtwo[#1][#2][#3]%
  {\long\def#1{\doifnextcharelse[{\getvalue{>>\string#1>>}}{\getvalue{>>\string#1>>}[#3]}}%
   \scratchtoks{\long\setvalue{>>\string#1>>}[##1]}%
   \dostepwiserecurse{2}{#2}{1}{\scratchtoks\expandafter{\the\scratchtoks######1}}%
   \the\scratchtoks}

\protect \endinput