\starttext

%D Suppose I have a document with three levels of headings|<| chapter,
%D section, and subsection. I want different separators for different levels,
%D say 1,2, etc. for chapter; 1-1, 1-2, etc., for sections and 1-1.1, 1-1.2
%D etc., for subsections. The present context approach of using
%D \starttyping
%D \setuphead[section][separator=-]
%D \setuphead[subsection][separator=.]
%D \stoptyping
%D does not work properly. See the output of the following

\setuphead[section][separator=-]
\setuphead[subsection][separator=.]


\chapter[chap]{First Chapter}
\section[sec]{First Section}
\subsection[subsec]{First Subsection}
As you may have noticed, \in[subsec] is the first subsubsection of
\in[sec], which in turn is the first section of \in[chap].

Notice that the all the separators in the subsection have changed, and the
separator is not honored in the references.

The reason that this happens is \tex{@@longsectionnumber} can not 
keep track of sectioning levels. One way to overcome this is to associate
the separator with \mono{section-x} rather than with \mono{head}. The
following patch does this, but I am not sure if it will break anything or
not.

\page

% Begin Patch

\setupsection[section-1][separator=.]
\setupsection[section-2][separator=.]
\setupsection[section-3][separator=.]
\setupsection[section-4][separator=.]
\setupsection[section-5][separator=.]
\setupsection[section-6][separator=.]
   
\unprotect
\def\@@longsectionnumber#1%
  {\ifreversesectionnumbers
     \@@shortsectionnumber{#1}%
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
      \csname\??se#1\c!separator\endcsname
       \csname\previoussection{#1}\c!number\endcsname
     \fi
   \else
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
     \csname\previoussection{#1}\c!number\endcsname%
     \csname\??se#1\c!separator\endcsname%
     \fi
     \@@shortsectionnumber{#1}%
   \fi}
\protect

% End Patch

%D Now let us see how we can get the desired output.
%D \startbuffer
%D \setupsection[section-3][separator=-]
%D \stopbuffer
%D \typebuffer
%D which gives the output o the next page
%D \getbuffer
%D \chapter[chap new]{First Chapter}
%D \section[sec new]{First Section}
%D \subsection[subsec new]{First Subsection}
%D As you may have noticed, \in[subsec new] is the first subsubsection of
%D \in[sec new], which in turn is the first section of \in[chap new].
%D \page

% Begin Patch

\setupsection[section-1][separator=.]
\setupsection[section-2][separator=.]
\setupsection[section-3][separator=.]
\setupsection[section-4][separator=.]
\setupsection[section-5][separator=.]
\setupsection[section-6][separator=.]
   
\unprotect
\def\@@longsectionnumber#1%
  {\ifreversesectionnumbers
     \@@shortsectionnumber{#1}%
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
      \csname\??se#1\c!separator\endcsname%AM: was .
       \csname\previoussection{#1}\c!number\endcsname
     \fi
   \else
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
     \csname\previoussection{#1}\c!number\endcsname%
     \csname\??se#1\c!separator\endcsname%AM: was .
     \fi
     \@@shortsectionnumber{#1}%
   \fi}
\protect

% End Patch

%D Now let us see how we can get the desired output.
%D \starttyping
%D \setupsection[section-3][separator=-]
%D \stoptyping
%D which gives the output on the next page

\setupsection[section-3][separator=-]

\chapter[chap new]{First Chapter}
\section[sec new]{First Section}
\subsection[subsec new]{First Subsection}
As you may have noticed, \in[subsec new] is the first subsubsection of
\in[sec new], which in turn is the first section of \in[chap new].

Notice that the section numbering as well as the reference numbering is
correct.

\stoptext
