%^^A* copyright
% \iffalse
%
%   This program is part of the Frankenstein bundle for LaTeX2e.
%
%   Copyright (C) 1995, 1996 Matt Swift <swift@bu.edu>
%
%   This program is free software; you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation; either version 2 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this program; if not, write to the Free Software
%   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
%      NOTE:  I am willing to specially license this code.
%             Please simply contact me with your proposal.
%
%^^A   NOTE:  \DocInput will start reading after this \fi:
% \fi  
%
%^^A* checks
%
%^^A NOTE:  The character table, with two %'s, will get written to all files.
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \CheckSum{67}
%
% \begin{abstract}
%   The \cs\lips command generates text ellipses that are closer to what
%   \booktitle{The Chicago Manual} suggests than what \cs\dots produces.
% \end{abstract}
%
% \part{Discussion}
%
% \DescribeMacro{\lips}
% The macro \cs\lips should be used for all text ellipses, that is, those that
% are not part of a mathematical expression.   
%
% \booktitle{The Chicago Manual} does not acknowledge different spacings after
% different marks of punctuation, distinguish interword from intersentence
% space, or give rules about where to break a line near an ellipsis.  Given a
% context where such spaces do vary and rules for linebreaks can be given, I
% arrived at the following rules for handling them around ellipses.
% \begin{enumerate}
% \item Pre-, post-, and intra-ellipsis space is normal intra-word space, which
%       should be 3-to-em.
% \item When non-period punctuation $p$ follows \cs\lips, $p$ is followed by
%       the space that normally follows it.
% \item A period following \cs\lips is treated as if the period preceded
%       \cs\lips.  Conceptually, an ellipsis never precedes a period, so
%       conceptually there is only one case, and it is convenient to be able to
%       type either \code{\lips.} or \code{.\lips}.
% \item Lines are a tiny bit breakable before ellipses, and a tiny bit
%       breakable after ellipses that are not followed by punctuation.
% \end{enumerate}
%
% Here are examples of correct usage and a comparison with \cs\dots.  You can
% substitute `?', `.', `:', `,' or `:' for the exclamation point.  There can be
% additional spaces after \cs\lips, just like after any command name.
% \begin{center}
% \DeleteShortVerb{\|}
% \begin{tabular}{lc}
% \bfseries source & \bfseries \hspace*{4em} result
% \end{tabular}\par
% \par
% \begin{tabular}{|lp{1in}|}
% \hline
% \verb*|Hello\lips. And|   & Hello\lips. And   \\\hline
% \verb*|Hello \lips. And|  & Hello \lips. And   \\\hline
% \verb*|Hello.\lips And|   & Hello.\lips And   \\\hline
% \verb*|Hello. \lips And|  & Hello. \lips And   \\\hline
% \verb*|one,\lips, three|  & one,\lips, three \\\hline
% \verb*|one, \lips, three| & one, \lips, three \\\hline
% \verb*|Hello\lips and|    & Hello\lips and    \\\hline
% \verb*|Hello \lips and|   & Hello \lips and    \\\hline
% \verb*|Hello!\lips And|   & Hello!\lips And   \\\hline
% \verb*|Hello! \lips And|  & Hello! \lips And   \\\hline
% \end{tabular}
% \par
% \begin{tabular}{lc}
% \bfseries source & \bfseries \hspace*{4em} result
% \end{tabular}\par
% \par
% \begin{tabular}{|lp{1in}|}
% \hline
% \verb*|Hello\dots. And|   & Hello\dots. And   \\
% \verb*|Hello\lips. And|   & Hello\lips. And   \\\hline
% \verb*|Hello \dots. And|  & Hello \dots. And   \\
% \verb*|Hello \lips. And|  & Hello \lips. And   \\\hline
% \verb*|Hello.\dots And|   & Hello.\dots And   \\
% \verb*|Hello.\lips And|   & Hello.\lips And   \\\hline
% \verb*|Hello. \dots And|  & Hello. \dots And   \\
% \verb*|Hello. \lips And|  & Hello. \lips And   \\\hline
% \verb*|one,\dots, three|  & one,\dots, three  \\
% \verb*|one,\lips, three|  & one,\lips, three \\\hline
% \verb*|one, \dots, three| & one, \dots, three \\
% \verb*|one, \lips, three| & one, \lips, three \\\hline
% \verb*|Hello\dots and|    & Hello\dots and    \\
% \verb*|Hello\lips and|    & Hello\lips and    \\\hline
% \verb*|Hello \dots and|   & Hello \dots and    \\
% \verb*|Hello \lips and|   & Hello \lips and    \\\hline
% \verb*|Hello!\dots And|   & Hello!\dots And   \\
% \verb*|Hello!\lips And|   & Hello!\lips And   \\\hline
% \verb*|Hello! \dots And|  & Hello! \dots And   \\
% \verb*|Hello! \lips And|  & Hello! \lips And   \\\hline
% \end{tabular}
% \end{center}
% \MakeShortVerb{\|}
% 
% \caveat{Notice that \cs\lips does the right thing after \cname{par}, but after
% \cs\indent or \cs\noindent there is an extra preceding space.  Suggestions on
% how to handle this problem are welcome.}
% \begin{quotation}
% \hrule
%  \par \lips and (|\par \lips and|)
%  \par and (|\par and|)
% \hrule
%  \par\indent \lips (|\par\indent \lips and|)
%  \par\indent and (|\par\indent and|)
% \hrule
%  \par\noindent \lips and (|\par\noindent \lips and|)
%  \par\noindent and (|\par\noindent and|)
% \hrule
%  \par And.\lips \par (|\par And.\lips \par|)
%  \par And. \par (|\par And. \par|)
% \hrule
% \end{quotation}
%
% The examples above are inside a \env{quotation} environment.  They need
% testing outside of this also, so we repeat them here:
%
% \hrule
%  \par \lips and (|\par \lips and|)
%  \par and (|\par and|)
% \hrule
%  \par\indent \lips (|\par\indent \lips and|)
%  \par\indent and (|\par\indent and|)
% \hrule
%  \par\noindent \lips and (|\par\noindent \lips and|)
%  \par\noindent and (|\par\noindent and|)
% \hrule
%  \par And.\lips \par (|And.\lips \par|)
%  \par And. \par (|And. \par|)
% \hrule
%
% Also I test here some random things: \cs\lips before \cs\\, before
% \package{shortvrb}'s verbatim chars, before a tie, before punctuation
% transparent to spacefactors (e.g. `)').
%
% \DeleteShortVerb{\|}
% \begin{tabular}{|lp{2in}|}
% \hline
%   \verb*|Hello.\lips \\|   & Hello.\lips \\
% \hline
%   \verb*|One two three.\lips~tiedword|  &  One two three.\lips~tiedword \\
% \hline
%   \verb*|(One two three.\lips) Next.|   & (One two three.\lips) Next. \\
% \hline
%   \verb*|(One two three.\lips)\ Next.|  & (One two three.\lips)\ Next. \\
% \hline
% \end{tabular}
% \MakeShortVerb{\*}
%
% One two three.\lips *shortverb verb stuff*.  %
% (*One two three.\lips |shortverb verb stuff|*.)
%
% \DeleteShortVerb{\*}
% \MakeShortVerb{\|}
%
% \StopEventually{}
%
% \part{Implementation}
%
% \section{Version control}
%
%  \begin{macro}{\fileinfo}
%  \begin{macro}{\fileversion}
%  \begin{macro}{\filedate}
%  \begin{macro}{\docdate}
%  \begin{macro}{\PPOptArg}
% These definitions must be the first ones in the file.
%    \begin{macrocode}
\def\fileinfo{Chicago Manual text ellipses (Frankenstein's lips)}
\def\DoXNeeDME{}
\def\fileversion{v1.2}
\def\filedate{1996/09/04}
\def\docdate{1996/09/04}
\edef\PPOptArg {%
  \filedate\space \fileversion\space \fileinfo
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% Stop right here if we're just loading the file's information, and don't want
% to load this code for typesetting its documentation (only makes sense for
% certain packages).  The |JuStLaAdInFoRmAtIoN| flag will be set by the
% documentation driver; the |DoXNeeDME| flag will be set in the
% \ext{dtx} file, and will appear above if it's set.
%    \begin{macrocode}
\makeatletter
\@ifundefined{JuStLoAdInFoRmAtIoN} {%
  }{% ELSE
  \@ifundefined{DoXNeeDME} {%
    }{% ELSE
    \UndefineCS\JuStLoAdInFoRmAtIoN
    \usepackage{lips}%
  }
  \makeatother
  \endinput
}
%    \end{macrocode}
%
% Now we check for \LaTeX2e and declare the package.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lips}[\PPOptArg]
%    \end{macrocode}
%
% ^^A NOTE: We have to compensate for the above backslashes, which are not
% ^^A actually in the doctex file I work on.
%%
% \AddToCheckSum{26}
% 
% \makeatletter
%   \@ifundefined{DoXNeeDME} {} {\AddToCheckSum{2}}
% \makeatother
%
%
% \section{The macro}
%
% \begin{macro}{\lips}
% \mbox{}
%    \begin{macrocode}
\newcommand\lips {}
\let\lips\relax
\DeclareRobustCommand\lips {%
  \ifmmode
    \def\sc@t@a {%
      \PackageError{lips}{Don't use \protect\lips \space in math mode.}%
    }%
  \else
    \ifvmode
      \def\sc@t@a {%
        \leavevmode
        .\nobreak\ .\nobreak\ .\nobreak\ %
      }%
    \else
      \let\sc@t@a\sc@lips@hmode
    \fi
  \fi
  \sc@t@a
}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\sc@lips@hmode}
%  \begin{macro}{\GobbleIgnoreSpaces}
% The horizontal mode case.
%    \begin{macrocode}
\newcommand\sc@lips@hmode {%
  \unskip
  \@ifnextchar . {%
      .\penalty9999\ .\nobreak\ .\nobreak\ .\penalty9999\ %
      \GobbleIgnoreSpaces
    }{% ELSE
    \penalty9999\ .\nobreak\ .\nobreak\ .%
    \futurelet\sc@t@a\sc@lips@check@punct
  }%
}
\newcommand\GobbleIgnoreSpaces [1] {%
  \ignorespaces
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\sc@lips@check@punct}
% Add a nonbreakable space if \cname{sc@t@a} is punctuation; add slightly
% breakable space otherwise.
%    \begin{macrocode}
\newcommand\sc@lips@check@punct {%
  \ifcat.\sc@t@a%
    \nobreak\ %
  \else
    \penalty9999\ %
  \fi
}
%    \end{macrocode}
%  \end{macro}
%
% You might want to compare the \LaTeX{} version (as of 95/12/01).
% \cname{fontdimen3} is the interword stretchability, not interword space.
% \begin{codeexample}
% \DeclareTextCommandDefault{\textellipsis}{%
%   .\kern\fontdimen3\font
%   .\kern\fontdimen3\font
%   .\kern\fontdimen3\font
% }
% \def\mathellipsis{\mathinner{\ldotp\ldotp\ldotp}}
% \DeclareRobustCommand{\dots}{%
%   \ifmmode\mathellipsis\else\textellipsis\fi
% }
% \let\ldots\dots
% \end{codeexample}
%
% \Finale
