summaryrefslogtreecommitdiff
path: root/tex/context/base/core-fil.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/core-fil.tex')
-rw-r--r--tex/context/base/core-fil.tex91
1 files changed, 80 insertions, 11 deletions
diff --git a/tex/context/base/core-fil.tex b/tex/context/base/core-fil.tex
index e8b92221c..a3311f562 100644
--- a/tex/context/base/core-fil.tex
+++ b/tex/context/base/core-fil.tex
@@ -165,7 +165,7 @@
\else
\makeshortfilename[#1\truefilename{#2}]% beware: *- is not part of syn
\doifelseflagged\shortfilename
- {\showmessage\m!systems7{#2}%
+ {\showmessage\m!systems7{#2 (line \number\inputlineno)}%
\settrue\moduleisloaded
\let\next\relax}
{\doglobal\setflag\shortfilename
@@ -192,22 +192,91 @@
\showmessage\m!systems6{#2}%
\fi}
-\def\dousemodules[#1][#2]%
- {\ifsecondargument
+% \def\usemodules
+% {\dodoubleempty\dousemodules}
+%
+% \def\dousemodules[#1][#2]%
+% {\ifsecondargument
+% \doifelsenothing{#2}
+% {\let\next\relax}
+% {\def\next{\processcommalist[#2]{\dodousemodules{#1}}}}%
+% \else
+% \def\next{\usemodules[][#1]}%
+% \fi
+% \next}
+%
+% \let\usemodule\usemodules
+
+\def\usemodules
+ {\dotripleempty\dousemodules}
+
+\def\dousemodules[#1][#2][#3]%
+ {\pushmacro\currentmodule
+ \pushmacro\currentmoduleparameters
+ \let\currentmoduleparameters\empty
+ \ifthirdargument
+ \doifelsenothing{#2}
+ {\let\next\relax}
+ {\def\currentmoduleparameters{#3}%
+ \def\next{\processcommalist[#2]{\dodousemodules{#1}}}}%
+ \else\ifsecondargument
\doifelsenothing{#2}
{\let\next\relax}
- {\def\next{\processcommalist[#2]{\dodousemodules{#1}}}}%
+ {\doifassignmentelse{#2}
+ {\def\currentmoduleparameters{#2}%
+ \def\next{\processcommalist[#1]{\dodousemodules{}}}}
+ {\def\next{\processcommalist[#2]{\dodousemodules{#1}}}}}%
+ \else
+ \def\next{\processcommalist[#1]{\dodousemodules{}}}%
+ \fi\fi
+ \next
+ \popmacro\currentmoduleparameters
+ \popmacro\currentmodule}
+
+\let\currentmoduleparameters\empty
+\let\currentmodule \s!unknown
+
+\def\startmodule
+ {\doifnextcharelse[\dostartmodule\nostartmodule}
+
+\def\nostartmodule #1 %
+ {\dostartmodule[#1]}
+
+\def\dostartmodule[#1]%
+ {\pushmacro\currentmodule
+ \pushmacro\currentmoduleparameters
+ \def\currentmodule{#1}}
+
+\def\stopmodule
+ {\popmacro\currentmoduleparameters
+ \popmacro\currentmodule}
+
+\def\setupmodule
+ {\dodoubleempty\dosetupmodule}
+
+\def\dosetupmodule[#1][#2]%
+ {\scratchtoks\expandafter{\currentmoduleparameters}%
+ \ifsecondargument
+ \getparameters[\??md:#1:][#2]%
+ \expanded{\getparameters[\??md:#1:][\the\scratchtoks]}%
\else
- \def\next{\usemodules[][#1]}%
+ \getparameters[\??md:\currentmodule:][#1]%
+ \expanded{\getparameters[\??md:\currentmodule:][\the\scratchtoks]}%
\fi
- \next}
+ \let\currentmoduleparameters\empty}
-\def\usemodules
- {\dodoubleempty\dousemodules}
-
-\let\usemodule\usemodules
+\def\moduleparameter #1#2{\csname\??md:#1:#2\endcsname}
+\def\currentmoduleparameter#1{\csname\??md:\currentmodule:#1\endcsname}
-% \usemodule[t][speech]
+% \usemodule[newmml]
+% \usemodule[newmml][a=b]
+% \usemodule[x][newmml]
+% \usemodule[x][newmml][a=b]
+%
+% \startmodule [mathml]
+% \setupmodule[a=c] [\currentmoduleparameter{a}] % user vars will be set afterwards
+% \setupmodule[a=c] [\currentmoduleparameter{a}] % user vars are now forgotten
+% \stopmodule
%D We also support a singular call, which saves us for
%D frustrations when we do a typo.