summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/symb-ini.mkiv
diff options
context:
space:
mode:
authorMojca Miklavec <mojca.miklavec@gmail.com>2012-05-14 17:38:55 +0000
committerMojca Miklavec <mojca.miklavec@gmail.com>2012-05-14 17:38:55 +0000
commit15995e10bfc68edf79970c4ea4fbb6678566c46e (patch)
tree2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/symb-ini.mkiv
parentc9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff)
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/symb-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/symb-ini.mkiv233
1 files changed, 138 insertions, 95 deletions
diff --git a/Master/texmf-dist/tex/context/base/symb-ini.mkiv b/Master/texmf-dist/tex/context/base/symb-ini.mkiv
index 8282649b033..e957e68c1f5 100644
--- a/Master/texmf-dist/tex/context/base/symb-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/symb-ini.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Basic Symbols Commands,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%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
@@ -43,94 +43,128 @@
%D \definesymbol [level 5] [$\star$]
%D \stoptyping
-% ss:tag -> symbol
-% ss:set:tag -> symbol out of set
-% sstag -> list of symbols in set
+\installcorenamespace{symbol}
+\installcorenamespace{symbolset}
+
+\let\currentsymbol \empty
+\let\currentsymbolset\empty
+
+\newtoks\t_symb_setups
+
+\let\m_symb_current_set\empty
+
+\newconditional\c_symb_found
+
+\newtoks\everysymbol
+
+%D We don't use the commandhandler as symbols have their own
+%D subsystem for resolving values.
\unexpanded\def\definesymbol
- {\dotripleempty\dodefinesymbol}
+ {\dotripleempty\symb_define}
-\def\dodefinesymbol[#1][#2][#3]% class name meaning
+\def\symb_define[#1][#2][#3]% class name meaning
{\ifthirdargument
- \setvalue{\??ss:#1:#2}{#3}%
- \doifsomething{#1}{\addvalue{\??ss*#1}{#2}}%
+ \setvalue{\??symbol#1:#2}{#3}%
+ \doifsomething{#1}{\addvalue{\??symbolset#1}{#2}}%
\else
- \setvalue{\??ss:\currentsymboldef:#1}{#2}%
- \addvalue{\??ss*\currentsymboldef}{#1}%
+ \setvalue{\??symbol\m_symb_current_set:#1}{#2}%
+ \addvalue{\??symbolset\m_symb_current_set}{#1}%
\fi}
-% \def\doifinsymbolsetelse#1#2{\doifdefinedelse{\??ss:#1:#2}}
-% \def\doifinsymbolset #1#2{\doifdefined {\??ss:#1:#2}}
-% \def\doifsymbolsetelse #1{\doifdefinedelse{\??ss*#1}}
-%
-% \def\symbolset#1{\executeifdefined{\??ss*#1}\empty} % no [#1], to be used in commalists etc
-
-\def\doifinsymbolsetelse#1#2{\ifcsname\??ss:#1:#2\endcsname\@EA\firstoftwoarguments\else\@EA\secondoftwoarguments\fi}
-\def\doifinsymbolset #1#2{\ifcsname\??ss:#1:#2\endcsname\@EA\firstofoneargument \else\@EA\gobbleoneargument \fi}
-\def\doifsymbolsetelse #1{\ifcsname\??ss*#1\endcsname \@EA\firstoftwoarguments\else\@EA\secondoftwoarguments\fi}
+\letvalue{\??symbolset}\empty
-\letvalue{\??ss*}\empty
+\unexpanded\def\doifinsymbolsetelse#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
+\unexpanded\def\doifinsymbolset #1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi}
+\unexpanded\def\doifsymbolsetelse #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi}
-\def\symbolset#1{\csname\??ss*\ifcsname\??ss*#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc
+\def\symbolset#1{\csname\??symbolset\ifcsname\??symbolset#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc
%D Since symbols are used frequently in interactive
%D documents, we speed up this one. Well, that was history,
%D since now we simplified things a bit, because the low
-%D level macros have been sped up now and then.
-
-\unexpanded\def\symbol % This one always gobbles spaces,
- {\dodoubleempty\dosymbol} % so never change it again!
-
-\newif\ifnosymbol \newtoks\everysymbol
-
-\def\dodosymbol#1#2% \relax's prevent lookahead problems
- {\nosymbolfalse{\the\everysymbol\csname\??ss:#1:#2\endcsname\relax}\relax}
-
-\letvalue{\??ss:}\firstofoneargument
-
-\def\directsymbol#1#2% no \relax, there can be an argument, see lists
- {%\executeifdefined{\??ss:#1:#2}\firstofoneargument}
- \csname\??ss:\ifcsname\??ss:#1:#2\endcsname#1:#2\fi\endcsname}
+%D level macros have been sped up every now and then.
% We support both:
%
% Test test \symbol[whatever]\ test \symbol[whatever].
% Test test \symbol{whatever} test \symbol{whatever}.
-\def\dosymbol % so we also handle \symbol{name}
+\unexpanded\def\symbol % This one always gobbles spaces,
+ {\dodoubleempty\symb_place} % so never change it again!
+
+\def\symb_place % so we also handle \symbol{name}
{\iffirstargument % which is nicer with following spaces
- \expandafter\donormalsymbol
+ \expandafter\symb_place_normal
+ \else
+ \expandafter\symb_place_special
+ \fi}
+
+\def\symb_place_normal
+ {\ifsecondargument
+ \expandafter\symb_place_normal_a
+ \else
+ \expandafter\symb_place_normal_b
+ \fi}
+
+\def\symb_place_normal_a[#1][#2]%
+ {\edef\currentsymbol{#2}%
+ \ifcsname\??symbol#1:#2\endcsname
+ \symb_place_indeed{#1:#2}%
+ \else
+ \symb_place_normal_c
+ \fi}
+
+\def\symb_place_normal_b[#1][#2]%
+ {\edef\currentsymbol{#1}%
+ \ifcsname\??symbol\currentsymbolset:#1\endcsname
+ \symb_place_indeed{\currentsymbolset:#1}%
\else
- \expandafter\dospecialsymbol
+ \symb_place_normal_c
+ \fi}
+
+\def\symb_place_normal_c
+ {\setfalse\c_symb_found
+ \the\t_symb_setups
+ \ifconditional\c_symb_found \else
+ \symb_place_retry\currentsymbol % hm, isn't this redundant?
\fi}
-\def\dospecialsymbol[#1][#2]#3%
+\def\symb_place_special[#1][#2]#3%
{\firstargumenttrue
\secondargumentfalse
- \donormalsymbol[#3][]}
+ \symb_place_normal[#3][]}
-\def\donormalsymbol[#1][#2]%
- {\nosymboltrue
- \ifsecondargument
- \edef\currentsymbol{#2}%
- \doifinsymbolset{#1}{#2}{\dodosymbol{#1}{#2}}%
+\def\symb_place_indeed#1% \relax's prevent lookahead problems
+ {\settrue\c_symb_found
+ \begingroup
+ \the\everysymbol
+ \csname\??symbol#1\endcsname\relax
+ \endgroup}
+
+\letvalue{\??symbol}\firstofoneargument
+
+\def\directsymbol#1#2% no \relax, there can be an argument, see lists
+ {\csname\??symbol\ifcsname\??symbol#1:#2\endcsname#1:#2\fi\endcsname}
+
+\unexpanded\def\symb_fetch
+ {\ifconditional\c_symb_found
+ \expandafter\gobbleoneargument
\else
- \edef\currentsymbol{#1}%
- \fi
- \ifnosymbol
- \the\symbolsetups
- \ifnosymbol
- \redosymbol\currentsymbol
- \fi
+ \expandafter\symb_fetch_indeed
\fi}
-\def\fetchsymbol#1%
- {\ifnosymbol
- \doifinsymbolset{#1}\currentsymbol{\dodosymbol{#1}\currentsymbol}%
+\def\symb_fetch_indeed#1%
+ {\ifcsname\??symbol#1:\currentsymbol\endcsname
+ \symb_place_indeed{#1:\currentsymbol}%
\fi}
-\def\redosymbol#1%
- {\doifinsymbolsetelse\empty{#1}{\dodosymbol\empty}\firstofoneargument{#1}}
+\def\symb_place_retry#1%
+ {\ifcsname\??symbol:#1\endcsname
+ \symb_place_indeed{:#1}%
+ \else
+ #1%
+ \fi}
%D \macros
%D {definefiguresymbol}
@@ -145,23 +179,23 @@
\def\defaultsymbolfactor{10}
\def\defaultsymbolheight{1.25ex}
-\def\figuresymbol
- {\dodoubleempty\dofiguresymbol}
+\unexpanded\def\figuresymbol
+ {\dodoubleempty\symb_figure}
-\ifx\externalfigure \undefined \def\externalfigure[#1][#2]{#1} \fi
-\ifx\resetexternalfigures\undefined \let\resetexternalfigures\relax \fi
+\ifdefined\externalfigure \else \def\externalfigure[#1][#2]{#1} \fi
+\ifdefined\resetexternalfigures \else \let\resetexternalfigures\relax \fi
-\def\dofiguresymbol[#1][% #2]%
+\def\symb_figure[#1][% #2]%
{\externalfigure[#1][\c!reset=\v!yes,\c!symbol=\v!yes,\c!height=\defaultsymbolheight,}% #2]}
\appendtoks \resetexternalfigures \to \everysymbol
\unexpanded\def\definefiguresymbol
- {\dotripleempty\dodefinefiguresymbol}
+ {\dotripleempty\symb_figure_define}
-\def\dodefinefiguresymbol[#1][#2][#3]%
+\def\symb_figure_define[#1][#2][#3]%
{\ifsecondargument
- \definesymbol[#1][{\dofiguresymbol[#2][#3]}]%
+ \definesymbol[#1][{\symb_figure[#2][#3]}]%
\fi}
%D \macros
@@ -169,31 +203,34 @@
%D
%D A handy private one:
-% a bit messy
-
-\def\xfetchsymbol#1%
- {\ifnosymbol
- \doifinsymbolset{#1}\currentsymbol\nosymbolfalse
+\def\symb_fetch_first
+ {\ifconditional\c_symb_found
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\symb_fetch_first_indeed
\fi}
-\def\xredosymbol#1%
- {\doifinsymbolset\empty\currentsymbol\nosymbolfalse}
+\def\symb_fetch_first_indeed#1%
+ {\doifinsymbolset{#1}\currentsymbol{\settrue\c_symb_found}}
+
+\def\symb_fetch_second#1%
+ {\doifinsymbolset\empty\currentsymbol{\settrue\c_symb_found}}
\def\doifsymboldefinedelse#1%
- {\bgroup
+ {\begingroup
\edef\currentsymbol{#1}%
- \let\fetchsymbol\xfetchsymbol
- \nosymboltrue
- \the\symbolsetups
- \ifnosymbol
- \xredosymbol\currentsymbol
- \ifnosymbol
- \egroup\@EAEAEA\secondoftwoarguments
+ \let\symb_fetch\symb_fetch_first
+ \setfalse\c_symb_found
+ \the\t_symb_setups
+ \ifconditional\c_symb_found
+ \endgroup\expandafter\firstoftwoarguments
+ \else
+ \symb_fetch_second\currentsymbol
+ \ifconditional\c_symb_found
+ \endgroup\doubleexpandafter\firstoftwoarguments
\else
- \egroup\@EAEAEA\firstoftwoarguments
+ \endgroup\doubleexpandafter\secondoftwoarguments
\fi
- \else
- \egroup\@EA\firstoftwoarguments
\fi}
%D \macros
@@ -226,24 +263,30 @@
%D \showsetup{setupsymbolset}
%D \showsetup{startsymbolset}
-\let\currentsymboldef\empty
+\installcorenamespace{symbolsets}
\unexpanded\def\startsymbolset[#1]%
- {\def\currentsymboldef{#1}}
+ {\pushmacro\m_symb_current_set
+ \def\m_symb_current_set{#1}}
\unexpanded\def\stopsymbolset
- {\let\currentsymboldef\empty}
-
-\newtoks\symbolsetups
+ {\popmacro\m_symb_current_set}
\unexpanded\def\setupsymbolset[#1]%
- {\prependtoksonce\fetchsymbol{#1}\to\symbolsetups}
+ {\edef\currentsymbolset{#1}%
+ \ifcsname\??symbolsets\currentsymbolset\endcsname \else
+ \symb_setup_symbol_set
+ \fi}
+
+\def\symb_setup_symbol_set
+ {\normalexpanded{\t_symb_setups{\symb_fetch{\currentsymbolset}\the\t_symb_setups}}%
+ \letvalue{\??symbolsets\currentsymbolset}\empty} % speedup
-\def\resetsymbolset
- {\symbolsetups\emptytoks}
+\unexpanded\def\resetsymbolset
+ {\t_symb_setups\emptytoks}
-\def\forcesymbolset[#1]%
- {\symbolsetups{\fetchsymbol{#1}}}
+\unexpanded\def\forcesymbolset[#1]%
+ {\t_symb_setups{\symb_fetch{#1}}}
%D \macros
%D {showsymbolset}
@@ -257,7 +300,7 @@
%D
%D \showsetup{usesymbols}
-\def\usesymbols[#1]{\ctxcommand{usesymbols("#1")}}
+\unexpanded\def\usesymbols[#1]{\ctxcommand{usesymbols("#1")}}
%D As longs as symbols are linked to levels or numbers, we can
%D also use the conversion mechanism, but in for instance the