# [dev-context] Nested \setupXXX commands

Wolfgang Schuster schuster.wolfgang at gmail.com
Tue Mar 26 19:11:41 CET 2013

Hi Hans,

there is a problem with the command handler and nested \setup… commands.

In the following example the setting for the “two” environment are ignored.

<example>
\defineenumeration[one][text=One]
\defineenumeration[two][text=Two]

\setupenumeration[one,two][alternative=serried,color=red]

\starttext

\startone
First enumeration.
\stopone

\starttwo
Second enumeration.
\stoptwo

\stoptext
</example>

The reason for this behavior is the \setupcounter call in \everysetupenumeration.

When you look at the internal code for \setupenumeration (mult-aux.mkiv) you see that the first
element in \setupernumeration (i.e. “one”) is processed with \mult_interfaces_with_comma_list_element,
at the end of this macro \everysetupenumeration. At this point \setupcounter is used which
redefines \mult_interfaces_with_comma_list_element. This redefined version is used for the next
element (i.e. “two”) in \setupenumeration and the values are no passed (“alternative” and “color”)
to \setupcounter.

\unexpanded\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8%
{\ifx#3\relax\let#3\empty\fi
\unexpanded\def#2{\dodoubleempty#4}%
\unexpanded\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it
\newtoks#5%
\newtoks#8%
\unexpanded\def#4[##1][##2]% maybe helper
{\let#7#3%
\ifsecondargument
\def\mult_interfaces_with_comma_list_element####1% we will have a simple one as well
{\edef#3{####1}%
\mult_interfaces_get_parameters{#1#3:}[##2]%
\the#5}%
\processcommalist[##1]\mult_interfaces_with_comma_list_element
\else
\let#3\empty
\mult_interfaces_get_parameters{#1:}[##1]%
\the#5%
\fi
\let#3#7%
\the#8}}

Wolfgang