summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-10-10 23:15:33 +0000
committerKarl Berry <karl@freefriends.org>2008-10-10 23:15:33 +0000
commitb8d4a9b3b475ba83bfd55f098881afb3efcaa1f2 (patch)
tree8d371c87a4cee6d1fb57990e8547893904e47281
parent41977cc6e6769af289a96d6846be398bdd94d133 (diff)
gmutils update (8oct08)
git-svn-id: svn://tug.org/texlive/trunk@10916 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/gmutils/gmutils.pdfbin1275572 -> 1286801 bytes
-rw-r--r--Master/texmf-dist/tex/latex/gmutils/gmutils.sty239
2 files changed, 151 insertions, 88 deletions
diff --git a/Master/texmf-dist/doc/latex/gmutils/gmutils.pdf b/Master/texmf-dist/doc/latex/gmutils/gmutils.pdf
index f86eaacf795..5f75088ea81 100644
--- a/Master/texmf-dist/doc/latex/gmutils/gmutils.pdf
+++ b/Master/texmf-dist/doc/latex/gmutils/gmutils.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
index 0736669b416..01defbad243 100644
--- a/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
+++ b/Master/texmf-dist/tex/latex/gmutils/gmutils.sty
@@ -53,7 +53,8 @@
% \chschange{v0.92}{2008/8/11}{4133}
% \chschange{v0.93}{2008/8/21}{4140}
% \chschange{v0.93}{2008/8/30}{4501}
-% \chschange{v0.94}{2008/10/4}{4869}
+% \chschange{v0.94}{2008/10/4}{4880}
+% \chschange{v0.95}{2008/10/8}{4908}
%
%
% \skiplines we skip the driver
@@ -82,7 +83,7 @@ pagella, fontspec=quiet]{gmdocc}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmutils}
- [2008/10/03 v0.94 some rather TeXnical macros, some of them tricky (GM)]
+ [2008/10/04 v0.95 some rather TeXnical macros, some of them tricky (GM)]
%
% \tableofcontents
@@ -175,6 +176,9 @@ pagella, fontspec=quiet]{gmdocc}
\let\@xa\expandafter
\let\@nx\noexpand
+\def\@xau{\@xa\unexpanded\@xa}
+%\changes{v0.94}{2008/10/4}{added}
+
%} \HideDefining*\pdef
\def\pdef{\protected\def}
%\changes{v0.93}{2008/08/20}{added}
@@ -394,29 +398,107 @@ pagella, fontspec=quiet]{gmdocc}
\newcommand*\g@relaxen{\global\@relaxen}
\@ifdefinable\grelaxen{\let\grelaxen\g@relaxen}
+% \division{\cs{gm@ifundefined}---a~test that doesn't create any\
+% hash entry unlike \cs{@ifundefined}}
+
+% I~define it under another name not redefine |\@ifundefined| because
+% I~can imagine an odd case when something works thanks to
+% |\@ifundefined|'s `relaxation effect'.
+
+\long\def\gm@ifundefined#1{% not |\protected| because expandable.
+ % \changes{v0.94}{2008/9/12}{added. All \cs{@ifundefined}s used by
+ % me changed to this}
+ % \changes{v0.94}{2008/10/03}{made robust to unbalanced \cs{if}s and
+ % \cs{fi}s the same way as \LaTeX's \cs{@ifundefined} (after a~heavy
+ % debug :-)}
+ \ifcsname#1\endcsname% defined
+ \@xa\ifx\csname #1\endcsname\relax% but as |\relax|
+ \afterfifi\@firstoftwo%
+ \else% defined and not |\relax|
+ \afterfifi\@secondoftwo%
+ \fi
+ \else% not defined
+ \afterfi\@firstoftwo%
+ \fi}
+
+
+\long\def\gm@testdefined#1\iftrue{% This is a~macro that expands to
+ % \incs{iftrue} or \incs{iffalse} depending on whether it's argument
+ % is defined in the \LaTeX\ sense. Its syntax requires an
+ % \incs{iftrue} to balance \incs{if}s with \incs{fi}s.
+ % \changes{v0.95}{2008/10/8}{added}
+ \csname
+ \ifdefined#1%
+ \ifx#1\relax
+ iffalse%
+ \else iftrue%
+ \fi
+ \else iffalse%
+ \fi\endcsname
+}
-%\division{From the ancient \pk{xparse} of \TeX Live 2007}
-% The code of this section is rewritten contents of the \pk{xparse}
-% package version 0.17 dated 1999/09/10, the version available in \TeX
-% Live 2007-13, in Ubuntu packages at least. It's a~stub `im Erwartung'
-% (Schönberg) for the \LaTeX 3 bundle and it does what I~want, namely
-% defines |\DeclareDocumentCommand|. I~rewrote the code to use the usual
-% catcodes (only with |@| a~letter) and not to use the \pk{ldcsetup}
-% package (which caused an error of
-% undefined \CS |\KV@def|).
+\long\def\gm@testundefined#1\iftrue{% we expand the last macro two
+ % levels. We repeat the parameter string to force the proper syntax.
+ % \changes{v0.95}{2008/10/8}{added}
+ \@xa\@xa\@xa\unless\gm@testdefined#1\iftrue}
+
+% \subdivision{Storing and restoring the catcodes of specials}
+
+\newcommand*\gmu@storespecials[1][]{% we provide a~possibility of
+ % adding stuff. For usage see line \ref{@storespecials}.
+ \def\do##1{\catcode`\@nx##1=\the\catcode`##1\relax}%
+ \edef\gmu@restorespecials{\dospecials\do\^^M#1}}
+
+\newcommand*\gmu@septify[1][]{% restoring the standard catcodes of specials. The
+ % name is the opposite of `sanitize' ^^A(
+ % :-)\,. It restores also the original catcode of \inverb|^^M|
+ \def\do{\relax\catcode`}%
+ \do\ 10\do\\0\do\{1\do\}2\do\$3\do\&4%
+ \do\#6\do\^7\do\_8\do\%14\do\~13\do\^^M5#1\relax}
+
+
+ %\division{From the ancient \pk{xparse} of \TeX Live 2007}
+ % The code of this section is rewritten contents of the \pk{xparse}
+ % package version 0.17 dated 1999/09/10, the version available in \TeX
+ % Live 2007-13, in Ubuntu packages at least. It's a~stub `im Erwartung'
+ % (Schönberg) for the \LaTeX 3 bundle and it does what I~want, namely
+ % defines |\DeclareDocumentCommand|. I~rewrote the code to use the usual
+ % catcodes (only with |@| a~letter) and not to use the \pk{ldcsetup}
+ % package (which caused an error of
+ % undefined \CS |\KV@def|).
+ %
+ % Well, I~add the |\protected| prefix to the first macro.
+%
+% After exchange of some mails with Morten H\o{}gholm and trying
+% \pk{xparse} of 2008/08/03 svn 748 (which beautifully spoils the
+% catcodes) I~wrap the
+% ancient code in a~conditional to avoid name collision if someone
+% loads \pk{xparse} before \pk{gmutils}
+\gm@testundefined\DeclareDocumentCommand\iftrue
+
+\unless\ifdefined\@temptokenb
\newtoks\@temptokenb
+\fi
+
\newtoks\xparsed@args
-\long\def\DeclareDocumentCommand#1#2#3{%
+
+\long\def\DeclareDocumentCommand#1#2#3{%\
+ % \begin{enumargs}
+ % \item command to be defined,
+ % \item arguments specification,
+ % \item definition body.
+ % \end{enumargs}
\@tempcnta\z@
\toks@{}%
\@temptokena\toks@
\@temptokenb\toks@
- \@ddc#2X\edef#1{%
- \noexpand\@ddc@
+ \@ddc#2X% |X| is the guardian of parsing.
+ \protected\edef#1{% The |\protected| prefix is my (GM) addition.
+ \@nx\@ddc@
{\the\toks@}%
- \@xa\noexpand\csname\string#1\endcsname
- \noexpand#1%
+ \@xa\@nx\csname\string#1\endcsname
+ \@nx#1%
}%
\long\@xa\def\csname\string#1\@xa\endcsname
\the\@temptokena{#3}}
@@ -544,6 +626,7 @@ pagella, fontspec=quiet]{gmdocc}
}}
\let\@ddc@m\undefined
+
\long\def\@ddc@xm#1\toks@#2{%
\addto@hook\toks@{{#2}}#1\toks@}
@@ -558,20 +641,25 @@ pagella, fontspec=quiet]{gmdocc}
\long\def\@ddc@xmmmmm#1\toks@#2#3#4#5#6{%
\addto@hook\toks@{{#2}{#3}{#4}{#5}{#6}}#1\toks@}
+
\long\def\@ddc@xmmmmmm#1\toks@#2#3#4#5#6#7{%
\addto@hook\toks@{{#2}{#3}{#4}{#5}{#6}{#7}}#1\toks@}
+
\long\def\@ddc@xmmmmmmm#1\toks@#2#3#4#5#6#7#8{%
\addto@hook\toks@{{#2}{#3}{#4}{#5}{#6}{#7}{#8}}#1\toks@}
+
\long\def\@ddc@xmmmmmmmm#1\toks@#2#3#4#5#6#7#8#9{%
\addto@hook\toks@{{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}#1\toks@}
+
\long\def\@ddc@xmmmmmmmmm\the\toks@#1#2#3#4#5#6#7#8#9{%
\addto@hook\toks@{{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}\the\toks@}
+
\let\@ddc@x\relax
\long\def\DeclareDocumentEnvironment#1#2#3#4{%
-\@xa\DeclareDocumentCommand\csname#1\endcsname{#2}{%
- #3}%
-\@namedef{end#1}{#4}%
+ \@xa\DeclareDocumentCommand\csname#1\endcsname{#2}{%
+ #3}%
+ \@namedef{end#1}{#4}%
}
\let\@parsed@endenv\undefined
\let\@parsed@endenv@\undefined
@@ -625,6 +713,7 @@ pagella, fontspec=quiet]{gmdocc}
\IfBooleanTF{#1}\@empty
}
+\fi% of |\unless\ifdefined\DeclareDocumentCommand|.
% \division{Ampulex Compressa-like modifications of macros}
% Ampulex Compressa is a~wasp that performs brain surgery on its
@@ -633,32 +722,43 @@ pagella, fontspec=quiet]{gmdocc}
% resembles Ampulex's actions but here is a~tool for a~replacement of
% part of macro's definition.
%
-% The \cs{ampulexdef} command takes its |#4| which has to be a~macro
-% and replaces part of its definition (delimited with |#5| and |#6|)
-% with the replacement |#5|. The redefinition may be prefixed with
-% |#1|. |#4| may have parameters and for such a~macro you have to set
-% the parameters string and arguments string with the \cs{ampulexset}
-% declaration. If \cs{ampulexdef} doesn't find the sart and end tokens
-% in the meaning of the macro, it does nothing to it. |#2| and |#3|
-% are parameters' strings for \cs{def} and for eating by first-level
-% expansion. You have to write |####| instead of |#| or you can use
-% |\ampulexhash| as well. For an example
-% use see line \ref{ampulexset}.
-
-%^^A\RequirePackage{xparse}
+% The \cs{ampulexdef} command takes its |#2| which has to be a~macro
+% and replaces part of its definition delimited with |#5| and |#6|
+% with the replacement |#7|. The redefinition may be prefixed with
+% |#1|. |#2| may have parameters and for such a~macro you have to set
+% the parameters string and arguments string (the stuff to be taken by
+% the one-step expansion of the macro) as the optional |[#3]| and
+% |[#4]|. . If \cs{ampulexdef} doesn't find the start and end tokens
+% in the meaning of the macro, it does nothing to it. You have to
+% write |####| instead of |#| or you can use |\ampulexhash| as
+% well. For an example use see line \ref{ampulexset}.
+
+%^^A \showthe\catcode`:
+%^^A \showthe\catcode`_
+%^^A
+%^^A \gmu@storespecials
+%^^A
+%^^A \RequirePackage{xparse}[2008/08/03]
+%^^A
+%^^A % This should not happen but well, it did: the catcodes changed the
+%^^A % \pk{expl3} way leaked so I~fix them here.
+%^^A \gmu@septify
+%^^A \@makeother\:
+%^^A \catcode`_=8
+%^^A \catcode`\ =10
-%^^A\long\def\gobblefour#1#2#3#4{}
\DeclareDocumentCommand\ampulexdef{O{}mO{}O{}mmm}{%^^B
- % \begin{enumargs}
- % \item definition prefix, empty by default,
- % \item macro to be redefined,
- % \item \cs{def} parameters string, empty by default,
- % \item definition body parameters for the first expansion, empty by default,
- % \item start token(s),
- % \item end token(s)
- % \item replacement.
- % \end{enumargs}
+ % \begin{enumargs*}
+ % \opt definition prefix, empty by default,
+ % \mand macro to be redefined,
+ % \opt \cs{def} parameters string, empty by default,
+ % \opt definition body parameters to be taken in a~one-step
+ % expansion of the redefined macro, empty by default,
+ % \mand start token(s),
+ % \mand end token(s)
+ % \mand replacement.
+ % \end{enumargs*}
% \changes{v0.93}{2008/08/29}{added}
% \changes{v0.94}{2008/09/07}{made \pk{xparse}-ish and
% \cs{ampulexset} removed}
@@ -777,7 +877,7 @@ pagella, fontspec=quiet]{gmdocc}
\fi
\reserved@c}
-{\def\:{\let\@sptoken= } \: % this makes |\@sptoken| a space token.
+{\def\:{\let\@sptoken= } \global\: % this makes |\@sptoken| a space token.
% \DefIndex\@xifncat
\def\:{\@xifncat} \@xa\gdef\: {\futurelet\@let@token\@ifncat}}
@@ -906,31 +1006,6 @@ pagella, fontspec=quiet]{gmdocc}
\long\def\afteriffififi#1#2\fi#3\fi#4\fi{\fi\fi#1}
\long\def\afterfififi#1#2\fi#3\fi#4\fi{\fi\fi\fi#1}
-% \division{\cs{gm@ifundefined}---a~test that doesn't create any\
-% hash entry unlike \cs{@ifundefined}}
-
-% I~define it under another name not redefine |\@ifundefined| because
-% I~can imagine an odd case when something works thanks to
-% |\@ifundefined|'s `relaxation effect'.
-
-\long\def\gm@ifundefined#1{%
- % \changes{v0.94}{2008/9/12}{added. All \cs{@ifundefined}s used by
- % me changed to this}
- % \changes{v0.94}{2008/10/03}{made robust to unbalanced \cs{if}s and
- % \cs{fi}s the same way as \LaTeX's \cs{@ifundefined} (after a~heavy
- % debug :-)}
- \ifcsname#1\endcsname% defined
- \@xa\ifx\csname #1\endcsname\relax% but as |\relax|
- \afterfifi\@firstoftwo%
- \else% defined and not |\relax|
- \afterfifi\@secondoftwo%
- \fi
- \else% not defined
- \afterfi\@firstoftwo%
- \fi}
-
-
-
% \division{Environments redefined}
% \subdivision{Almost an environment or redefinition of \cs{begin}}
@@ -1838,13 +1913,13 @@ pagella, fontspec=quiet]{gmdocc}
% we should name it |\SetSectionFormatting| and add issuing errors if
% the inner macros are undefined.
%
-%\begin{enumargs}^^B
-%\item (optional) the flags, e.g. |breakbefore|, |breakafter|;
+%\begin{enumargs*}^^B
+%\opt the flags, e.g. |breakbefore|, |breakafter|;
%\item the sectioning name, e.g. |chapter|, |part|;
%\item preskip;
%\item heading type;
%\item postskip
-%\end{enumargs}
+%\end{enumargs*}
%
\relaxen\SetSectionFormatting
@@ -2214,13 +2289,13 @@ pagella, fontspec=quiet]{gmdocc}
\def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
-\newcommand*\DeclareLogo[3][\relax]{% \begin{enumargs}
- % \item is for non-\LaTeX\ spelling and will be used in the
+\newcommand*\DeclareLogo[3][\relax]{% \begin{enumargs*}
+ % \opt is for non-\LaTeX\ spelling and will be used in the
% \acro{PD1} encoding (to make pdf bookmarks);
% \item is the command, its name will be the PD1 spelling by
% default,
% \item is the definition for all the font encodings except PD1.
- % \end{enumargs}
+ % \end{enumargs*}
%
\ifx\relax#1\def\gmu@reserveda{\@xa\@gobble\string#2}%
\else
@@ -2961,7 +3036,8 @@ pagella, fontspec=quiet]{gmdocc}
% It's very strange to me but it seems that $\continuum$ is not
% defined in the basic math packages. It is missing at least in the
% \textit{Symbols} book.
-\pprovide\continuum{\gmu@RPfor{eufrak}\mathfrak\mathfrak{c}}
+\pprovide\continuum{%
+ \gmu@RPfor{eufrak}\mathfrak\ensuremath{\mathfrak{c}}}
% And this macro I~saw in the \pk{ltugproc} document class nad I~liked
% it.
@@ -3836,19 +3912,6 @@ pagella, fontspec=quiet]{gmdocc}
% And now write \shortthousep |\thous 3628800| to get \thous 3628800 even with
% a~blank space (beware of the range of \TeX's counts).
-% \subdivision{Storing and restoring the catcodes of specials}
-
-\newcommand*\gmu@storespecials[1][]{% we provide a~possibility of
- % adding stuff. For usage see line \ref{@storespecials}.
- \def\do##1{\catcode`\@nx##1=\the\catcode`##1\relax}%
- \edef\gmu@restorespecials{\dospecials\do\^^M#1}}
-
-\newcommand*\gmu@septify[1][]{% restoring the standard catcodes of specials. The
- % name is the opposite of `sanitize' ^^A(
- % :-)\,. It restores also the original catcode of \inverb|^^M|
- \def\do{\relax\catcode`}%
- \do\ 10\do\\0\do\{1\do\}2\do\$3\do\&4%
- \do\#6\do\^7\do\_8\do\%14\do\~13\do\^^M5#1\relax}
% \subdivision{\pk{hyperref}'s \cs{nolinkurl} into \cs{url*}}