%D \module
%D   [       file=t-setup,
%D        version=2004.10.31,
%D          title=\CONTEXT\ User Module,
%D       subtitle=\CONTEXT\ Setup Definitions,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% module x-set-02 loads the mapping, after that we can say:
%
% texmfstart texexec --int=nl --pdf --global --result=setup-nl x-set-12
%
% \getinterfacecomponent{constant|variable|string}{tag}

% 2006-08 Wolfgang Schuster's adaptation of set-11.tex
% 2006-11 Vit Zyka adaptation

\usemodule[set-02]

\unprotect

% general

\def\setupnumfont  {}
\def\setuptxtfont  {}
\def\setupintfont#1{\uppercase{#1}}
\def\setupvarfont  {\sl}
\def\setupoptfont  {\sl}
\def\setupalwcolor {}
\def\setupoptcolor {darkgray}

\defineXMLenvironmentsave [cd:content] [list=,state=]
  {\simpleSETUPargument{content}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\startmessages  dutch  library: setup
        title:  setup
      formula:  formule
       number:  getal
         list:  lijst
    dimension:  maat
         mark:  markering
    reference:  verwijzing
      command:  commando
         file:  file
         name:  naam
   identifier:  naam
         text:  tekst
      section:  sectie
     singular:  naam enkelvoud
       plural:  naam meervoud
       matrix:  n*m
          see:  zie
     inherits:  erft van
            1:  de karakters < en > zijn globaal actief!
            2:  -- wordt verwerkt
            3:  -- is niet gedefinieerd
            4:  -- wordt nogmaals verwerkt
     optional:  optioneel
  displaymath:  formule
        index:  ingang
         math:  formule
      nothing:  leeg
         file:  file
     position:  positie
    reference:  verwijzing
       csname:  naam
  destination:  bestemming
      triplet:  triplet
         word:  woord
      content:  tekst
\stopmessages

\startmessages  english  library: setup
        title:  setup
      formula:  formula
       number:  number
         list:  list
    dimension:  dimension
         mark:  mark
    reference:  reference
      command:  command
         file:  file
         name:  name
   identifier:  identifier
         text:  text
      section:  section
     singular:  singular name
       plural:  plural name
       matrix:  n*m
          see:  see
     inherits:  inherits from
            1:  the characters < and > are globally active!
            2:  -- is processed
            3:  -- is undefined
            4:  -- is processed again
     optional:  optional
  displaymath:  formula
        index:  entry
         math:  formula
      nothing:  empty
         file:  file
     position:  position
    reference:  reference
       csname:  name
  destination:  destination
      triplet:  triplet
         word:  word
      content:  text
\stopmessages

\startmessages  german library: setup
        title:  Setup
      formula:  Formel
       number:  Nummer
         list:  Liste
    dimension:  Dimension
         mark:  Beschriftung
    reference:  Referenz
      command:  Befehl
         file:  Datei
         name:  Name
   identifier:  Name
         text:  Text
      section:  Abschnitt
     singular:  singular
       plural:  plural
       matrix:  n*m
          see:  siehe
     inherits:  inherits from
            1:  Die Zeichen < und > gelten global!
            2:  -- wird verarbeitet
            3:  -- ist undefiniert
            4:  -- ist mehrmals verarbeitet
     optional:  optioneel
  displaymath:  formula
        index:  entry
         math:  formula
      nothing:  empty
         file:  file
     position:  position
    reference:  reference
       csname:  name
  destination:  destination
      triplet:  triplet
         word:  word
      content:  text
\stopmessages

\startmessages  czech  library: setup
        title:  nastaven\iacute{}
      formula:  rovnice
       number:  \ccaron\iacute slo
         list:  seznam
    dimension:  dimenze
         mark:  zna\ccaron ka
    reference:  reference
      command:  p\rcaron\iacute kaz
         file:  soubor
         name:  jm\eacute no
   identifier:  identifik\aacute tor
         text:  text
      section:  sekce
     singular:  jm\eacute no v singul\aacute ru
       plural:  jm\eacute no v plur\aacute lu
       matrix:  n*m
          see:  viz
     inherits:  d\ecaron d\iacute{} z
            1:  znaky < a > jsou globaln\ecaron{} aktivn\iacute!
            2:  -- je zpracov\aacute no
            3:  -- je nedefinov\aacute no
            4:  -- je zpracov\aacute no znovu
     optional:  voliteln\eacute{}
  displaymath:  formule
        index:  \uacute daj
         math:  formule
      nothing:  nic
         file:  soubor
     position:  pozice
    reference:  reference
       csname:  jm\eacute no
  destination:  c\iacute l
      triplet:  trojice
         word:  slovo
      content:  text
\stopmessages

\startmessages  italian library: setup
        title:  setup
      formula:  formula
       number:  number
         list:  list
    dimension:  dimension
         mark:  mark
    reference:  reference
      command:  command
         file:  file
         name:  name
   identifier:  name
         text:  text
      section:  section
     singular:  singular name
       plural:  plural name
       matrix:  n*m
          see:  see
     inherits:  inherits from
            1:  the characters < and > are globally active!
            2:  -- is processed
            3:  -- is undefined
            4:  -- is processed again
     optional:  optioneel
  displaymath:  formula
        index:  entry
         math:  formula
      nothing:  empty
         file:  file
     position:  position
    reference:  reference
       csname:  name
  destination:  destination
      triplet:  triplet
         word:  word
      content:  text
\stopmessages

\startmessages  romanian library: setup
        title:  setari
      formula:  formula
       number:  numar
         list:  lista
    dimension:  dimensiune
         mark:  marcaj
    reference:  referinta
      command:  comanda
         file:  fisier
         name:  nume
   identifier:  nume
         text:  text
      section:  sectiune
     singular:  nume singular
       plural:  nume pluram
       matrix:  n*m
          see:  vezi
     inherits:  inherits from
            1:  caracterele < si > sunt active global!
            2:  este procesat --
            3:  -- este nedefinit
            4:  -- este procesat din nou
     optional:  optioneel
  displaymath:  formula
        index:  entry
         math:  formula
      nothing:  empty
         file:  file
     position:  position
    reference:  reference
       csname:  name
  destination:  destination
      triplet:  triplet
         word:  word
      content:  text
\stopmessages

\startmessages  french  library: setup
        title:  réglage
      formula:  formule
       number:  numéro
         list:  liste
    dimension:  dimension
         mark:  marquage
    reference:  reference
      command:  commande
         file:  fichier
         name:  nom
   identifier:  identificateur
         text:  texte
      section:  section
     singular:  nom singulier
       plural:  nom pluriel
       matrix:  n*m
          see:  vois
     inherits:  herite de
            1:  les caractères < et > sont globalement actifs !
            2:  -- est traité
            3:  -- n'est pas défini
            4:  -- est traité de nouveau
     optional:  optionel
  displaymath:  formule
        index:  entrée
         math:  formule
      nothing:  vide
         file:  fichier
     position:  position
    reference:  réference
       csname:  nom
  destination:  destination
      triplet:  triplet
         word:  mot
      content:  texte
\stopmessages

\startmessages  vietnamese  library: setup
        title:  tiêu đề
      formula:  công thức
       number:  số
         list:  danh sách
    dimension:  kích thước
         mark:  đánh dấu
    reference:  tham chiếu
      command:  lệnh
         file:  tập tin
         name:  tên
   identifier:  nhất quán
         text:  văn bản
      section:  tiết đoạn
     singular:  số ít
       plural:  số nhiều
       matrix:  n*m
          see:  xem
     inherits:  thừa hưởng
            1:  các kí tự < và > tác động toàn cục!
            2:  -- biên dịch
            3:  -- chưa định nghĩa
            4:  -- biên dịch lại
     optional:  tùy chọn
  displaymath:  công thức
        index:  mục
         math:  công thức
      nothing:  rỗng
         file:  tập tin
     position:  vị trí
    reference:  tham chiếu
       csname:  tên
  destination:  đích
      triplet:  bộ ba
         word:  từ
      content:  nội dung
\stopmessages

\def\c!setup!internal!#1%
  {{\getmessage{setup}{#1}%
    \expanded{\setupintfont{\currentmessagetext}}}}

\def\c!setup!text!#1%
  {{\getmessage{setup}{#1}%
    \setupvarfont{\currentmessagetext}}}

\def\c!setup!command!#1%
  {{\setupvarfont{\texescape...#1}}}

\def\??stp{@@stp}

\defineregister
  [texmacro]
  [texmacros]

\definesorting
  [texcommand]
  [texcommands]

\setupsorting
  [texcommand]
  [\c!command=\@@stpcommand,
   \c!criterium=\@@stpcriterium]

\definesorting
  [eachtexcommand]
  [alltexcommands]

\setupsorting
  [eachtexcommand]
  [\c!command=\@@stpcommand,
   \c!criterium=\v!all]

\pushmacro\setuptext

\defineframedtext
  [setuptext]
  [\c!width=\hsize,
   \c!height=\v!fit,
   \c!align=\v!right,
   \c!offset=0.75em]

\popmacro\setuptext

\newif\ifshortsetup

\def\setup     {\shortsetupfalse\dosetup}
\def\shortsetup{\shortsetuptrue \dosetup}
\def\setupsetup{\dodoubleargument\getparameters[\??stp]}

%\setupsetup
%  [\c!before=,
%   \c!after=,
%   \c!command=\setup,
%   \c!criterium=\v!used]

\setupsetup
  [\c!before=,
   \c!after=,
   \c!command=\setup,
   \c!criterium=\v!used,
   \c!text=]

% verwijzing: 0 geen verwijzingen plaatsen / wel genereren
%             1 alleen bij zie plaatsen / wel genereren
%             2 alle verwijzingen plaatsen / niet genereren
%             3 bij zie commando klikken / wel genereren

\setupsetup
  [\c!reference=0]

\def\placesetup
  {\bgroup
   \getvalue{\e!place\e!listof texcommands}
   \egroup}

\def\placeeverysetup % for fun purposes only
  {\bgroup
   \setupsetup[\c!reference=2]%
   \setupreferencing[\c!state=\v!stop]%
   \getvalue{\e!place\e!listof alltexcommands}%
   \egroup}

\let\plaatssetup    \placesetup
\let\plaatselkesetup\placeeverysetup

% we use :1 as fallback
%
% \setup{setupinterlinespace}
% \setup{setupinterlinespace:1}
% \setup{setupinterlinespace:2}

\bgroup \catcode`\<=\active

%\gdef\dosetup#1%
%  {\bgroup
%   \def<<##1>>{##1}%
%   \edef\ascii{#1}%
%   \enableXML
%   \doifelseXMLelement{stp:\ascii}
%     {\expanded{\flushXMLelement{stp:\ascii}}}
%     {\doifelseXMLelement{stp:\ascii:1}
%        {\expanded{\flushXMLelement{stp:\ascii:1}}}
%        {\convertargument#1\to\ascii
%         \em unknown setup \quote{\ascii}}}
%   \egroup}

\gdef\dosetup%
  {\dosingleempty\dodosetup}

\gdef\dodosetup[#1]#2%
  {\bgroup
   \getparameters[\??stp][#1]
   \def<<##1>>{##1}% VZ: seems does not operate! (\shortsetup{start<<name>>makeup})
   \edef\ascii{#2}%
%   \pagereference[pgref:stp:\ascii]% VZ new
   \enableXML
   \doifelseXMLelement{stp:\ascii}
     {\expanded{\flushXMLelement{stp:\ascii}}%
      \setbox\scratchbox\hbox{\csname stp:y:\ascii\endcsname}% VZ (for index generation)
     }
     {\doifelseXMLelement{stp:\ascii:1}
        {\expanded{\flushXMLelement{stp:\ascii:1}}%
         \setbox\scratchbox\hbox{\csname stp:y:\ascii:1\endcsname}% VZ
        }
        {\convertargument#2\to\ascii
         \em unknown setup \quote{\ascii}}}
   \egroup}

%% VZ 2006-12-04: for putting to index but without printing here
\gdef\secretsetup%
  {\dosingleempty\dosecretsetup}

\gdef\dosecretsetup[#1]#2%
  {\bgroup
   \getparameters[\??stp][#1]
   \def<<##1>>{##1}% VZ: seems does not operate! (\shortsetup{start<<name>>makeup})
   \edef\ascii{#2}%
%   \pagereference[pgref:stp:\ascii]% VZ new
   \enableXML
   \doifelseXMLelement{stp:\ascii}
     {%
      \setbox\scratchbox\hbox{\csname stp:y:\ascii\endcsname}% VZ (for index generation)
     }
     {\doifelseXMLelement{stp:\ascii:1}
        {%
         \setbox\scratchbox\hbox{\csname stp:y:\ascii:1\endcsname}% VZ
        }
        {\convertargument#2\to\ascii
         \em unknown setup \quote{\ascii}}}
   \egroup}

\egroup

\defineXMLenvironment [cd:command] [name=,type=,generated=,interactive=,variant=]
  {}
  {\showSETUPrecord}

%\def\showSETUPrecord
%  {\getvalue{\e!start setuptext}
%     \tttf
%     \nohyphens
%     \veryraggedright
%     \startXMLmapping [one]
%       \doglobal\newcounter\currentSETUPargument
%       \global\let\maximumSETUPargument\currentSETUPargument
%       \bgroup
%         \doifXMLop{generated}{yes}{\ttsl}%
%         \doifelseXMLop{type}{environment}
%           {\tex{\e!start}}{\tex{}}\ignorespaces
%         \XMLflush{cd:sequence}\ignorespaces
%       \egroup
%       \doifelseXMLempty{cd:arguments}
%         {}
%         {\bgroup
%            \setbox0=\hbox{\XMLflush{cd:arguments}}%
%            \global\let\maximumSETUPargument\currentSETUPargument
%            \doglobal\newcounter\currentSETUPargument
%            \ignorespaces\XMLflush{cd:arguments}%
%            \doif{\XMLpar{cd:command}{type}{}}{environment}
%              {\hskip.5em\unknown\hskip.5em
%               \tex{\e!stop}\ignorespaces\XMLflush{cd:sequence}}%
%            \endgraf
%          \egroup
%         %\bgroup
%         %  \tx
%         %  \doif{\XMLpar{cd:command}{interactive}{}}{yes}      {\quad INTERACTIVE}%
%         %  \doif{\XMLpar{cd:command}{interactive}{}}{exclusive}{\quad INTERACTIVE ONLY}%
%         %\egroup
%        \startXMLmapping [two]
%          \bgroup
%            \doglobal\newcounter\currentSETUPargument
%            \blank[\v!line]
%            \switchtobodyfont[small] % kan sneller
%            \ignorespaces\XMLflush{cd:arguments}\endgraf
%          \egroup
%        \stopXMLmapping}
%     \stopXMLmapping
%   \getvalue{\e!stop setuptext}}

\def\showSETUPrecord
  {\getvalue{\e!start setuptext}
     \tttf
     \nohyphens
     \veryraggedright
     \startXMLmapping [one]
       \doglobal\newcounter\currentSETUPargument
       \global\let\maximumSETUPargument\currentSETUPargument
       \bgroup
         \doifXMLop{generated}{yes}
           \doifnothing
             {\@@stptext}
             {\ttsl}%
         \doifelseXMLop{type}{environment}
           {\tex{\e!start}}
           {\tex{}}%
         \ignorespaces
         \doiftextelse
           {\@@stptext}
           {\@@stptext}
           {\ignorespaces\XMLflush{cd:sequence}}%
         \ignorespaces
       \egroup
%       \doifelseXMLempty{cd:arguments}% VZ: Why??? it spoils \startA...\stopA
%         {}
         {\bgroup
            \setbox0=\hbox{\XMLflush{cd:arguments}}%
            \global\let\maximumSETUPargument\currentSETUPargument
            \doglobal\newcounter\currentSETUPargument
            \ignorespaces\XMLflush{cd:arguments}%
            \doif{\XMLpar{cd:command}{type}{}}{environment}
              {\hskip.5em\unknown\hskip.5em
               \doifXMLop{generated}{yes} % VZ
                 \doifnothing             % VZ
                   {\@@stptext}
                   {\ttsl}
               {\tex{\e!stop}}\ignorespaces
               \doiftextelse
                 {\@@stptext}
                 {\@@stptext}
                 {\ignorespaces\XMLflush{cd:sequence}}}%
%            % VZ new
%            \hfill
%              \def\tmp{%
%                \doiftextelse{\@@stptext}%
%                  {\@@stptext}%
%                  {\ignorespaces\XMLflush{cd:sequence}}%
%                }%
%              \at[pgref:stp:\tmp]%
%            % VZ new end
            \endgraf
          \egroup
         %\bgroup
         %  \tx
         %  \doif{\XMLpar{cd:command}{interactive}{}}{yes}      {\quad INTERACTIVE}%
         %  \doif{\XMLpar{cd:command}{interactive}{}}{exclusive}{\quad INTERACTIVE ONLY}%
         %\egroup
        \startXMLmapping [two]
          \bgroup
            \doglobal\newcounter\currentSETUPargument
            \blank[\v!line]
            \switchtobodyfont[small] % kan sneller
            \ignorespaces\XMLflush{cd:arguments}\endgraf
          \egroup
        \stopXMLmapping}
     \stopXMLmapping
   \getvalue{\e!stop setuptext}}

\defineXMLenvironmentsave [cd:sequence]  \ignorespaces \ignorespaces
\defineXMLenvironmentsave [cd:arguments] \ignorespaces \ignorespaces

% VZ here! + setXvalue!
\defineXMLenvironmentsave [cd:define] [name=]
  {}
  {\setxvalue{cd:def:\XMLop{name}}{\XMLflush{cd:define}}}

%D This is the first pass; here we generate the top line.

\newcounter\currentSETUPargument
\def\currentSETUPwidth{0pt}

% environmentsave ?

\startXMLmapping [one]

\defineXMLenvironmentsave [cd:string] [value=]
  {\getinterfacecomponent{string}{\XMLop{value}}\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:variable] [value=]
%  {{\expanded{\setupintfont{\getinterfacecomponent{variable}{\XMLop{value}}}}}\ignorespaces}
  {{\expanded{\setupvarfont{\getinterfacecomponent{variable}{\XMLop{value}}}}}\ignorespaces}% VZ
  {\ignorespaces}

% moet een standaard type worden

\defineXMLenvironmentsave [cd:assignments] [list=,state=]
  {\showSETUPassignment\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:keywords] [list=,state=]
  {\showSETUPkeyword\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:content] [list=,state=]
  {\showSETUPcontent\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:displaymath] [list=,state=]
  {\showSETUPdisplaymath\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:index] [list=,state=]
  {\showSETUPindex\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:math] [list=,state=]
  {\showSETUPmath\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:nothing] [list=,state=]
  {\showSETUPnothing\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:file] [list=,state=]
  {\showSETUPfile\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:position] [list=,state=]
  {\showSETUPposition\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:reference] [list=,state=]
  {\showSETUPreference\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:csname] [list=,state=]
  {\showSETUPcsname\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:destination] [list=,state=]
  {\showSETUPdestination\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:triplet] [list=,state=]
  {\showSETUPtriplet\ignorespaces} {\ignorespaces}

\defineXMLenvironmentsave [cd:word] [list=,state=]
  {\showSETUPword\ignorespaces} {\ignorespaces}

\stopXMLmapping

%D This is the second pass; here we generate the table.

\startXMLmapping [two]

\def\startfirstSETUPcolumn#1%
  {\bgroup
   \advance\leftskip 2em
   \noindent\llap{\hbox to 2em{#1\hss}}}

\def\stopfirstSETUPcolumn
  {\endgraf
   \egroup}

\def\startsecondSETUPcolumn#1#2%
  {\bgroup
   \advance\hangindent \currentSETUPwidth
   \advance\hangindent 2.5em
   \noindent \hbox to \hangindent{#1\hss\hbox to 2.5em{\hss#2\hss}}}

\def\stopsecondSETUPcolumn
  {\endgraf
   \egroup}

\def\secondSETUPcolumn#1#2%
  {\startsecondSETUPcolumn{#1}{#2}\stopsecondSETUPcolumn}

\def\previousSETUPargument{\currentSETUPargument}

%% VZ move above!
%\defineXMLenvironmentsave [cd:define] [name=]
%  {}
%  {\setevalue{cd:def:\XMLop{name}}{\XMLflush{cd:define}}}

\defineXMLsingular [cd:resolve] [name=]
  {\getvalue{cd:def:\XMLop{name}}}

\defineXMLenvironmentsave [cd:assignments]
  {}
  {\xdef\currentSETUPwidth{0pt}%
   \bgroup
   \defineXMLenvironment [cd:parameter] [name=]
     {\setbox0=\hbox{\potentialXMLentity{\getinterfacecomponent{constant}{\XMLop{name}}}}%
      \ifdim\wd0>\currentSETUPwidth\xdef\currentSETUPwidth{\the\wd0}\fi}%
     {}
   \setbox0=\vbox{\XMLflush{cd:assignments}}%
   \egroup
   \startfirstSETUPcolumn{\showSETUPnumber}%
     \doifelseXMLempty{cd:assignments}
       {\secondSETUPcolumn{\c!setup!text!{see} \previousSETUPargument}{}}
       {\ignorespaces
        \XMLflush{cd:assignments}%
        \let\previousSETUPargument\currentSETUPargument}%
   \stopfirstSETUPcolumn
   \blank[\v!halfline]
   \ignorespaces}

\defineXMLenvironmentsave [cd:keywords]
  {}
  {\startfirstSETUPcolumn{\showSETUPnumber}%
     \doifelseXMLempty{cd:keywords}
       {\secondSETUPcolumn{see \previousSETUPargument}{}}
       {\ignorespaces
        \XMLflush{cd:keywords}%
        \let\previousSETUPargument\currentSETUPargument}%
   \stopfirstSETUPcolumn
   \blank[\v!halfline]
   \ignorespaces}

\defineXMLenvironment [cd:parameter] [name=]
  {\startsecondSETUPcolumn{\potentialXMLentity{\getinterfacecomponent{constant}{\XMLop{name}}}}{=}%
   \ignorespaces}
  {\stopsecondSETUPcolumn
   \ignorespaces}

\defineXMLenvironmentsave [cd:constant] [type=,default=]
  {\doifXMLop{default}{yes}{\underbar}%
     {\potentialXMLentity{\getinterfacecomponent{variable}{\XMLop{type}}}}\quad\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:variable] [type=]
  {\potentialXMLentity{\getinterfacecomponent{variable}{\XMLop{type}}}\quad\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:inherit] [name=]
  {\secondSETUPcolumn{\c!setup!text!{inherits} \tex{}\getinterfacecomponent{string}{\XMLop{name}}}{}\ignorespaces}
  {\ignorespaces}

\def\simpleSETUPargument#1%
  {\startfirstSETUPcolumn{\showSETUPnumber}%
      \c!setup!internal!{#1}%
   \stopfirstSETUPcolumn}

\defineXMLenvironmentsave [cd:content] [list=,state=]
  {\simpleSETUPargument{content}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:displaymath] [list=,state=]
  {\simpleSETUPargument{display math}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:index] [list=,state=]
  {\simpleSETUPargument{index}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:math] [list=,state=]
  {\simpleSETUPargument{math}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:nothing] [list=,state=]
  {\simpleSETUPargument{nothing}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:file] [list=,state=]
  {\simpleSETUPargument{file name}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:position] [list=,state=]
  {\simpleSETUPargument{position}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:reference] [list=,state=]
  {\simpleSETUPargument{reference}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:csname] [list=,state=]
  {\simpleSETUPargument{csname}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:destination] [list=,state=]
  {\simpleSETUPargument{destination}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:triplet] [list=,state=]
  {\simpleSETUPargument{triplet}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\defineXMLenvironmentsave [cd:word] [list=,state=]
  {\simpleSETUPargument{word}\blank[\v!halfline]\ignorespaces}
  {\ignorespaces}

\stopXMLmapping

\defineXMLentity [cd:command]        {\c!setup!internal!{command}}
\defineXMLentity [cd:dimension]      {\c!setup!internal!{dimension}}
\defineXMLentity [cd:file]           {\c!setup!internal!{file}}
\defineXMLentity [cd:name]           {\c!setup!internal!{identifier}}
\defineXMLentity [cd:character]      {\c!setup!internal!{character}}
\defineXMLentity [cd:mark]           {\c!setup!internal!{mark}}
\defineXMLentity [cd:number]         {\c!setup!internal!{number}}
\defineXMLentity [cd:reference]      {\c!setup!internal!{reference}}
\defineXMLentity [cd:plural]         {\c!setup!internal!{plural}}
\defineXMLentity [cd:singular]       {\c!setup!internal!{singular}}
\defineXMLentity [cd:text]           {\c!setup!internal!{text}}
\defineXMLentity [cd:formula]        {\c!setup!internal!{formula}}
\defineXMLentity [cd:file]           {\c!setup!internal!{file}}
\defineXMLentity [cd:matrix]         {\c!setup!internal!{matrix}}
\defineXMLentity [cd:list]           {\c!setup!internal!{list}}
\defineXMLentity [cd:section]        {\c!setup!internal!{section}}

\defineXMLentity [cd:noargument]     {\c!setup!command!{}}
\defineXMLentity [cd:oneargument]    {\c!setup!command!{\#1}}
\defineXMLentity [cd:twoarguments]   {\c!setup!command!{\#1\#2}}
\defineXMLentity [cd:threearguments] {\c!setup!command!{\#1\#2\#3}}

%D Todo:

\defineXMLprocess [cd:choice]

%D Auxiliary.

\setuplabeltext[en][optional=optional]            % VZ ??? language or
\setuplabeltext[cz][optional=voliteln\eacute{}]   %        interface

\unexpanded\def\showSETUP#1#2%
  {\bgroup
   \doglobal\increment\currentSETUPargument
   \setbox0=\hbox
     {\doifelseXMLop{list}{yes}{#2}{#1}}%
   \setbox2=\hbox to \wd0
     {\hss
      \raise1ex\hbox
        {\tx\ifcase\maximumSETUPargument\relax
           \or*\else\currentSETUPargument
         \fi}%
      \hss}%
   \setbox4=\hbox to \wd0
     {\hss
      \lower2ex\hbox
        \bgroup
          \txx\doifXMLop{optional}{yes}{\c!setup!internal!{optional}}%
%          \txx\doifXMLop{optional}{yes}{\labeltext{optional}}% VZ ???
        \egroup
      \hss}%
   \ht2\ht\strutbox
   \dp4\dp\strutbox
   \hskip.5em\hsmash{\box0}\hsmash{\box4}\box2%
   \egroup}

\def\showSETUPnumber
  {\doglobal\increment\currentSETUPargument
   \hbox to 2em
     {\ifcase\maximumSETUPargument\relax
        \or*\else\currentSETUPargument
      \fi
      \hss}}

\def\showSETUPassignment {\showSETUP
  {[.\lower.5ex\hbox{=}.]}
  {[..,.\lower.5ex\hbox{=}.,..]}}

\def\showSETUPkeyword {\showSETUP
  {[...]}
  {[...,...]}}

\def\showSETUPargument {\showSETUP
  {\leftargument..\rightargument}
  {\leftargument..,...,..\rightargument}}

\def\showSETUPdisplaymath {\showSETUP
  {\$\$...\$\$}
  {\$\$...\$\$}}

\def\showSETUPindex {\showSETUP
  {\leftargument...\rightargument}
  {\leftargument..+...+..\rightargument}}

\def\showSETUPmath {\showSETUP
  {\$...\$}
  {\$...\$}}

\def\showSETUPnothing {\showSETUP
  {...}
  {}}

\def\showSETUPfile {\showSETUP
  {~...~}
  {}}

\def\showSETUPposition {\showSETUP
  {(...)}
  {(...,...)}}

\def\showSETUPreference {\showSETUP
  {[...]}
  {[...,...]}}

\def\showSETUPcsname {\showSETUP
  {{\c!setup!command!{}}}
  {}}

\def\showSETUPdestination {\showSETUP
  {[\leftargument..[ref]\rightargument]}
  {[..,\leftargument..[ref,..]\rightargument,..]}}

\def\showSETUPtriplet {\showSETUP
  {[x:y:z=]}
  {[x:y:z=,..]}}

\def\showSETUPword {\showSETUP
  {\leftargument...\rightargument}
  {\leftargument.. ... ..\rightargument}}

\def\showSETUPcontent {\showSETUP
  {\leftargument...\rightargument}
  {\leftargument.. ... ..\rightargument}}

%\def\c!par!{\c!setup!internal!{endofpar}}
%\def\c!repeat!{\c!opt!{{\setupvarfont n}*}}
%\showSETUP\def\c!par!{\texescape par}
%\showSETUP\def\c!sep!{\texescape\texescape}
%\def\c!par!{\addtypespec{delimiter}{par}}       % \par
%\def\c!sep!{\addtypespec{separator}{backslash}} % \\
%\def\c!repeat!{}
%\def\c!tex!#1{\addtypespec{command}{#1}\doanother{tex}}

\startXMLmapping[zero]

%\defineXMLenvironmentsave [cd:command] [name=,type=,generated=,interactive=,variant=]
%  {}
%  {\doifelseXMLop{type}{environment}
%     {\edef\currentSETUPname{start\getinterfacecomponent{string}{\XMLop{name}}}}
%     {\edef\currentSETUPname{\getinterfacecomponent{string}{\XMLop{name}}}}%
%   \doifsomething{\XMLop{variant}}
%     {\edef\currentSETUPname{\currentSETUPname:\XMLop{variant}}}% like setupinterlinespace:1
%   \doifXMLop{generated}{yes}
%     {\edef\currentSETUPname{\currentSETUPname*}}%
%   \doglobal\saveXMLdatainelement{stp:\currentSETUPname}{cd:command}{cd:command}%
%   \expanded{\eachtexcommand[stp:x:\currentSETUPname]{\currentSETUPname}}%
%   \expanded{\texcommand    [stp:y:\currentSETUPname]{\currentSETUPname}}}

\defineXMLenvironmentsave [cd:command] [name=,type=,generated=,interactive=,variant=]
  {}
  {\doifelseXMLop{type}{environment}
     {\edef\currentSETUPname{\e!start\getinterfacecomponent{string}{\XMLop{name}}}}
     {\edef\currentSETUPname{\getinterfacecomponent{string}{\XMLop{name}}}}%
   \doifsomething{\XMLop{variant}}
     {\edef\currentSETUPname{\currentSETUPname:\XMLop{variant}}}% like setupinterlinespace:1
   \doifXMLop{generated}{yes}
     {\edef\currentSETUPname{\currentSETUPname}}%
   \doglobal\saveXMLdatainelement{stp:\currentSETUPname}{cd:command}{cd:command}%
   \expanded{\eachtexcommand[stp:x:\currentSETUPname]{\currentSETUPname}}%
   \expanded{\texcommand    [stp:y:\currentSETUPname]{\currentSETUPname}}}

\stopXMLmapping

\def\loadsetups{\complexorsimple\loadsetups}

\def\simpleloadsetups
  {\doifnotmode{no-setup-main}
     {\complexloadsetups[cont-en.xml]}}

\def\complexloadsetups[#1]%
  {\doifnotmode{no-setup-all}
     {\doifsomething{#1}
        {\startXMLmapping[zero]
         \expanded{\processXMLfilegrouped{#1}}%
         \stopXMLmapping}}}

\defineXMLsingular [cd:include] [file=]
  {\complexloadsetups[\XMLop{file}]}

\protect \endinput
