%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Mario Wolczko",
%%%     version         = "2",
%%%     date            = "21 May 1992",
%%%     time            = "21:10:02 BST",
%%%     filename        = "vdmindex.sty",
%%%     address         = "Dept of Computer Science
%%%                        The University of Manchester
%%%                        Oxford Road
%%%                        Manchester M13 9PL
%%%                        UK",
%%%     telephone       = "+44-61-275-6146",
%%%     FAX             = "+44-61-275-6236",
%%%     checksum        = "16947 78 289 2980",
%%%     email           = "mario@madarch (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "LaTeX, VDM specification language, indexing",
%%%     supported       = "yes",
%%%     docstring       = "Modifies the behaviour of the VDM style to
%%%     facilitate indexing of types, functions and operations.",
%%%  }
%%% ====================================================================
%
% The makeidx and ifthen styles must also be included in the style options when
% using this style, eg:
%	\documentstyle[vdm,makeidx,ifthen,vdmindex,12pt...
%	\makeindex
% See the makeindex manual for more detail on how indexing works.
%
% Under normal use, an index of all \type, {record}, {fn} and {op}
% names will be written to a .idx file.  After this is done, the shell
% script vdmindex should be run, generating typeidx.ind and fnidx.ind,
% which are then subsequently included using \include, eg:
%  \section{Index to Types}
%  \input{typeidx.ind}
%
%  \section{Index to Functions}
%  \input{fnidx.ind}
%
% Any type, record, function or operation can be excluded from the
% index by placing the command \noindex within the environment (or
% before, for \type).
%
{\makeatother\global\let\atletter@}

% stuff to index names
\newcommand{\@doindex}{yes}
\def\noindex{\gdef\@doindex{no}}
\def\doindex{\gdef\@doindex{yes}}

\def\postOperationHook{%
  \ifthenelse{\equal{\@doindex}{yes}}%
	{\index{op-\the\@operationName\atletter$\the\@operationName$}}%
	{\doindex}%
  \penalty\postOperationPenalty}
\def\postFunctionHook{%
  \ifthenelse{\equal{\@doindex}{yes}}%
	{\index{fn-\the\@fnName\atletter$\the\@fnName$}}%
	{\doindex}%
  \penalty\postFunctionPenalty}
\def\postTypeHook{\ifthenelse{\equal{\@doindex}{yes}}%
	{\index{type-\the\@typeName\atletter$\the\@typeName$}}%
	{\doindex}}
\def\postRecordHook{%
  \ifthenelse{\equal{\@doindex}{yes}}%
	{\index{rec-\the\@recordName\atletter$\the\@recordName$}}%
	{\doindex}%
  \penalty\postRecordPenalty}

% this overrides LaTeX's theindex env, which generates "Index"
% and goes into two column mode.
\def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
%\columnseprule \z@
%\columnsep 35pt%\twocolumn[\@makeschapterhead{Index}]
%    \@mkboth{INDEX}{INDEX}\thispagestyle{plain}
    \parindent\z@
    \parskip\z@ plus .3pt\relax\let\item\@idxitem}