% \iffalse
%
% Copyright 1999 the fontinst maintenance team and any individual 
% authors listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the fontinst system version 1.9.
% -----------------------------------------------------
% 
% It may be distributed under the terms of the LaTeX Project Public
% License, as described in lppl.txt in the base LaTeX distribution.
% Either version 1.0 or, at your option, any later version.
% 
% \fi
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fisource}%
   [2000/06/05 v1.38 Fontinst source documentation commands]

\CodelineIndex
\setcounter{IndexColumns}{2}
\setcounter{tocdepth}{2}
\DeclareRobustCommand\package[1]{\textsf{#1}}
\DeclareRobustCommand\eTeX{\(\varepsilon\)-\TeX}
\newcommand\missing[2]{%
   \marginpar{%
      \raggedleft\leavevmode\strut 
      Not in \texttt{#1}: \texttt{\string#2}\strut
      \index{Not in #1\actualchar Not in \string\texttt{#1}\levelchar
         \string#2\actualchar\string\verb\verbatimchar
         \string#2\verbatimchar\encapchar usage}%
   }%
}
\newcommand\ambiguity[1]{\leavevmode
   \textbf{#1\index{Ambiguity\encapchar usage}}%
   \marginpar{\raggedleft\textbf{\huge A}}%
}
\newcommand\question[1]{\leavevmode
   \textbf{#1\index{Question\encapchar usage}}%
   \marginpar{\raggedleft\textbf{\huge ?}}%
}
\AtBeginDocument{\catcode`\_=11}
\def\MakePrivateLetters{\catcode`\_=11\makeatletter}

%    \end{macrocode}
% 
% \begin{macro}{\meta}
%   \changes{1.30}{2000/01/02}{\cs{Meta} command (robust wrapper around 
%      \package{doc}'s \cs{meta}) added. (LH)}
%   \changes{1.31}{2000/02/10}{Command redefined so that it is robust 
%      itself. \cs{Meta} removed. (LH)}
% \begin{macro}{\meta@font@select}
%   \package{doc}'s |\meta| command is given a completely new 
%   definition which allows it to be robust. This is very handy for use 
%   in |\changes| notes and the like. Note that |\protect\meta| wouldn't 
%   work with \package{doc}'s traditional |\meta|, since it makes space 
%   active.
%   
%   The basic idea of this definition is to work \emph{with} \TeX's 
%   hyphenation mechanism in preventing hyphenation of words in the 
%   argument, rather than trying to lock it out by putting each word in 
%   an |\hbox|. Since \TeX\ records the current values of 
%   |\lefthyphenmin| and |\righthyphenmin| in each |\setlanguage| 
%   whatsit, even local changes of these just inside the |\meta| can be 
%   made to affect hyphenation of that piece of text. The maximal 
%   effective value these parameters can have is 63, but I think 9 works 
%   better since words of 18 letters or more probably need hyphenation.
%   
%   |\meta@font@select| can be redefined by a command, if it prefers 
%   some other font change. The most likely change is probably to use 
%   |\normalfont|\discretionary{}{}{}|\itshape| instead of the default 
%   definition.
%   \changes{1.33}{2000/02/26}{Macro added. (LH)}
%   \changes{1.35}{2000/03/25}{Don't make \cs{setlanguage} whatsits in 
%      restricted horizontal mode. (LH)}
%    \begin{macrocode}
\DeclareRobustCommand\meta[1]{%
  \(\langle\){%
     \ifinner \else
        \lefthyphenmin=9\righthyphenmin=9\setlanguage\language
     \fi
     \nobreak\hskip\z@skip
     \meta@font@select#1\/%
     \nobreak\hskip\z@skip
  }\ifinner\else \setlanguage\language \fi
  \(\rangle\)%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\meta@font@select{\itshape}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\cs}
%   This is \package{ltxdoc}'s normal |\cs|, but with a twist to make 
%   |\meta| produce better results when used in the argument.
%   \changes{1.33}{2000/02/26}{Redefinition added. (LH)}
%    \begin{macrocode}
\DeclareRobustCommand\cs[1]{%
   \texttt{%
      \def\meta@font@select{\normalfont\itshape}%
      \char`\\#1%
   }%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{environment}{isyntax}
%   |isyntax| is for ``informal'' syntax specifications, such as
%   \begin{quote}
%     A \meta{varchar command} can be one of\\
%     \begin{quote}
%       |\vartop|\marg{glyph}\\
%       |\varmid|\marg{glyph}\\
%       |\varbot|\marg{glyph}\\
%       |\varrep|\marg{glyph}
%     \end{quote}
%   \end{quote}
%   The implementation is based on that of the \texttt{verse} 
%   environment.It usually works just as fine with \texttt{quote}, but 
%   \texttt{isyntax} handles breaking long lines better (and more 
%   elegantly).
%   \changes{1.37}{2000/05/14}{Increased \cs{rightskip} stretchability 
%      and added setting of \cs{linepenalty}. (LH)}
%    \begin{macrocode}
\newenvironment{isyntax}{%
   \let\\\@centercr
   \list{}{%
      \itemsep \z@
      \itemindent -1.5em%
      \listparindent \itemindent
      \advance \leftmargin 1.5em%
   }%
   \advance \rightskip \z@\@plus0.7\linewidth \relax
   \linepenalty=100\relax
   \item\relax
}{\endlist}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{obsoletemacro}
%   The \texttt{obsoletemacro} environment is for getting the right 
%   heading on |\changes| comments that refer to macros which have been 
%   removed. It only updates the |\saved@macroname|.
%    \begin{macrocode}
\newenvironment{obsoletemacro}{\begingroup
   \catcode`\\12
   \MakePrivateLetters
   \obsolete@macro
}{}
\def\obsolete@macro#1{\endgroup
   \edef\saved@macroname{\string#1}%
}
%    \end{macrocode}
% \end{environment}
% 
% 
% \section{\texttt{macro}-like environments}
% 
% This subsection contains the definitions of a couple of environments 
% that, like \package{doc}'s \texttt{environment}, are for marking up the 
% document (what is defined and where). The definitions of these 
% environments are identical to that of \texttt{environment}, except 
% that the index entry texts are a little different.
% 
% \begin{macro}{\FI@identifier}
% \begin{macro}{\FI@pre@identifier}
%   The |\FI@identifier| macro is analogous to \package{doc}'s |\m@cr@|, 
%   but instead of passing |\iffalse| or |\iftrue| as the first 
%   argument, the caller should pass one of
%   \begin{quote}
%     \begin{tabular}{ll}
%       |I|& for integers (|\int|s)\\
%       |S|& for strings (|\str|s)\\
%       |W|& for switches (|\if|s)
%     \end{tabular}
%   \end{quote}
%   It is easy to extend this list, if necessary.
%   
%   The letters are used to get differently formatted index entries from 
%   the different environments defined below. |\Special|\-|Main|\-|FI|^^A
%   \-|Index| controls exactly what the difference between |I| and |S| 
%   entries are. |\Print|\-|FI|\-|Name| could be changed to make the 
%   two types presented differently when they are printed in the 
%   margin, but that is currently not done.
%    \begin{macrocode}
\def\FI@pre@identifier{%
   \begingroup\MakePrivateLetters\expandafter\endgroup \FI@identifier
}
%    \end{macrocode}
%    \begin{macrocode}
\def\FI@identifier#1#2{%
   \topsep=\MacroTopsep
   \trivlist
   \protected@edef\saved@macroname{#2}%
   \if@inlabel
      \toks@={}%
      \count@=\macro@cnt
      \loop \ifnum \count@>\z@
         \toks@=\expandafter{\the\toks@\hbox{\strut}}%
         \advance \count@ \m@ne
      \repeat
      \edef\makelabel##1{%
         \noexpand\llap{\vtop to\baselineskip{%
            \the\toks@\hbox{##1}\vss
         }}%
      }%
      \advance \macro@cnt \@ne
   \else
      \def\makelabel##1{\llap{##1}}%
      \macro@cnt=\@ne
   \fi
   \item[\PrintFIName{#1}{#2}]%
   \global\advance \c@CodelineNo \@ne
   \MainFIIndex{#1}{#2}\nobreak
   \global\advance \c@CodelineNo \m@ne
   \ignorespaces
}
%    \end{macrocode}
% \end{macro}\end{macro}
% 
% \begin{macro}{\MainFIIndex}
%   The |\MainFIIndex| macro is called as
%   \begin{quote}
%     |\MainFIIndex|\marg{type}\marg{name}
%   \end{quote}
%   \meta{name} is some identifier for which one or several index 
%   entries are to be made; it is assumed that \meta{name} only consists 
%   of `letter', `other', and possibly space tokens. \meta{type} is one 
%   of the letters listed in the comments to |\FI@identifier| and 
%   describe what \meta{name} is the name of. 
%    \begin{macrocode}
\providecommand\MainFIIndex[2]{%
   \@bsphack
   \if #1W
      \GeneralFIIndex{#2 W}{#2}{ (switch)\encapchar main}%
      \GeneralFIIndex{if#2}{\bslash if#2}{\encapchar main}%
      \GeneralFIIndex{#2true}{\bslash#2true}{\encapchar main}%
      \GeneralFIIndex{#2false}{\bslash#2false}{\encapchar main}%
   \else
      \GeneralFIIndex{#2 #1}{#2}{ (%
            \if #1Sstring\else integer\fi
         )\encapchar main%
      }%
   \fi
   \@esphack
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\GeneralFIIndex}
%   The |\GeneralFiIndex| macro is called as
%   \begin{quote}
%     |\GeneralFIIndex|\marg{key}\marg{verbatim}\marg{normal}
%   \end{quote}
%   It generates an index entry with \meta{key} as the sort key and 
%   \meta{verbatim}\meta{normal} as the entry text. \meta{verbatim} is 
%   made the argument of a |\verb*|, whereas \meta{normal} is given no 
%   special formatting. The index entry will be for the codeline number.
%    \begin{macrocode}
\providecommand\GeneralFIIndex[3]{%
   \special@index{#1\actualchar \string\verb \quotechar*\verbatimchar
      \quotechar#2\verbatimchar#3}%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\PrintFIName}
%   The |\PrintFIName| macro is called as
%   \begin{quote}
%     |\PrintFIName|\marg{type}\marg{name}
%   \end{quote}
%   \meta{name} is some identifier that is to be printed; it is 
%   assumed that \meta{name} only consists of `letter', `other', and 
%   possibly space tokens. \meta{type} is one of the letters listed in 
%   the comments to |\FI@identifier| and describe what \meta{name} is 
%   the name of. 
%   
%   The default definition does formatting identically to 
%   \package{doc}'s |\PrintEnvName| and pays no regard to the 
%   \meta{type} argument. It can be overridden by a definition in the 
%   \texttt{.cfg} file.
%    \begin{macrocode}
\providecommand\PrintFIName[2]{\strut\MacroFont#2\ }
%    \end{macrocode}
% \end{macro}
%   
% \begin{environment}{fiinteger}
% \begin{environment}{fistring}
% \begin{environment}{switch}
%   \changes{1.33}{2000/02/27}{Environment added. (LH)}
%    \begin{macrocode}
\newenvironment{fiinteger}{\FI@pre@identifier I}{\endtrivlist}
\newenvironment{fistring}{\FI@pre@identifier S}{\endtrivlist}
\newenvironment{switch}{\FI@pre@identifier W}{\endtrivlist}
%    \end{macrocode}
% \end{environment}\end{environment}\end{environment}
% 
% 
% \section{Changes of change history formating}
% 
% \begin{macro}{\@changes}
%   |\@changes| is redefined to change the sorting a little; the 
%   specific change is that the date will be used as sorting key at the 
%   |\subsubitem| level. This will probably make most sense if multiple 
%   changes is made to the same macro within the same version.
%    \begin{macrocode}
\def\changes@#1#2#3{%
   \protected@edef\@tempa{%
      \noexpand\glossary{%
         #1\levelchar
         \ifx\saved@macroname\@empty
           \space
           \actualchar
           \generalname
         \else
           \expandafter\@gobble
           \saved@macroname
           \actualchar
           \string\verb\quotechar*%
           \verbatimchar\saved@macroname
           \verbatimchar
         \fi:\levelchar
         #2\actualchar #3%
      }%
   }%
   \@tempa\endgroup\@esphack
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\multchanges}
%   \changes{1.32}{2000/02/22}{\cs{flushleftspace} between \cs{cs} 
%      items when typeset, instead of space. (LH)}
%   \changes{1.34}{2000/03/11}{\cs{notcs} marker allowed in 
%      \meta{commands}. (LH)}
%   The |\multchanges| commands is used to record a change to several 
%   macros. Its syntax is
%   \begin{quote}
%     |\multchanges|\marg{commands}\marg{version}\marg{date}^^A
%       \marg{description}
%   \end{quote}
%   The three last arguments are as the arguments of |\changes|. The 
%   \meta{commands} should be a nonempty sequence of commands, each 
%   command either a |\cs| or a |\notcs|, and each command with one 
%   argument. The change history entry generated by a 
%   |\multchanges| will be for all the macros (or whatever) listed in 
%   the first argument. |\cs| items will be typeset in typewriter font 
%   with a leading backslash, whereas |\notcs| items will receive no 
%   such special formatting.
%   
%   This method may have problems with active characters (since I've 
%   ignored some things the standard |\changes| do to accomodate these), 
%   but luckily \package{fontinst} hardly uses active characters 
%   anyway. Furthermore I don't think the \package{doc} way of dealing 
%   with them would be the right way here. Perhaps an active character 
%   should rather be entered in the \meta{commands} argument as 
%   |\active|\marg{code} or something?
%    \begin{macrocode}
\newcommand*\multchanges[4]{%
   \@bsphack
   \begingroup
      \def\cs##1{,\space##1}%
      \let\notcs=\cs
      \protected@xdef\@gtempa{%
         \expandafter\@gobbletwo#1\@empty\@empty\@empty
      }%
      \edef\cs{,\noexpand\flushleftspace
         \noexpand\protect
         \expandafter\noexpand\csname cs \endcsname
      }%
      \def\notcs##1{,\flushleftspace ##1}%
      \protected@xdef\@gtempa{%
         \@gtempa\actualchar
         \expandafter\@gobbletwo#1\@empty\@empty\@empty
      }%
   \endgroup
   \protected@edef\@tempa{%
      \noexpand\glossary{%
         #2\levelchar
         \@gtempa:\levelchar
         #3\actualchar #4%
      }%
   }%
   \@tempa
   \@esphack
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\flushleftspace}
%   The |\flushleftspace| command should typeset something which looks 
%   like a space when not broken at, and as an \texttt{3em plus 1fil} 
%   space when broken at. It also have to survive its use in 
%   |\multchanges|.
%   \changes{1.32}{2000/02/22}{Command added. (LH)}
%   \changes{1.38}{2000/06/05}{Modified finite penalty. (LH)}
%    \begin{macrocode}
\DeclareRobustCommand\flushleftspace{%
   \nobreak \hskip 3em\@plus 1fil%
   \penalty\@m \hskip -3em\@plus -1fil\ %
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{environment}{theglossary}
%    \begin{macrocode}
% \ifhave@multicol
%   \renewenvironment{theglossary}{%
%     \begin{multicols}\c@GlossaryColumns
%                      [\glossary@prologue][\GlossaryMin]%
%     \GlossaryParms \def\item{\@idxitem v\,}\ignorespaces}%
%    {\end{multicols}}
% \else
%   \renewenvironment{theglossary}{%
%       \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
%       \columnseprule \z@  \columnsep 35\p@
%       \twocolumn[\glossary@prologue]%
%       \GlossaryParms \def\item{\@idxitem v\,}\ignorespaces}
%     {\if@restonecol\onecolumn\else\clearpage\fi}
% \fi
%    \end{macrocode}
% 
%   If we want to use the glossary for some other information as well 
%   (here I am thinking primarily on collecting |\missing| notices) then 
%   perhaps we should insert the |v\,| in |\changes| instead. I would 
%   guess the 64 character limit isn't at all as usual as it was when 
%   the doc package documentation was written.
%   
%    \begin{macrocode}
\renewenvironment{theglossary}{%
%     \penalty\z@\vskip\GlossaryMin\@plus\z@\@minus\GlossaryMin
%     \penalty\z@\vskip-\GlossaryMin\@plus\z@\@minus-\GlossaryMin
    \glossary@prologue
    \GlossaryParms \let\item\@idxitem \ignorespaces
}{\par\bigskip}
%    \end{macrocode}
%   On second thoughts, the changes should be printed in one column. 
%   They're usually very hard to linebreak in narrow columns.
% \end{environment}
% 
% \begin{macro}{\firstsubsubitem}
%   The idea with |\firstsubsubitem| is that it should be like |\efill| 
%   |\subsubitem| if the paragraph is ended by a |\subsubitem| and like 
%   \verb*"\ " if it isn't. This is achieved by grabbing the paragraph 
%   into a macro and then prepend some suitable material to it when 
%   typesetting.
%   \changes{1.36}{2000/04/10}{Grabbing paragraph as list of tokens, 
%      rather than typeset text. (LH)} 
%    \begin{macrocode}
\newcommand\firstsubsubitem{%
   \begingroup
   \let\par\@fssi@par
   \let\subsubitem\@fssi@subsubitem
   \protected@edef\@tempa{\iffalse}\fi
}
%    \end{macrocode}
%    \begin{macrocode}
\def\@fssi@subsubitem{%
   \iffalse{\fi}%
   \nobreak\hfill\vadjust{\nobreak}%
   \penalty-\@M\vadjust{\penalty\@m}\nobreak\hskip -5pt\relax
   \@tempa
   \endgroup
   \subsubitem
}
%    \end{macrocode}
%   \multchanges{\cs{@fssi@par}}{2000/06/05}{1.38}{Replaced simple space 
%      by a more complicated sequence of penalties, vadjusts, and glue, 
%      to make it more like \cs{flushleftspace}. (LH)}
%    \begin{macrocode}
\def\@fssi@par{%
   \iffalse{\fi}%
   \nobreak \hskip \z@ \@plus 0.4\linewidth
   \vadjust{\nobreak}%
   \penalty500\hskip \z@ \@plus -0.4\linewidth\hskip 5pt\relax
   \penalty\z@\ \vadjust{\penalty\@m}%
   \nobreak\hskip -5pt\relax
   \@tempa
   \endgroup
   \par
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\GlossaryParms}
%    \begin{macrocode}
\def\GlossaryParms{%
   \parindent \z@
   \columnsep 15pt
   \parskip 0pt plus 1pt
   \rightskip 15pt plus 15pt
   \mathsurround \z@
   \parfillskip=-\rightskip
   \pretolerance=\tolerance
   \small
   \def\@idxitem{\par\hangindent 30pt v\,}%
   \def\subitem{\par\hangindent 30pt\hspace*{15pt}}%
   \def\subsubitem{\par\hangindent 30pt\hspace*{25pt}}%
   \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
}
%    \end{macrocode}
% \end{macro}
% 
\let\DescribeFamily\@gobble
% 
% 
% \section{Hack for removing ``Marginpar moved'' warning messages}
%
% Check if the definition matches the known. To be on the safe 
% side, only the known definition will be changed.
% 
%    \begin{macrocode}
\def\@tempa{\@next\@marbox\@currlist{\@cons\@freelist\@marbox
    \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
    \if@twocolumn
        \if@firstcolumn \@tempcnta\m@ne \fi
    \else
      \if@mparswitch
         \ifodd\c@page \else\@tempcnta\m@ne \fi
      \fi
      \if@reversemargin \@tempcnta -\@tempcnta \fi
    \fi
    \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
    \@tempdima\@mparbottom
    \advance\@tempdima -\@pageht
    \advance\@tempdima\ht\@marbox
    \ifdim\@tempdima >\z@
      \@latex@warning@no@line {Marginpar on page \thepage\space moved}%
    \else
      \@tempdima\z@
    \fi
    \global\@mparbottom\@pageht
    \global\advance\@mparbottom\@tempdima
    \global\advance\@mparbottom\dp\@marbox
    \global\advance\@mparbottom\marginparpush
    \advance\@tempdima -\ht\@marbox
    \global\setbox \@marbox
                   \vbox {\vskip \@tempdima
                          \box \@marbox}%
    \global \ht\@marbox \z@
    \global \dp\@marbox \z@
    \kern -\@pagedp
    \nointerlineskip
    \hb@xt@\columnwidth
      {\ifnum \@tempcnta >\z@
          \hskip\columnwidth \hskip\marginparsep
       \else
          \hskip -\marginparsep \hskip -\marginparwidth
       \fi
       \box\@marbox \hss}%
    \nointerlineskip
    \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}
\ifx \@addmarginpar\@tempa
%    \end{macrocode}
% It matched.
%    \begin{macrocode}
   \def\@addmarginpar{\@next\@marbox\@currlist{\@cons\@freelist\@marbox
       \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
       \if@twocolumn
           \if@firstcolumn \@tempcnta\m@ne \fi
       \else
         \if@mparswitch
            \ifodd\c@page \else\@tempcnta\m@ne \fi
         \fi
         \if@reversemargin \@tempcnta -\@tempcnta \fi
       \fi
       \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
       \@tempdima\@mparbottom
       \advance\@tempdima -\@pageht
       \advance\@tempdima\ht\@marbox
       \ifdim \@tempdima<\z@ \@tempdima\z@ \fi % Modification
       \global\@mparbottom\@pageht
       \global\advance\@mparbottom\@tempdima
       \global\advance\@mparbottom\dp\@marbox
       \global\advance\@mparbottom\marginparpush
       \advance\@tempdima -\ht\@marbox
       \global\setbox \@marbox
                      \vbox {\vskip \@tempdima
                             \box \@marbox}%
       \global \ht\@marbox \z@
       \global \dp\@marbox \z@
       \kern -\@pagedp
       \nointerlineskip
       \hb@xt@\columnwidth
         {\ifnum \@tempcnta >\z@
             \hskip\columnwidth \hskip\marginparsep
          \else
             \hskip -\marginparsep \hskip -\marginparwidth
          \fi
          \box\@marbox \hss}%
       \nointerlineskip
       \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}}
\else
%    \end{macrocode}
% It didn't match. Inform the user of what is to come.
%    \begin{macrocode}
   \typeout{Expect a lot of ``Marginpar moved'' warnings.}
\fi
\let\@tempa=\relax
%    \end{macrocode}
% 
% 
% \section{Things not to index}
% 
%    \begin{macrocode}
\DoNotIndex{\def,\let,\else,\fi,\then,\x_cs,\x_relax}
\DoNotIndex{\csname,\endcsname,\string,\the,\expandafter,\noexpand}
%    \end{macrocode}
% 
\endinput

