%D \module
%D   [       file=cont-new,
%D        version=1995.10.10,
%D          title=\CONTEXT\ Miscellaneous Macros,
%D       subtitle=New Macros,
%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.

%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks and new features.

\unprotect

\writestatus{\m!systems}{beware: some patches loaded from cont-new.tex!}

%D A few local optimizations and new features:

\readfile {cont-loc} {} {} 

%D For Ton: 

\def\plaatsexterndocument[#1]% 
  {\def\doexternaldocument[##1][##2][##3]%
     {\readlocfile{##2}{}{}}%
   \getvalue{\v!file:::#1}}

%D For me: 

\beginTEX

\def\p!doifinstringelse#1#2%
  {\def\pp!doifinstringelse##1#1##2##3\war%
     {\csname if\if##2@fals\else tru\fi e\endcsname}%
   \expanded{\pp!doifinstringelse#2#1@@\noexpand\war}} % expand #2 here

\endTEX

\beginETEX \unless

\def\p!doifinstringelse#1#2%
  {\def\pp!doifinstringelse##1#1##2##3\war%
     {\unless\if##2@}%
   \expanded{\pp!doifinstringelse#2#1@@\noexpand\war}} % expand #2 here

\endETEX

%D For Willy's nested commented buffers:

\def\processnextbufferline#1#2#3%
  {\relax % checken waarom eerdere macro dit nodig heeft / supp-mps run
   \convertargument#1 \to\next
   \doifinstringelse{\delcharacter\texcommentsymbol}{\delcharacter\next}
     {\def\next{#3}}
     {\doifinstringelse{\endofblock}{\next}
        {\ifnum\nestedbufferlevel=0\relax % \relax ?
           \def\next{#2}%
         \else
           \decrement\nestedbufferlevel\relax
           \def\next{#3}%
         \fi}
        {\doifinstringelse{\beginofblock}{\next}
           {\increment\nestedbufferlevel\relax
            \def\next{#3}}
           {\def\next{#3}}}}%
   \next}

%D Some day:

% \definieermarkering[\v!margetitel]
%
% \def\complexmargewoord[#1][#2]#3%
%   {\doglobal\increment\margincontent
%    \stelinmargein[\margincontent][]% see next macro
%    \@EA\setgvalue\@EA{\@EA\??im\@EA\margincontent\@EA}\@EA
%      {\@EA\stelinmargein\@EA[\margincontent][]%  see next macro
%       \flushmargincontent[#1][#2]{#3}%
%       \markeer[\v!margetitel]{#3}}}

%D New indeed. Undocumented and under development.

\def\startsimplecolumns%
  {\dosingleempty\dostartsimplecolumns}

\def\dostartsimplecolumns[#1]%
  {\bgroup
   \getparameters[\??kl][\c!breedte=\hsize,\c!afstand=1em,\c!n=2,#1]%
   \setrigidcolumnhsize\@@klbreedte\@@klafstand\@@kln
   \setbox\scratchbox=\vbox\bgroup
   \forgetall}

\def\stopsimplecolumns%
  {\removelastskip
   \egroup
   \rigidcolumnbalance\scratchbox
   \egroup}

%D Aha.

\def\rigidcolumnbalance#1%
  {\global\chardef\rigidcolumnbox=#1\relax
   \ifnum\rigidcolumns=1
     \ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi\rigidcolumnbox
   \else
     \hbox to \savedrigidhsize % was \hsize
       {\vbadness=10000
        \tabskip\!!zeropoint
        \setbox\rigidcolumnbox=\vbox
          {\unvbox\rigidcolumnbox
           \unpenalty\removelastskip}% get rid of \blank's
       %\splittopskip=\openstrutheight
        \splittopskip=\!!zeropoint
       %\scratchdimen=\ht\rigidcolumnbox      % sensitive for overflow
       %\divide\scratchdimen by \rigidcolumns % therefore we need the hack:
        \scratchdimen=1pt
        \divide\scratchdimen by \rigidcolumns
        \expanded{\scratchdimen=\withoutpt{\the\scratchdimen}\ht\rigidcolumnbox}%
        \advance\scratchdimen by \ht\strutbox
        \valign{##\vfill\cr\dorigidcolumnsplits}}%
   \fi}

%D Is this a better default?

\def\doverbatimgoodbreak%
  {} % instead of {\ifoptimizeverbatim\penalty100\fi}

%D Hm:

\def\startgeheel%
  {\startregelcorrectie
   \insidefloattrue}

\def\stopgeheel
  {\stopregelcorrectie}

%D Under construction:

\def\resetpositions%
  {\let\someposition=\gobblesevenarguments   % old 
   \let\pxypos      =\gobblefourarguments    % new 
   \let\pxywhdpos   =\gobblesevenarguments}  % new

\resetpositions

%D The next line can be uncommented when Taco's extensions to
%D \quote {\TEX\ The Program} are used.

% \readfile {syst-eet} {} {}

\protect

\endinput
