 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%% email-fr.sty
 %%%% Master posting on ftp matups.matups.fr
 %%%% Support: Laurent Siebenmann lcs@matups.matups.fr
 %%%% After \endinput see an alternate paste-in header version
 %%%% suitable for real email messages.
 %%%% There is documentation toward the end of this file.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% Succinct French accentuation for Plain TeX (LS'93)
 %% After \input email-fr.sty, \frenchemail activates macros.
 %% Then 'e 'E for \'e \'E;  / for apostrophe, at least before  e  E
 %% ` ^ _ for \` \^ \c respectively; and \" is unchanged. 
 %% The command \SmartQuotes permits syntax
 %%  "#1" for smart quotes; \noSmartQuotes annuls (makes "inactive).
 %% Problem: \input is forbidden with these macros in effect.
 %% Solution (see documentation):  Use grouping. Or environment: 
 %% \beginemailFR...\endemailFR
 %% \begin{emailFR}...\end{emailFR} (LaTeX only)
 %% and use \emailinput or \macroinput therein, but \input outside.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \def\empty{}
 \ifx\emailFRFlag\empty
   \def\temp{\immediate\write16{}%
     \errmessage{ Oops, email-fr is already loaded\string!}%
     \endinput}
 \expandafter\temp
 \else\def\emailFRFlag{}%
 \fi

 \chardef\emailFRAt=\catcode`@ \catcode`@=11

 \def\gobble#1{} \let\EX@\expandafter

 \def\doemailFRChars@{\do/\do_\do^\do'\do`}

 \def\emailFRChActive{\edef\do##1{\EX@\catcode\string`##1=13}%
                \doemailFRChars@}
 \def\emailFRChOther{\edef\do##1{\EX@\catcode\string`##1=12}%
                \doemailFRChars@}

 \bgroup\catcode`\"=13\relax\emailFRChActive
  \gdef\@ActiveDQuote{"}
  \gdef\@ActiveSlash{/}
  \gdef\@ActiveULine{_}
  \gdef\@ActiveHat{^}
  \gdef\@ActiveRQuote{'}
  \gdef\@ActiveLQuote{`}
  \gdef\lqmole@{\ifx`\next\lq\lq\EX@\gobble\else\EX@\`\fi}
  \gdef\ppmole@{\ifx'\next\EX@\@rqq\else\EX@\rq@\fi}
 \egroup

  \def\pprime@{\futurelet\next\ppmole@}
  \def\@rqq#1{\futurelet\next\@rqqmole}
  \def\@rqqmole{\ifcat a\noexpand\next\EX@\@@rqq\else\rq\rq\fi}
  \def\@@rqq#1{\EX@\ifnum\lccode`#1=`e\rq\'#1\else\rq\rq#1\fi}
  \def\rq@{\ifcat a\noexpand\next\EX@\@rq@\else\rq\fi}
  \def\@rq@#1{\EX@\ifnum\lccode`#1=`e\'#1\else\rq#1\fi}
  \edef\Excl@{\string!\string!\string!\string!}
 \bgroup\EX@\let\@ActiveDQuote\relax
    \xdef\@SmartDQ{\def\@ActiveDQuote##1\@ActiveDQuote
          {\lq\lq##1\rq\rq}}
 \egroup
 \def\SmartQuotes{\@SmartDQ\catcode`\"=13\relax}
 \def\noSmartQuotes{\catcode`\"=12\relax}
 \def\MSlash@{\futurelet\next\MSlash@mole}
 \def\MSlash@mole{%
   \ifx\next e
     \immediate\write16{}%
     \immediate\write16{\string! Is this /e correct; 
                          or is it 'e corrupted?\string!}%
     \errmessage{ Stop and correct; or replace by / e \string!}%
   \fi\string/}


 \def\frenchemail{\emailFRChActive\noSmartQuotes
   \EX@\def\@ActiveULine{\ifmmode\sb\else\EX@\c\fi}%
   \EX@\def\@ActiveSlash{\ifmmode\EX@\MSlash@\else\EX@\rq\fi}%
   \EX@\def\@ActiveHat{\ifmmode\sp\else\EX@\^\fi}%
   \EX@\def\@ActiveLQuote{\futurelet\next\lqmole@}
   \EX@\def\@ActiveRQuote{\ifmmode\EX@\@@prime\else\EX@\pprime@\fi}%
    \def\@@prime{\sp\bgroup\prim@s}%
    \def\pr@m@s{\ifx'\next\let\nxt\pr@@@s \else
      \ifx^\next\let\nxt\pr@@@t\else\let\nxt\egroup\fi\fi \nxt}%
   \edef\input{\immediate\write16{} \errmessage{\Excl@ No \string
     \input\space please during email-fr typing \Excl@ }}%
   }
 
 
 \let\prim@emailFRinput\input
 
 \def\beginemailFR{\begingroup\bgroup\frenchemail
     \let\emailinput\prim@emailFRinput
     \def\macroinput##1 {\egroup\prim@emailFRinput##1 \bgroup}}
 \let\emailFR\beginemailFR
 \def\endemailFR{\egroup\endgroup}
 
 %%% \flexcat!
  
 %\let\EX@\expandafter
 \def\IW@#1{\immediate\write16{#1}}%
 \newif\ifc@tOK
 
 \def\flexcat{\begingroup\catcode`\!=11\futurelet\next\flexcattest@}
 
 \def\flexcattest@#1{%
     \ifcat a\noexpand\next 
         \c@tOKtrue
     \else
         \c@tOKfalse     
     \fi
    \count255=`#1\relax %\showthe\count255
    \ifnum\count255=`\!
      \ifc@tOK
        \IW@{*** Test passed; this \string\flexcat\string!
                   location on line \the\inputlineno}
        \IW@{*** seems OK for category changes.}%
      \else
        \IW@{*** Test by \string\flexcat\string! failed 
             at line \the\inputlineno}%
        \IW@{*** as category change was not immediately effective.}%
        \IW@{*** \string\flexcat\string! must be in your .tex file.}%
        \IW@{*** Only where the test succeeds 
                    should you try catcode changes.}%
        \errmessage{}%
      \fi
    \else
       \IW@{*** Sorry, you must use \string! after
             \noexpand\flexcat at line \the\inputlineno.}%
       \errmessage{}%
    \fi\endgroup}

 \newcount\aux@count

 \def\Invalidate@#1#2{%% invalid -ate #1 <= <#2
     \count@=#1\relax \aux@count=#2
     \loop
        \catcode\count@=15
        \advance\count@ by \@ne
     \ifnum\count@ < \aux@count %
     \repeat}

 \def\BlockExtendedASCII{\Invalidate@{127}{256}}
 
 \def\BlockLowASCII{%
   \Invalidate@{0}{10}%
   \Invalidate@{14}{32}}
 
 \def\BlockNonASCII{\BlockLowASCII\BlockExtendedASCII}
 
 \catcode`@=\emailFRAt
 
 \endinput
 
 
 %%% Header version for autonomous one-file email messages.
 %%% 
 %%% Version francaise pour entetes.
 %%% A inserrer par copier et coller 
 %%% apres vos macros et \inputs (apr`es \documentstyle{...}
 %%% pour LaTeX) juste avant la saisie.
 %%% Les macros sont alors de suite en vigueur.
 %-------- selectioner
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% email-fr: Accentuation francaise succincte pour TeX
 %% Version entete portable (LS 3&4-93) ftp matups.matups.fr
 %% Syntaxe: \begingroup <ces macros> <la frappe> \endgroup
 %% La frappe: / pour <apostrophe>, du moins devant  e  et  E 
 %% ' ` ^ _ pour \' \` \^ \c  respectivement; \" inchang'e
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% "#1" pour guillemets (anglais) si on active la ligne suivante 
 \catcode`\"=13 \edef"#1"{\lq\lq#1\rq\rq}%
 \catcode`\/=13 \def/{\ifmmode\string/\else\string'\fi}%
 \catcode`\_=13 \def_{\ifmmode\sb\else\expandafter\c\fi}%
 \catcode`\^=13 \def^{\ifmmode\sp\else\expandafter\^\fi}%
 \chardef\emailFRAt=\catcode`@ \catcode`@=11 \catcode`\'=13 
 \def'{\@prime}\let\EX@\expandafter\def\g@bble#1{}\let\FL@\futurelet
 \def\@prime{\ifmmode\EX@\@@prime\else\EX@\pprime@\fi}%
 \def\@@prime{\sp\bgroup\prim@s}\def\pprime@{\FL@\next\ppmole@}
 \def\pr@m@s{\ifx'\next\let\nxt\pr@@@s \else\ifx^\next\let\nxt\pr@@@t
   \else\let\nxt\egroup\fi\fi \nxt} \def\@rqq#1{\FL@\next\@rqqmole}
 \def\ppmole@{\ifx'\next\EX@\@rqq\else\EX@\rq@\fi}
 \def\@rqqmole{\ifcat a\noexpand\next\EX@\@@rqq\else\rq\EX@\rq\fi}
 \def\@@rqq#1{\EX@\ifnum\lccode`#1=`e\rq\'#1\else\rq\rq#1\fi}
 \def\rq@{\ifcat a\noexpand\next\EX@\@rq@\else\rq\fi}
 \def\@rq@#1{\EX@\ifnum\lccode`#1=`e\'#1\else\rq#1\fi}
 \count255=\catcode`\!\catcode`\!=12
 \edef\input{\immediate\write16{}\errmessage{!!!! Les macros email-fr 
      excluent \string\input\space !!!!}}\catcode`\!=\the\count255
 \catcode`\`=13 \def`{\futurelet\next\lqmole@}%
     \def\lqmole@{\ifx`\next\lq\lq\EX@\g@bble\else\EX@\`\fi}
 \EX@\catcode\string`@=\emailFRAt
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %-------- copier

 %%%%%%%%%%%% ASCII (ISO 850) integrity check %%%%%%%%%%%%%%%%
 %%   Upper case letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
 %%   Lower case letters: abcdefghijklmnopqrstuvwxyz
 %%   Six punctuation marks  . ? ! , : ;
 %%   Parentheses: ()
 %%   Braces: square, curly, angle : [] {} <>
 %%   Backslash, slash, vertical bar:   \ / |
 %%   Underscore, hyphen, equal:   _ - =
 %%   Quotes: right, left, double  ' ` "
 %%   "at", "number", "dollar", "percent":   @ # $ %
 %%   "and", "hat", "star", "plus", "tilde":  & ^ * + ~
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%% Succinct French typing for 7-bit ASCII email %%%%%%%%% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 --- This is documentation for the email-fr macros 
in their style file and header forms.

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 USER COMMAND INDEX: ("search" for information on them)
  --- Indented commands are less ugrent.
  \frenchemail  (always after header material) switches on macros.
    Switching on AND off:
    \begingroup \frenchemail <succinct typing> \endgroup
    \beginemailFR  <succinct typing> \endemailFR
    \begin{emailFR}  <succinct typing> \end{emailFR}  (for LaTeX only)
       \flexcat!  diagnostic test for switching
       \emailinput or \macroinput  replacing  \input when macros on.
  'e 'E for \'e \'E;  / for apostrophe, at least before  e  E
  ` ^ _ for \` \^ \c respectively (\" is unchanged)
    \SmartQuotes  then  syntax "#1";  \noSmartQuotes.
       \<...\>  Guillemets (with external definition)
  \lq...\rq  English single quotes replacing `...'
  \BlockNonASCII  to enforce strict ASCII typing
       \BlockExtendedASCII, \BlockLowASCII
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 


                 **** Introduction ****

     First off, read the documentation in the headers to the
macros both in style file form (up to \endinput) and in header
form (after \endinput). Above all, note the new usage of 
the five diacritics ` ' ^ _ / .   

     Let us imagine that an urgent letter in French is to be sent
by email.  It must be both immediately and easily readable in
ASCII form and automatically convertible by TeX into good
printed copy.  With the ASCII 7bit typing recommended by Knuth
in the TeXbook (1982), and employed by a majority French TeX
users for a decade the ASCII form is of poor readibility because
of backslashed control sequences used for accents : L'Ob\'eron a
\'et\'e d\'em\^at\'e. The simplified typing that email-fr.tex
makes available is more readible without degrading the quality 
or convenience of the printing : L'Ob'eron a 'et'e d'em^at'e.

     There is another consideration.  Most TeX users expect to
employ some sort of a preprocessor to produce L'Ob\'eron a
\'et\'e d\'em\^at\'e, be it a command key system or a  stream
processor. Except, that is, in various awkward  circumstances
that email so often creates on the various minitel sets and
terminals one encounters. In such circumstances users will
surely be happy to type L'Ob'eron a 'et'e d'em^at'e, and the aim
of these macros is to make this directly acceptable to TeX

     Similar considerations apply to many European languages.
But just a few (notably German) have thus far develloped this
sort of succinct typing style.  To facilitate parallel efforts
for other languages this documentation is in English.

     Alpha-test notice: The applicability of the email-fr
macros beyond basic Plain TeX is still a matter for cautious
investigation (see below). Even under Plain there may still be
bugs. Please proceed with caution and report problems.



 **** Instructions Remarks and Limitations ****

     The diarresis accent \" is so rare in French that it would
be senseless to provide an abbreviation.

     The accent macros \' \` \^ \c remain alive and well and can
still be used; in fact, the email-fr macros relies on them to get
output.  You therefore have to be using a TeX environment
in which they have been progammed to give the best
accented characters your font system will permit. In particular
Knuth's definition of  \^  must have been modified so that
\^i  involves a dotless i.  There are several ready-made 
setups found on anonymous ftp ftp.univ-rennes1.fr or ftp
matups.matups.fr and the CTAN servers.  I provide support 
for format-dumper, whose master posting is on  ftp
matups.matups.fr. 


 ** A common typing error and its painless remedy

     There is one unfortunate disruption of standard typing
habits that forced email-fr to evolve considerably.   In order
to be acceptable to email-fr.sty (or the email-fr header) the
apostrophe followed by  e or  E  must  in principle be typed as a
slash / and not as '.  This rule is unambiguous and visually
acceptable --- at least more so than a backslash in the middle of
a word.  The problem is that few typists are able to avoid
reverting many times per page to  '  for apostrophe, which may
produce <eaccute> or <Eaccute> in TeX. 

      A classical remedy is to use a good text editor to search for
the quadruple <space><letter>'<e or E> and replace it where
appropriate by /e (or /E).  As <letter> is one of many c d j l m
n s t (not counting capitalisation and the occurrence s of qu), 
<letter> should be treated as a wildcard or multiple choice and
only a sophisticated text editor (operated by a sophisticated
user?) can do that.  It is exceedingly  tiresome to search for all
'e or 'E.

      Thus some automatic and portable typing correction tool can
be reckoned a necessity; it is provided by a small ".tex" utility
called email-fr.fix which in turn uses email-fr.dmp; both
are distributed with email-fr.sty.  
      
      With email-fr.fix you can freely forget to use  /  for
apostrophe --- and suffer no penalty!
      
      Here is how to start using email-fr.fix; for more details 
see its own documentation.  Save your email-fr typescript
underthe name corr.in  along side of email-fr.fix. Then
"compose"  email-fr.fix  (not corr.in)  under your TeX format,
just as though it were a typescript. Then follow instructions
given interactively. Interactive correction  of possible errors
is a minimum service.  *Automatic* correction of errors is offered
*provided* a special language "emailFR" with its very peculiar
hyphenation patterns is available in the TeX format used.  This
(tiny) language is always present in French formats built with
the format-dumper mechanism on ftp matups.matups.fr. The
quickest way to get such a format if you do not have one is to
use email-fr.dmp distributed with this file.
     

 ** Guillemets

     Because it is currently a font-dependant matter, no
support is provided here for true (double) French guillemets.
They are grammatically equivalent to ordinary double quotes
--- but preferred thereto in most literary work. However, if
you wish to import a definition, the macro "#1" can be
redefined to print them. The most common syntax for typing 
them is \<...\>.


 ** Single quotes are bannished as not French

     The following English (prose) typing has also been invalidated:
     
 ` for left single quote; use \lq instead
 ' for right single quote; use \rq instead

Single quotes are not used in French. But double quotes are
and the usual syntax ``...'' works. 


 ** Smart Quotes

    After the \SmartQuotes command, the syntax
"<text>" puts <text> between left and right double quotes. 
When defined, the smart quotes macro "#1" provides double
quotes that must be paired within each paragraph. A further
alternative (always available) is offered by \lq\lq and
\rq\rq.

    In the header version, the smart quotes macro  "#1"  is
activated by uncommenting a line at the beginning.

    In the style file version, \SmartQuotes and
\noSmartQuotes turn this feature on and off.  When it is off,
the character " is in its inactive state.  With AmSTeX one
will have to turn off the smart quotes feature when one wishes to
use the syntax \tag"...", \item"...", or \footnote"..." ---
unless perchance your AmS format has been patched appropriately.
Similarly problems occur in LamsTeX and probably elsewhere.

    \SmartQuotes activates  "  and hence the same prudence
is recommended as with \frenchemail itself (see \flexcat! below).

    A switch from French to English might reasonably
automatically change the meaning of \SmartQuotes to use single
quotes  rather than double, and inversely. Then email-fr.sty
is suitable for, say, an essay in English on a French subject.
A TeXpert can arrange this for your TeX environment on demand.


 ** Switching email-fr macros on and off

     As a safety measure, the email-fr macros have been set
up so that they have essentially no effect beyond any group
within which they occur. Thus, once a block of succinct
typing composes correctly under an unfamiliar format, it is a
near certainty that the block can be included in a larger
typescript under the same format without causing trouble ---
provided grouping is used as in the recipe:

 \begingroup <the header macros> <succinct typing> \endgroup

Here <these macros> refers to the block of macros after
\endinput above set up for cut and paste insertion.  

     When several blocks of succinct typing are being
incorporated into a larger typescript one can avoid repeating
the header by switching to the style file version
--- replacing the header by \input email-fr.sty. Then
there are two syntaxes available. The simplest is

  \begingroup \frenchemail <succinct typing> \endgroup

     There is also the environment syntax

  \beginemailFR  <succinct typing> \endemailFR

and the LaTeX equivalent

  \begin{emailFR}  <succinct typing> \end{emailFR}

This email environment makes available new macros
\emailinput and \macroinput. They together replace \input,
which, we recall, is then forbidden.

    \emailinput <file>  

serves to input files of succinct email typing; for this the
active catcodes for accents etc. are maintained.  

    \macroinput <file>

serves to input non-email material, in particular macros; for
this the active catcodes are momentarily restored to their 
state outside the environment.

     How much of a manuscript can be typed with the email-fr
macros steadily in force?  The chief restriction is that TeX
programming or unfamiliar syntax involving `'^_/ should not
appear in your typescript while the email-fr macros are in
force.  However, normal use of `'^_/ in normal *math* is is
perfectly OK. In well constructed TeX typescripts, all the
programming is collected into a style file and \input at the
outset; anytime thereafter the email-fr macros can hopefully
be invoked by \frenchemail once and for all, even without the
help of grouping or environment. See the appendix if you wish
to use the email-fr macros still more liberally.


 **  Where NOT to switch email-fr macros on or off.

     The most important place to avoid is a segment of typing that
is in fact a macro argument (or similar construct).  The reason is
that the category changes involved are then usually not not obeyed
in time. Unfortunately, the user can often not tell whether a
given spot on his typescript is in a macro argument or not.  Hence
there is a test macro

      \flexcat!

that one can temporarily insert to tell.  Use flexcat! whenever
you encounter trouble in switching email-fr macros on or off.


 **  Hints on using TeX for email

    No characters other than the ASCII characters 32--126 and
carriage return should be used.  All lines (carriage return to
carriage return) must be of length much less than 80 (50 is a good choice).
All lines should for safety begin with a space. 

    In particular, replace tabs (character 9) by
a certain number spaces (and be sure not to to use 
tabs for anything but spaces in the first place).

    While you can certainly assure these conditions by hand, you
will find that many text editors provide suitable automatic
functions.  

     Further, email-fr.fix will optionally provide 
 (i) the space beginning lines in its output
 (ii) a check-list of ASCII characters 33--126 in the header of
its output (32 is space).  

     For its part, mail-fr.sty will complain of characters
127--255 if you issue the command

      \BlockExtendedASCII

And it will do the same for the characters 0--31 via the
command

      \BlockLowASCII

(Exception: 13 and 10 are not excluded as they in some combination
represent carriage return.)  It is advisable
to take *both* measures if you want a portable typescript; hence
the single command

      \BlockNonASCII

for this purpose.

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


APPENDIX 

 *** Active characters and wider use of the email-fr macros ***

     The following comments are for TeXperts only.

     The email-fr macros make the characters /_`'^ active.
This technique that is powerful but dangerous --- which makes 
it difficult to keep the email-fr macros in force all the time,
a practice that would in many respects be most convenient.

     The danger is fortunately limited to those characters that
receive active category on input as a consequence of the
email-fr macros.  Characters input with the normal category 12 
(=other) keep category 12 forever and behave normally. Be aware
that a given character's category is assigned at input by TeX,
and the category of the resulting character token is not influenced
by later occurences of the \catcode assignments.

     There are two sorts of problems one encounters beyond the
necessary avoidance of the single quotes syntax `...'  that has
already been mentioned.  These extra problems fortunately do 
not often arise outside of TeX programming.

 (I) Standard usage for the category 12 versions of '"`^ in TeX
programming is unavailable when these characters have category
13. In particular, where numbers are expected, watch out for ` '
and " to indicate binary, octal and hexadecimal.  Watch out for
^^ to indicate octets being artificially input (such as ^^ff for
octet 255 or ^^I for 9).  These are used almost exclusively by
programmers and the disabling of \input plus the use of grouping
should avoid trouble most of the time.  Fortunately, " can cause
no trouble while the smart quotes feature is off. Also, there is
usually a way to change the usage so that it does  not matter what
the category of these characters is; for example
\catcode`\!=12 can be replaced by
\expandafter\catcode\string`\!=12.

 (II)  TeX macro packages may use some of the characters
'`^/_ in their private macro syntax.  For example ^ is used
for index compilation in Knuth's style file for the TeXbook.
It is often possible for a programmer to fix things 
to achieve compatibility with email-fr.

     Thus, the use of the email-fr macros beyond the context of
straight prose and math for which they are chiefly intended is
by no means impossible, but it does occasionally require some
attention from a TeX programmer.


Orsay, March and April 1993

