% \iffalse meta-comment
%-*- coding: iso-8859-15 -*-
% Time-stamp: <2011-04-20 16:47:35 yvon>
% --------------------------------------------------------------------
% 
% Copyright (C) 2011 
% by Yvon Henel alias le TeXnicien de surface
% <le.texnicien.de.surface@wanadoo.fr>
%
% --------------------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<*common>
\def\fileversion{v4}  
\def\filedate{2011/04/19}
\def\fileinfo{fichier paresse par le TeXnicien de surface}
%</common>
%<*package>
\ProvidesPackage{paresse}
   [\filedate\space\fileversion\space\fileinfo] 
%</package>
% \fi
% \iffalse
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}  
\usepackage[tame]{paresse}
\usepackage{xspace,url,array, ifthen}
\IfFileExists{lmodern.sty}{\usepackage{lmodern}}{}
\usepackage[frenchb,english]{babel}
\usepackage{hypdoc,hologo}

\newcommand*\PS{\texttt{\S}\xspace}
\newcommand*\PSVerb[1]{\texttt{\S #1}}
\newcommand\BOP{\discretionary{}{}{}}
\newcommand\Option[1]{\textsc{#1}}
\newcommand\Pkg[1]{\textsf{#1}}
\newcommand\NOUVO{%
  \marginpar{\hspace*{\stretch{1}}%
    \textbf{N (v4)}\hspace*{.5em}}\xspace} 

% commentez la ligne suivante pour avoir un document avec le code
% \OnlyDescription
% comment the preceding line to obtain a document with the code
% puis cherchez \StopEventually pour d'éventuels réglages
% then look for \StopEventually to make a bit of setup
\EnableCrossrefs
\CodelineIndex
\RecordChanges

\begin{document}
  \DocInput{paresse.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{592}
%
% \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         \~}
%
%
% \changes{v0.0}{2004/02/07}{New name, some redefinitions,
% first public version}
% \changes{v1}{2004/04/17}{Documentation updated}
% \changes{v1a}{2005/03/01}{Correction of a bug in Infofile which prevented the loading of the package}
% \changes{v2}{2008/08/13}{A useless macro is deleted}
% \changes{v2}{2008/08/13}{Documentation reorganised}
% \changes{v2}{2008/08/13}{New wrapping to provide a tds.zip.}
% \changes{v2.1}{2008/08/16}{Correction of a bug in Infofile, once again} 
% \changes{v3}{2010/03/19}{Option for Sylvio \textsc{Levi}'s encoding}
% \changes{v4}{2011/04/16}{Documentation of the code in English}
% \changes{v4}{2011/04/16}{paresse goes utf8}
%
% \GetFileInfo{paresse.sty}
%
% \DoNotIndex{\newcommand,\newenvironment,\i,\ae,\oe,\DeclareOption,^^A
%   \ifthenelse,\if,\else,\fi,\tr@@c,\ExecuteOptions,\ProcessOptions,^^A
%   \relax,\MessageBreak,\CurrentOption,\RequirePackage,\PackageError,^^A
%   \def,\endinput,\let,\boolean,\newboolean,\setboolean,\renewcommand,^^A
%   \afterassignment,\global,\aftergroup,\bgroup,\egroup,\csname,^^A
%   \endcsname,\emph,\catcode,\space,\string,\next,\active,\rmfamily,\rule,^^A
%   \textsl,\upshape, \alpha, \beta, \gamma, \delta, \epsilon, ^^A
%   \varepsilon, \zeta, \eta, \theta, \vartheta, \iota, \kappa, ^^A
%   \lambda, \mu, \nu, \xi, \pi, \varpi, \rho, \varrho, \sigma, ^^A
%   \varsigma, \tau, \upsilon, \phi, \varphi, \chi, \psi, \omega, ^^A
%   \Delta, \Gamma, \Theta, \Lambda, \Xi, \Pi, \Sigma, \Upsilon, ^^A
%   \ExecuteOptionsX,\ProcessOptionsX,\DeclareOptionX,^^A
%   \DeclareUnicodeCharacter, \parse@XML@charref, ^^A
%   \parse@UTFviii@a, \parse@UTFviii@b, \AtBeginDocument, ^^A
%   \@eha, \@firstofone, \@gobble,\@toks, \@latex@error, ^^A
%   \begingroup, \endgroup, \gdef, \IeC, \ifcat, \ifcsname, ^^A
%   \ifluatex, \ifxetex, \iftogoff, \iftogon, \UTFviii@tmp, ^^A
%   \UTFviii@four@octets, \UTFviii@three@octets, \UTFviii@two@octets,^^A
%   \ifx, \the, \wlog, \togoff, \togon, \@ifpackageloaded, ^^A
%   \expandafter, \futurelet, \makeatletter, \makeatother, ^^A
%   \inputencodingname, \InputIfFileExists, \PackageInfo,^^A
%   \PackageWarning, \newtog, \ProvidesFile, \PS, \PSVerb, ^^A 
%   \stop, \S, \usepackage, \temp@a, \define@bitogkeys, ^^A
%   \Phi, \Psi, \Omega, \newif, \ifnum, \count@, \ensuremath, ^^A
%   \~, \", \^} ^^A
%
% \title{The package \Pkg{paresse}\thanks{This document corresponds
% to file \Pkg{paresse.sty}~\fileversion, dated \filedate.}}
% \author{Le \TeX nicien de surface\\
%   \href{mailto:le.texnicien.de.surface@wanadoo.fr}%
%   {le.texnicien.de.surface@wanadoo.fr}} 
%
% \maketitle
% \begin{abstract}
%   This package implements an example from T.~\textsc{Lachand-Robert}
%   in~\cite{tlachand}. It provides a means of typing isolated greek
%   letters with the character \PS activated and redefined. Instead of
%   |\(\alpha\)| one types \PSVerb{a} to obtain \(\alpha\).
%
%   \textbf{Important}: You have to load it \textbf{after} the
%   \Pkg{inputenc} package if the latter is used. Moreover the sign
%   \PS must be a letter for \TeX.
% 
%   \textbf{New}: with this version~4, one can use this package even
%   with utf8-encoded source for \hologo{LaTeX}, \hologo{LuaLaTeX}, or
%   \hologo{XeLaTeX}.
% 
%   The English documentation for the final user of the package
%   \Pkg{paresse} is available in the file \texttt{paresse-en.pdf}.
% 
% \end{abstract}
% \begin{otherlanguage}{french}
%   \begin{abstract}
%     Ce module, reprenant un exemple de T.~\textsc{Lachand-Robert}
%     dans~\cite{tlachand}, fournit un moyen de taper des lettres
%     grecques isolées à l'aide du caractère \PS actif et redéfini. Au
%     lieu de |\(\alpha\)| ou tape \PSVerb{a} pour obtenir
%     \(\alpha\). 
%
%     \textbf{Important} : Il doit être chargé \textbf{après}
%     \Pkg{inputenc} si ce dernier est utilisé. De plus, il faut
%     que le signe \PS soit une lettre pour \TeX.
% 
%     \textbf{Nouveau}: avec cette version~4, on peut utiliser cette
%     extension même dans un source codé en utf-8 avec \hologo{LaTeX},
%     \hologo{LuaLaTeX} ou \hologo{XeLaTeX}.
% 
%     La documentation française pour l'utilisateur de l'extension
%     \Pkg{paresse} est disponible sous le nom de
%     \texttt{paresse-fr.pdf}.
%   \end{abstract}
% \end{otherlanguage}
% 
% \tableofcontents{}
%
% \StopEventually{
% \begin{thebibliography}{99}
% \addcontentsline{toc}{section}{Bibliographie}
% \bibitem{tlachand} T.~\textsc{Lachand-Robert}.
% \emph{La maîtrise de \TeX{} et \LaTeX{}}.
% Masson, Paris, Milan, Barcelone, \oldstylenums{1995}.\\
% \textsc{isbn} : \texttt{2-225-84832-7}.
% \end{thebibliography}
% \PrintChanges \PrintIndex}
% \iffalse
%<*package> 
% \fi
% \section{The code}
% 
% 
% \subsection{The sty file}
% 
% From this 4th version, I use \Pkg{skeyval} for it provides
% toggle-keys. \Pkg{skeyval} loads \Pkg{xkeyval} the macros of
% which I use to manage options.
% 
% \Pkg{ifluatex} and \Pkg{ifxetex} are required to take care of
% \hologo{LuaLaTeX} and \hologo{XeLaTeX} respectively.
% 
%    \begin{macrocode}
\RequirePackage{skeyval}
\RequirePackage{ifluatex}
\RequirePackage{ifxetex}
%    \end{macrocode}
% 
% With \cmd{\define@bitogkeys}, from \Pkg{skeyval}, I define nine
% pairs of complementary toggle keys. If one of the pair is set to
% \texttt{true}, the other will be automatically set to \texttt{false}
% and vice-versa.
%    \begin{macrocode}
\define@bitogkeys[GA]{paresse.sty}[GA@]{legacy}[true]{levi}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{wild}[true]{tame}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{ttau}[true]{ttheta}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{varepsilon}[true]{epsilon}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{varphi}[true]{phi}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{pi}[true]{varpi}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{sigma}[true]{varsigma}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{rho}[true]{varrho}{}{}
\define@bitogkeys[GA]{paresse.sty}[GA@]{theta}[true]{vartheta}{}{}
%    \end{macrocode}
% 
% I set the behaviour of the package in case of an unknown option
% with \cmd{\DeclareOptionX*}, from \Pkg{xkeyval}.
%    \begin{macrocode}
\DeclareOptionX*{\PackageError{paresse} {The option "\CurrentOption"
    is not known!\MessageBreak The default options are:\MessageBreak
    legacy, varepsilon, theta, pi, rho, sigma, and varphi.}%
  {Choose between `wild' (for an active Paresse in all the document)
    \MessageBreak and `tame', so that the character obtained by
    \string\S\MessageBreak prints the section symbol \string\S).
    \MessageBreak See the documentation for other options.}}
%    \end{macrocode}
% 
% The default options are: |legacy|, |wild|, |varepsilon|,
% |theta|, |pi|, |rho|, |sigma|, and |varphi|.
% \changes{v3}{2010/03/20}{Default option |legacy| added}
%    \begin{macrocode}
\ExecuteOptionsX[GA]{legacy,wild,varepsilon,theta,pi,rho,sigma,varphi}
\ProcessOptionsX[GA]\relax
%    \end{macrocode}
% 
% The prefix of the \emph{secret} macros of this package is
% |GA@|. Here I define the macros which will print the correct
% character according to the chosen options. \cs{iftogon} is provided
% by \Pkg{skeyval}.
%    \begin{macrocode}
\iftogon{GA@varepsilon}{%
  \def\GA@epsilon{\varepsilon}}{\def\GA@epsilon{\epsilon}}
\iftogon{GA@vartheta}{\def\GA@theta{\vartheta}}{\def\GA@theta{\theta}}
\iftogon{GA@varpi}{\def\GA@pi{\varpi}}{\def\GA@pi{\pi}}
\iftogon{GA@varrho}{\def\GA@rho{\varrho}}{\def\GA@rho{\rho}}
\iftogon{GA@varsigma}{\def\GA@sigma{\varsigma}}{\def\GA@sigma{\sigma}}
\iftogon{GA@varphi}{\def\GA@phi{\varphi}}{\def\GA@phi{\phi}}
%    \end{macrocode}
% 
% 
% I test the engine, it it is \hologo{XeTeX} or \hologo{LuaTeX}, the
% file \texttt{paresseold.sto} is loaded. 
%    \begin{macrocode}
\ifluatex
  \PackageInfo{paresse}{compiling with luatex}
  \InputIfFileExists{paresseold.sto}{%
    \PackageInfo{paresse}{paresseold loaded}}{%
    \PackageInfo{paresse}{paresseold not loaded}}
\else
  \ifxetex
    \PackageInfo{paresse}{compiling with xetex}
    \InputIfFileExists{paresseold.sto}{%
      \PackageInfo{paresse}{paresseold loaded}}{%
      \PackageInfo{paresse}{paresseold not loaded}}
  \else
%    \end{macrocode}
% We arrive here if the working engine is good old \hologo{TeX} (in
% fact, good not so old \hologo{eTeX} I hope for some things could
% depend on \hologo{eTeX}-nical internals). 
% 
% First some useful macros to take care of the encoding. The macros
% have been given to me by Christian \textsc{Tellechea} I do heartily
% thank for his kindness.
% 
% The first one takes care of problems of encoding.
%    \begin{macrocode}
\newcommand\encoding@error{%
  \@latex@error{%
    paresse needs inputenc loaded with option "utf8"
    or option such as "latin1" (8 bits encodign).}{}\stop}
%    \end{macrocode}
% The second checks that \Pkg{inputenc} has been loaded before
% \Pkg{paresse}. 
%    \begin{macrocode}
\@ifpackageloaded{inputenc}\relax
{\PackageError{paresse}{%
    Please, load inputenc package before paresse}{%
  With LaTeX, "paresse" needs to know the encoding to work well and so
  the package "inputenc" must be loaded, with \string\usepackage, before
  loading "paresse" itself}}
%    \end{macrocode}
% The test for \Pkg{inputenc} and encoding is delayed at the beginning
% of the document where all things about encoding should be settled.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{inputenc}\find@encoding\encoding@error}
%    \end{macrocode}
% I create a new toggle |GA@utf8| and set it to \texttt{false}. It
% will be used later to chose the correct action. 
%    \begin{macrocode}
\newtog[GA@]{utf8}[false]
%    \end{macrocode}
% A bit of code to find the declared encoding and set up the toggle
% |GA@utf8| accordingly. There again work by Christian
% \textsc{Tellechea}. 
%    \begin{macrocode}
\newcommand\find@encoding{%
  \begingroup
  \def\utf@encoding{utf8}%
  \def\temp@a{\togoff{GA@utf8}%
    \PackageInfo{paresse}{8-bit encoding expected\@gobble}}
  \ifx\utf@encoding\inputencodingname
  \def\temp@a{\togon{GA@utf8}%
    \PackageInfo{paresse}{utf8 encoding detected\@gobble}}
  \fi
  \expandafter\endgroup\temp@a}
%    \end{macrocode}
% 
% The main action is then delayed at the beginning of the document for
% reasons already given above. In case the utf8 encoding has been
% detected, the file \texttt{paresseutf8.sto} is loaded, otherwise it
% is \texttt{paresseold.sto} once again.
% 
% \cs{makeatletter} is needed to mimic the loading of a \texttt{sty}
% file for, at the beginning of the document, |@| is no more a
% letter. Naturally, we must revert |@| to its non-letter status at
% the end of the loading.
%    \begin{macrocode}
\AtBeginDocument{%
  \makeatletter
  \iftogoff{GA@utf8}{%
    \InputIfFileExists{paresseold.sto}{%
      \PackageInfo{paresse}{old loaded\@gobble}}{%
      \PackageError{paresse}{paresseold.sto not found}{%
        The package "paresse" needs to load the file "paresseold.sto"
        but can't find it. Something seems to be broken in your TeX
        system}}}{%
    \InputIfFileExists{paresseutf8.sto}{%
    \PackageInfo{paresse}{utf8 loaded\@gobble}}{%
    \PackageError{paresse}{paresseutf8 not found}{%
        The package "paresse" needs to load the file "paresseutf8.sto"
        but can't find it. Something seems to be broken in your TeX
        system}}}
  \makeatother}
\fi
\fi
%    \end{macrocode}
% 
% And that's all for the main file.
% \iffalse
%</package>
% \fi
% \iffalse
%<*oldpack>
% \fi
% 
%\subsection{The file paresseold.sto}
%
% This file will be loaded in all cases except when the working engine is
% \hologo{LaTeX} with |[utf8]{inputenc}| loaded. |^^a7| is \TeX nical
% code for the character I type, on my French keypad, with key \S.
% 
% This is almost the content of the version~3 of
% \texttt{paresse.sty}. The changes are the use of toggles provided by
% \Pkg{skeyval} and the appearance of \PSVerb{Z} to obtain \S ---
% which is always available through \cs{S}\footnote{So could I speak
%   of \PSVerb{Z} in terms of ``shortcut''?}.
% 
%    \begin{macrocode}
\ProvidesFile{paresseold.sto}
%    \end{macrocode}
% Presentations made, I save the current category code (catcode) of
% the character \PS and its definition in \cs{GA@LaVieilleParesse}.
%    \begin{macrocode}
\count@=\catcode`\^^a7
\let\GA@LaVieilleParesse= ^^a7
%    \end{macrocode}
% For sake of convienience, \PS is def'ed as |\S|.
%    \begin{macrocode}
\def\^^a7{\S}
%    \end{macrocode}
% 
% Come some end-user macros. \cs{makeparesseletter} changes the
% \DescribeMacro{\makeparesseletter} catcode of \PS to~\(11\) which is
% the code of letter and \DescribeMacro{\makeparesseother}
% \cs{makeparesseother} changes that code to~\(12\) the code of other
% characters.
%    \begin{macrocode}
\newcommand{\makeparesseletter}{\catcode `\^^a7=11\relax}
\newcommand{\makeparesseother}{\catcode `\^^a7=12\relax}
%    \end{macrocode}
% \cs{GA@MakeParesseActive} is an internal macro to activate \PS. 
% \DescribeMacro{\GA@MakeParesseActive}
% Then come two macros to activate \PS for the remaining part of the
% file. On of them is applied according to the catcode of \PS at the
% beginning --- catcode saved in |\count@|.
%    \begin{macrocode}
\newcommand{\GA@MakeParesseActive}{\catcode `\^^a7=\active}
\def\GA@ActiveLaParessexii{\catcode `\^^a7=\active}
\def\GA@ActiveLaParessexiii{\catcode `\^^a7=\active
  \def^^a7##1{\ensuremath{\csname \string^^a7##1\endcsname}}}
\ifnum\count@=12
  \let\GA@ActiveLaParesse \GA@ActiveLaParessexii
\else
  \let\GA@ActiveLaParesse \GA@ActiveLaParessexiii
\fi
%    \end{macrocode}
% 
% It's time to provide one end-user macro and one environment useful
% \DescribeMacro{\ActiveLaParesse}
% \DescribeEnv{ParesseActive}
% when the package has been loaded with option \Option{tame} to
% locally activate \PS.
%    \begin{macrocode}
\newcommand{\ActiveLaParesse}{\GA@ActiveLaParesse}
\newenvironment{ParesseActive}{\GA@ActiveLaParesse}{}
%    \end{macrocode}
% 
% Now come the definitions of the meanings of the \PS-macros. For
% these definitions to work, \PS is made a letter.
%    \begin{macrocode}
\makeparesseletter
\def\^^a7a {\alpha}
\def\^^a7b {\beta}
\def\^^a7g {\gamma}
\def\^^a7d {\delta}
\def\^^a7e {\GA@epsilon}
\def\^^a7z {\zeta}
\def\^^a7h {\eta}
\def\^^a7i {\iota}
\def\^^a7k {\kappa}
\def\^^a7l {\lambda}
\def\^^a7m {\mu}
\def\^^a7n {\nu}
\def\^^a7x {\xi}
\def\^^a7p {\GA@pi}
\def\^^a7r {\GA@rho}
\def\^^a7s {\GA@sigma}
\def\^^a7u {\upsilon}
\def\^^a7f {\GA@phi}
\def\^^a7w {\omega}
%    \end{macrocode}
% In case of option \Option{legacy}, definitions of \PSVerb{v},
% \PSVerb{y}, \PSVerb{c}, and \PSVerb{q} as in the first two versions
% of this package. 
%    \begin{macrocode}
\iftogon{GA@legacy}{%
  \def\^^a7v {\GA@theta}
  \def\^^a7y {\tau}
  \def\^^a7c {\chi}
  \def\^^a7q {\psi}
%    \end{macrocode}
% Care is taken of options \Option{ttau} and \Option{ttheta}.
%    \begin{macrocode}
  \iftogon{GA@ttau}{\def\^^a7t {\tau}}{\def\^^a7t {\GA@theta}}}{%
%    \end{macrocode}
% Definitions of the same \PSVerb{v}, \PSVerb{y}, \PSVerb{c}, and
% \PSVerb{q} with option \Option{levi}. In that case, options
% \Option{ttau} and \Option{ttheta} are no-op.
%    \begin{macrocode}
  \def\^^a7j {\GA@theta}
  \def\^^a7t {\tau}
  \def\^^a7q {\chi}
  \def\^^a7y {\psi}
  \def\^^a7c {\varsigma}}
%    \end{macrocode}
% Upper case letters are treated thence: 
%    \begin{macrocode}
\def\^^a7G {\Gamma}
\def\^^a7D {\Delta}
\def\^^a7L {\Lambda}
\def\^^a7P {\Pi}
\def\^^a7S {\Sigma}
\def\^^a7U {\Upsilon}
\def\^^a7F {\Phi}
\def\^^a7X {\Xi}
\def\^^a7W {\Omega}
%    \end{macrocode}
% Once again \Option{legacy} vs. \Option{levi}: 
%    \begin{macrocode}
\iftogon{GA@legacy}{%
  \def\^^a7V {\Theta}
  \def\^^a7T {\Theta}
  \def\^^a7Q {\Psi}
}{%
  \def\^^a7J {\Theta}
  \def\^^a7Y {\Psi}
}%
% \changes{va4}{2011/04/17}{\PSVerb{Z} added to produce \PS}
\def\^^a7Z {\S}
%    \end{macrocode}
% 
% The end is near! \PS is made active and the \PS-macros defined. This
% is old code --- directly from~\cite{tlachand}.
%    \begin{macrocode}
\catcode `\^^a7=\active
\def^^a7#1{\ensuremath{\csname \string^^a7#1\endcsname}}
%    \end{macrocode}
% In case option \Option{tame} is chosen, \PS is given its first
% catcode and meaning back.
%    \begin{macrocode}
\iftogon{GA@tame}{%
  \catcode`\^^a7=\count@
  \ifnum\count@=13 \let ^^a7=\GA@LaVieilleParesse \fi
}%
%    \end{macrocode}
% 
% And that's all for \texttt{paresseold.sto}.
% 
% \iffalse
%</oldpack>
% \fi
% \iffalse
%<*utf8pack>
% \fi
%
%\subsection{The file paresseutf8.sto}
% 
% This part is brand new. It deals with the document encoded in utf8
% via |\usepackage[utf8]{fontenc}| and compiled with \hologo{LaTeX}. 
% 
% It is at the request of Christian \textsc{Tellechea} that this
% package now deals with such source. Most of the macros of this part
% were created by the same Christian.
%
% First a bit of identification
%    \begin{macrocode}
\ProvidesFile{paresseutf8.sto}
%    \end{macrocode}
% followed by code partially taken from \texttt{utf8.def} for I wanted
% to implement the option \Option{tame} and, to do so, needed to
% redeclare the character \PS. Four macros are used in such a
% redeclaration and they are made unavailable outside preamble in
% \texttt{utf8.def}.
% 
% The original \cs{DeclareUnicodeCharacter} depends on
% \cs{parse@XML@charref} which itself depends on \cs{parse@UTFviii@a}
% and \cs{parse@UTFviii@b}. Those two last macros are defined in terms
% of accessible macros. Therefore, I first create an alias of the last
% two and then define \cs{declareunicodecharacter} and
% \cs{GA@parse@XML@charref} in terms of the \emph{localised} version
% of \cs{parse@UTFviii@a} and \cs{parse@UTFviii@b}.
% 
% To be on the safe side, I repeat the invocations of catcode of
% \texttt{utf8.def}.
%    \begin{macrocode}
\begingroup
\catcode`\"=12
\catcode`\<=12
\catcode`\.=12
\catcode`\,=12
\catcode`\;=12
\catcode`\!=12
\catcode`\~=13
\global\let\GA@parse@UTFviii@a=\parse@UTFviii@a
\global\let\GA@parse@UTFviii@b=\parse@UTFviii@b
\gdef\declareunicodecharacter#1#2{%
   \count@"#1\relax
   \wlog{\space\space Redefining Unicode char U+#1 (decimal \the\count@)}%
   \begingroup
    \GA@parse@XML@charref
    \def\UTFviii@two@octets##1##2{\csname u8:##1\string##2\endcsname}%
    \def\UTFviii@three@octets##1##2##3{\csname u8:##1%
      \string##2\string##3\endcsname}%
    \def\UTFviii@four@octets##1##2##3##4{\csname u8:##1%
      \string##2\string##3\string##4\endcsname}%
    \expandafter\expandafter\expandafter
    \expandafter\expandafter\expandafter
    \expandafter
    \gdef\UTFviii@tmp{\IeC{#2}}%
    \endgroup}
\gdef\GA@parse@XML@charref{%
  \ifnum\count@<"A0\relax
     \PackageError{inputenc}{Cannot\space define\space Unicode\space
       char\space value\space <\space 00A0}\@eha
  \else\ifnum\count@<"800\relax
     \GA@parse@UTFviii@a,%
     \GA@parse@UTFviii@b C\UTFviii@two@octets.,%
  \else\ifnum\count@<"10000\relax
     \GA@parse@UTFviii@a;%
     \GA@parse@UTFviii@a,%
     \GA@parse@UTFviii@b E\UTFviii@three@octets.{,;}%
   \else
     \GA@parse@UTFviii@a;%
     \GA@parse@UTFviii@a,%
     \GA@parse@UTFviii@a!%
     \GA@parse@UTFviii@b F\UTFviii@four@octets.{!,;}%
    \fi
  \fi
\fi}
\endgroup
%    \end{macrocode}
% Here ends the \emph{localisation}. 
% 
% I provide the same macros as in the preceding case but in such a
% context \cs{makeparesseother} doesn't make sense. It just produces a
% warning.
%    \begin{macrocode}
\newcommand{\makeparesseletter}{\DeclareUnicodeCharacter{00A7}\S}
\newcommand{\makeparesseother}{%
  \PackageWarning{paresse}{%
    Command \string\makeparesseother disabled}{%
    The command \string\makeparesseother would have been meaningless
    in the current context}}
%    \end{macrocode}
% 
% The end-user macro \cs{ActiveLaParesse} and the corresponding
% environment |ParesseActive|.
% 
% The Unicode character of code \texttt{00A7} is made equal to the
% macro \cs{@paresse}. 
%    \begin{macrocode}
\newcommand{\ActiveLaParesse}{\declareunicodecharacter{00A7}\@paresse}
\newenvironment{ParesseActive}{\ActiveLaParesse}{}
%    \end{macrocode}
% 
% It's time to prepare the definition of the \PS-macros. To begin with
% we activate the character \PS.
%    \begin{macrocode}
\ActiveLaParesse
%    \end{macrocode}
% 
% And now for the \emph{working} code: when the paresse is active, the
% byte \texttt{00A7} is an alias for \cs{@paresse} and, because of the
% following, the code \cs{@paresse}\meta{token} is changed into
% \cs{@i@paresse}\meta{token} with the side effect that \cs{@toks} is
% let to \meta{token}.
%    \begin{macrocode}
\def\@paresse{\futurelet\@toks\@i@paresse}
%    \end{macrocode}
% Then if \meta{token}, now ``in'' \cs{@toks}, has the same category
% than \texttt{a} --- hopefully a letter --- then we obtain
% \cs{@ii@paresse} else \cs{S}.
% 
%    \begin{macrocode}
\def\@i@paresse{%
  \csname\ifcat a\@toks @ii@paresse\else S\fi\endcsname}
%    \end{macrocode}
% At that point, the code which was \cs{@paresse}\meta{token} is
% either \cs{S}\meta{token} or \cs{@ii@paresse} which awaits for an
% argument. That argument will be the still present \meta{token}.
% 
% If the command \cs{@paresse@}\meta{token} is defined then it does
% its job, else we obtain \cs{S}\meta{token}.
%    \begin{macrocode}
\def\@ii@paresse#1{%
  \ifcsname @paresse@#1\endcsname
    \csname @paresse@#1\endcsname\expandafter\@gobble
  \else
    \expandafter\@firstofone
  \fi{\S#1}}
%    \end{macrocode}
% 
% The next macro is used to define the \PS-macros.
% 
% I have not used it in \texttt{paresseold.sto} for that definition
% prevent a feature I'm attached to, to wit, obtaining
% \(\alpha^{\beta}\) with |\(|\PSVerb{a}|^|\PSVerb{b}|\)|. I would
% have been loath to force some of the users to change their until now
% working sources.
%    \begin{macrocode}
\def\define@paresse@car#1#2{%
  \expandafter\def\csname @paresse@#1\endcsname{\ensuremath{#2}}}
%    \end{macrocode}
% 
% From now on, there are just definitions of \PS-macros. 
% 
% The first one, \PSVerb{Z} is new.
%    \begin{macrocode}
\define@paresse@car Z\S
\define@paresse@car a\alpha
\define@paresse@car b\beta
\define@paresse@car g\gamma
\define@paresse@car d\delta
\define@paresse@car e\GA@epsilon
\define@paresse@car z\zeta
\define@paresse@car h\eta
\define@paresse@car i\iota
\define@paresse@car k\kappa
\define@paresse@car l\lambda
\define@paresse@car m\mu
\define@paresse@car n\nu
\define@paresse@car x\xi
\define@paresse@car p\GA@pi
\define@paresse@car r\GA@rho
\define@paresse@car s\GA@sigma
\define@paresse@car u\upsilon
\define@paresse@car f\GA@phi
\define@paresse@car w\omega
\iftogon{GA@legacy}{%
  \define@paresse@car v\GA@theta
  \define@paresse@car y\tau
  \define@paresse@car c\chi
  \define@paresse@car q\psi
  \iftogon{GA@ttau}{%
    \define@paresse@car t\tau}{%
    \define@paresse@car t\GA@theta}}{%
  \define@paresse@car j\GA@theta
  \define@paresse@car t\tau
  \define@paresse@car q\chi
  \define@paresse@car y\psi
  \define@paresse@car c\varsigma}
\define@paresse@car G\Gamma
\define@paresse@car D\Delta
\define@paresse@car L\Lambda
\define@paresse@car P\Pi
\define@paresse@car S\Sigma
\define@paresse@car U\Upsilon
\define@paresse@car F\Phi
\define@paresse@car X\Xi
\define@paresse@car W\Omega
\iftogon{GA@legacy}{%
  \define@paresse@car V\Theta
  \define@paresse@car T\Theta
  \define@paresse@car Q\Psi}{%
  \define@paresse@car J\Theta
  \define@paresse@car Y\Psi}%
%    \end{macrocode}
% 
% At the end of the package, if the option \Option{tame} is chosen, \PS
% is made a letter again.
%    \begin{macrocode}
\iftogon{GA@tame}{\makeparesseletter}
%    \end{macrocode}
% 
% And that's all for the file \texttt{paresseutf8.sto}.
% \iffalse
%</utf8pack>
% \fi
% \Finale
\endinput
%%% Local Variables: 
%%% mode: doctex
%%% fill-column: 70
%%% coding: iso-8859-15
%%% TeX-master: t
%%% End: 

