\ProvidesPackage{dhua}[2011/09/19 v0.11 German phrase abbrevs (UL)]
%% copyright (C) 2011 Uwe Lueck, 
%% http://www.contact-ednotes.sty.de.vu 
%% -- author-maintained in the sense of LPPL below.
%%
%% This file can be redistributed and/or modified under 
%% the terms of the LaTeX Project Public License; either 
%% version 1.3c of the License, or any later version.
%% The latest version of this license is in
%%     http://www.latex-project.org/lppl.txt
%% We did our best to help you, but there is NO WARRANTY. 
%%
%% Please report bugs, problems, and suggestions via 
%% 
%%   http://www.contact-ednotes.sty.de.vu 
%%
%% \pagebreak
%% == Package Options ==
%% \label{sec:opt} 
%% === Idea ===
%% You may say ``I can \[`\newcommand{\ua}{u.\,a.\xspace}'\]
%% myself." Yes, you can. The point of \[`\newtwopartdhua{\ua}{u}{a}'\] 
%% is that you can use that same defining instruction for all of the 
%% following \emph{types of documents:} \ (i)~\emph{requiring} |\xspace| 
%% because in the source some `\ua' precedes a word without control space 
%% (`\ ', as in `\ua weil'); \ (ii)~\emph{not} using `\xspace'
%% (I use it with \CtanPkgRef{morehype}{blog.sty} 
%%  where `\xspace' does not work); 
%% \ (iii)~to be typeset for high-quality \emph{printing} 
%% (thin space strongly recommended)
%% \ (iv)~to be displayed as \HTML\ 
%% (\Wikienref{web typography} relevant, thin space somewhat dangerous). 
%% \
%% In order to use (almost) the \emph{same source} for (iii) and (iv), 
%% the \LaTeX\ document preamble just must load the |[web]| option 
%% for (iv) where it doesn't for (iii). 
%% 
%% === `web' ===
%% \begin{german}
%%    Paketoption |[web]| verwendet ein gesch\"utztes 
%%    Leerzeichen normaler Breite anstelle des empfohlenen 
%%    schmalen Festabstands.
%% \end{german}
%% In \wikienref{web typography}{web typography,} `&nbsp;' 
%% (\Wikienref{no-break space}) may be used instead of a thin space 
%% because some browsers do not support the latter 
%% (the non-breakable one---which is not a \emph{named} \HTML\ 
%%  entity, it is U+202F---and some even the breakable one---which 
%% is the named \HTML\ entity \verb+&thinsp;+).
%% You can decide for this choice by package option |[web]|.
%% (Actually I use the package for direct \HTML\ generation 
%%  with 'blog.sty'.)
%%
%% === `xspace' ===
%% With option |[xspace]|, the package's setup commands equip all the 
%% single abbreviation macros with a final `\xspace' from the 
%% \ctanpkgref{xspace} package in the \LaTeX\ \ctanpkgref{tools} bundle. 
%% % (With 'blog.sty', `\xspace' does not work.)
%% \begin{german}
%%   Mit der Paketoption `[xspace]' verwenden alle Abk\"urzungsmakros 
%%   automatisch (\mbox{--} sie enden auf \mbox{--}) `\xspace'.
%% \end{german}
%%
%% === Implementations ===
%% |\dhuaspace| stores the dot plus the inner space
%% (TODO could be useful for Euro symbol without dot). 
%% The default setting is:
\newcommand*\dhuaspace{.\,}
%% |\DhuaSpace| is for getting a single token in 
%% \verb+\edef+s: 
\newcommand*{\DhuaSpace}{\noexpand\dhuaspace}
%% Option |[web]| uses the tilde (tie, `~') instead of `\,':
\DeclareOption{web}{\newcommand*\dhuaspace{.~}}
%% I reasoned as follows for this: \ (i)~\emph{Either} the \HTML\ is 
%% generated from \acro{DVI}, this is what 
%% \CtanPkgRef{tex4ht}{TeX4ht} does. I don't know exactly, 
%% but I assume that the combinatin of \pkg{TeX4ht} with a 
%% \TeX\ run finally converts the tilde into `&nbsp;'.
%% \ (ii)~\emph{Or} the \HTML\ generator translates the \TeX\ code 
%% into \HTML\ in a more direct way. I don't know what all of these 
%% programs actually do, but they ``should" translate `~' into 
%% `&nbsp;'. At least 'blog.sty' does, for sure. 
%%
%% |\dhuaxspace| stores what closes the entire 
%% abbreviation definition; by default it is a dot only. 
%% Because German text should be typeset using
%% `\frenchspacing', we do not care about the space factor:
\newcommand*{\dhuaxspace}{.}
\@ifdefinable{\DhuaXspace}{\let\DhuaXspace\dhuaxspace}
\DeclareOption{xspace}{%
    \AtEndOfPackage{\RequirePackage{xspace}}%%          %% 2011/09/09
    \renewcommand*{\dhuaxspace}{.\xspace}%
    \renewcommand*{\DhuaXspace}{\noexpand\dhuaxspace}}
%% ---That were all options, processed now:
\ProcessOptions
%%
%% == Setup Commands ==
%% \label{sec:setup}
%% The syntax |\newdhua{<new-macro>}{<replace>}| is the same 
%% as for \LaTeX's standard `\newcommand' etc. defining 
%% user macros \emph{without parameters}. 
%% However, `\newdhua' internally uses `\edef' in order to 
%% minimize the number of tokens in the actual internal 
%% replacement text. This additionally requires using 
%% `\DhuaSpace' for separating the one-word abbreviations 
%% in <replace>. 
\newcommand*{\newdhua}[2]{\@ifdefinable#1{%
%     \protected@edef#1{#2\DhuaXspace}%
    \let\protect\noexpand                       %% 2011/09/04
%% ... an unusual meaning of |\protect|, CARE! 
%% I.e., `\protect' is used here to prevent expansion 
%% in the setup macros. It is not stored for future expansion 
%% with its usual robustification purpose.
    \edef#1{#2\DhuaXspace}%
    \let\protect\@typeset@protect
}}
%% \begin{german}
%%   Um ein Makro <neu> f\"ur eine Abk\"urzung mit beliebig vielen 
%%   Gliedern zu definieren, trennt man die einzelnen Glieder 
%%   im <Ergebnis>-Argument der Definition 
%%   |\newdhua{<neu>}{<Ergebnis>}| 
%%   durch `\DhuaSpace' (Beispiel unten).
%%
%% \[|\newtwopartdhua{<neu>}{<B.-1>}{<B.-2>}|\]
%%   definiert dasselbe Makro <neu> wie 
%% \[`\newdhua{<neu>}{<B.-1>\DhuaSpace<B.-2>}'\]
%% \end{german}
%%
%% |\newtwopartdhua{<new>}{<letter-1>}{<letter-2>}|
%% results in the same macro <new> as 
%% `\newdhua{<new>}{<letter-1>\DhuaSpace<letter-2>}':
\newcommand*{\newtwopartdhua}[3]{\newdhua#1{#2\DhuaSpace#3}}
%%
%% == Single Abbreviation Macros ==
%% \label{sec:single}
%% The user may want to use 
%% (some of) the following single macro names   %% 2011/09/09
%% for a different purpose or so; to this end, a file 
%% `dhua.cfg' may contain a different set of definitions.
%% `\IfFileExists' works depending on whether a file 
%% `dhua.cfg' is found:
\IfFileExists{dhua.cfg}{% 
  \typeout{^^J * single definitions read from 
               \string`dhua.cfg\string'         %% 2011/09/19
               *^^J}%
  \input{dhua.cfg}}{% 
%% |\idR| exemplifies multi-part abbreviations, 
%% where \qtd{multi} means ``more than two":
  \newdhua{\idR}{i\DhuaSpace d\DhuaSpace R}
%   \show\idR
%% \begin{german}
%%   |\idR| erzeugt \qtd{\idR} -- ein Anwendungsfall 
%%   f\"ur |\newdhua|. Nachfolgend wird nur noch 
%%   |\newtwopartdhua| verwendet.
%% \end{german}
%%
%% \LaTeX\ actually defines |\dh| as something nordic 
%% (one of my earliest macro making experiences)
%% so we are \emph{re}defining it:
  \PackageWarning{dhua}{Redefining \string\dh}
  \let\dh\relax
  \newtwopartdhua{\dh}{d}{h}
%   \show\dh
%% \begin{german}
%%   |\dh| wird hier \emph{umdefiniert}, um \qtd{\dh} zu bekommen.
%%   Die \"ubrigen Makros sind \qtd{normale} Anwendungs\-f\"alle 
%%   von `\newtwopartdhua', man achte aber noch auf die 
%%   Verwendung von `\protect'.
%% \end{german}
%%
%% \dqtd{Normal} cases                          %% TODO catchdq
%% (|\oae|  for \qtd{\oae}, 
%%  |\so|   for \qtd{\so},  |\su|   for \qtd{\su}, %% 2011/09/19
%%  |\uae|  for \qtd{\uae}, 
%%  |\ua|   for \qtd{\ua},  |\vglu| for \qtd{\vglu},
%%  |\vglo| for \qtd{\vglo}, 
%%  |\zB|   for \qtd{\zB},   %% was |\qtd{\zB}| until 2011/09/19
%%  |\zT|   for \qtd{\zT}):
  \newtwopartdhua{\oae}{o}{\protect\"a} 
% \newtwopartdhua{\oae{o}{\"a} 
%   \show\oae
%% ---exemplifying use of |\protect| so the definition of `\oae'
%% has a single token `\"', not an expansion of `\"'. 
  \newtwopartdhua{\so}  {s}{o} 
  \newtwopartdhua{\su}  {s}{u} 
  \newtwopartdhua{\ua}  {u}{a} 
  \newtwopartdhua{\uae} {u}{\protect\"a} 
  \newtwopartdhua{\vglu}{vgl}{u} 
  \newtwopartdhua{\vglo}{vgl}{o} 
  \newtwopartdhua{\zB}  {z}{B}
  \newtwopartdhua{\zT}  {z}{T} 
}                                       %% Closes \IfFileExists
%%
%% == A Different Approach ==
%% \begin{german}
%%   Statt f\"ur 
%%   \qtd{\abkii AB} %%% `A.\,B.' 
%%   ein Makro zu definieren, 
%%   kann man auch \glqq`\abkii AB'\grqq\ tippen.
%% \end{german}
%%
%% I also thought that, instead of defining an abbreviation macro 
%% (perhaps `\<letter-1><letter-2>'), 
%% |\abkii <letter-1><letter-2>|  %% add. space rm. {} 2011/09/10
%% could be preferred to typing the 
%% the two dots and `\,':
\@ifdefinable\abkii{%               %% w/o `protected' 2011/09/09:
    \edef\abkii#1#2{#1\DhuaSpace#2\DhuaXspace}} 
%   \show\abkii
%% So `\abkii AB' results in \qtd{\abkii AB}, saving you from 
%% `A.\,B.'.---You may create 
%% your own shorter alias <shal> for `\abkii' by `\let<shal>\abkii'.
%% Perhaps `\II': \let\II\abkii 
%% `\let\II\abkii'---`\II AB'---\qtd{\II AB}. 
%% Is this better than `A.\,B.'?
%% 
%% == The End ==
\endinput
%%
%% == VERSION HISTORY ==
v0.1    2011/09/13  renamed `dhusw'->`dhua'
v0.1a   2011/09/14  doc. fix
        2011/09/16  doc. of options much extended
v0.11   2011/09/19  don't use \qtd with .cfg-\typeout; \so, \su; 
                    doc. fix \zB
