%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 ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\newcontextversion{2017.05.15 21:48}

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

% \usemodule[newotf]
% \usemodule[oldotf]

\unprotect

% \writestatus\m!system{beware: some patches loaded from cont-new.mkiv}

% \attribute152\zerocount : marks ... lots of sweeps so best early in list

%D Maybe:

% \appendtoks
%     \inheritmaintextcolor
% \to \everybeforenoteinsert

% \appendtoks
%     \inheritmaintextcolor
% \to \everymargindatacontent

% This is experimental; if this changes we need to adapt the mb-mp style too. It's
% not in the core yet.
%
% \def\ActionY{\blank\inleftmargin{\shownofparlines}}
% \def\ActionN{\inleftmargin{\shownofparlines}}
%
% \saveparnumber
% ...
% \checknofparlines
% \ifnum\nofparlines<2
%   \ActionY
% \else
%   \ActionN
% \fi
% ...

\newcount\c_typo_par_current
\newcount\c_typo_par_saved
\newcount\c_typo_par_lines
\newcount\c_typo_par_temp

\appendtoks
    \advance\c_typo_par_current\plusone % local
   %\llap{\infofont[\the\c_typo_par_saved:\the\c_typo_par_current]\quad}%
\to \everypar

\unexpanded\def\saveparnumber % the upcoming number
  {\c_typo_par_saved\c_typo_par_current} % local

\def\savedparnumber  {\number\c_typo_par_saved}
\def\currentparnumber{\number\c_typo_par_current}
\def\nofparlines     {\number\c_typo_par_lines}
\let\savedparstate   \empty

\unexpanded\def\shownofparlines
  {\dontleavehmode\hbox\bgroup
   \infofont[\savedparstate]%
   \egroup}

\unexpanded\def\checknofparlines
  {\c_typo_par_temp\numexpr\c_typo_par_saved+\plusone\relax
   \ifhmode
     \c_typo_par_lines\zerocount
     \edef\savedparstate{\number\c_typo_par_temp:\number\c_typo_par_current\space-}%
   \else\ifnum\c_typo_par_current=\c_typo_par_temp
     \c_typo_par_lines\prevgraf
     \edef\savedparstate{\number\c_typo_par_temp:\number\c_typo_par_current\space\number\prevgraf}%
   \else\ifnum\c_typo_par_temp>\c_typo_par_current
     \c_typo_par_lines\zerocount
     \edef\savedparstate{\number\c_typo_par_temp:\number\c_typo_par_current\space-}%
   \else
     \c_typo_par_lines\maxdimen
     \edef\savedparstate{\number\c_typo_par_temp:\number\c_typo_par_current\space+}%
   \fi\fi\fi}

%D Maybe:

\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox}
\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop}

%D Needs some work:

\unexpanded\def\startgridcorrection
  {\dosingleempty\spac_grid_correction_start}

\def\spac_grid_correction_start[#1]%
  {\ifgridsnapping
     \snaptogrid[#1]\vbox\bgroup
   \else
     \startbaselinecorrection
   \fi}

\unexpanded\def\stopgridcorrection
  {\ifgridsnapping
     \egroup
   \else
     \stopbaselinecorrection
   \fi}

\unexpanded\def\checkgridsnapping
  {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi}

%D Probably obsolete:

\unexpanded\def\startcolumnmakeup % don't change
  {\bgroup
   \getrawnoflines\textheight % raw as we cna have topskip
   \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax
     \bgroup
     \forgetall}

\unexpanded\def\stopcolumnmakeup
  {\egroup
   \dp\scratchbox\zeropoint
   \wd\scratchbox\textwidth
   \box\scratchbox
   \egroup
   \page_otr_command_synchronize_hsize}

%D Till we fixed all styles:

\let\\=\crlf

\protect \endinput
