summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-20 21:52:58 +0000
committerKarl Berry <karl@freefriends.org>2016-04-20 21:52:58 +0000
commitfe2d50f648a774c6f405d54b77ab8e5c2f37e4b6 (patch)
tree550832aeb2c5d7d63af10cb7770e0055e3056fae /Master/texmf-dist/source/latex
parent658a820e8fce6fffa034e89505a59080716852ff (diff)
multidef (20apr16)
git-svn-id: svn://tug.org/texlive/trunk@40637 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r--Master/texmf-dist/source/latex/multidef/multidef.dtx134
-rw-r--r--Master/texmf-dist/source/latex/multidef/multidef.ins2
2 files changed, 107 insertions, 29 deletions
diff --git a/Master/texmf-dist/source/latex/multidef/multidef.dtx b/Master/texmf-dist/source/latex/multidef/multidef.dtx
index 11c80e93628..6f849e1cc9a 100644
--- a/Master/texmf-dist/source/latex/multidef/multidef.dtx
+++ b/Master/texmf-dist/source/latex/multidef/multidef.dtx
@@ -4,7 +4,7 @@
%<*driver>
\documentclass{ltxdoc}
\usepackage{doc}
-\usepackage{multidef}
+\usepackage{multidef-save}
\usepackage{dsfont}
\def\sty#1{\textsf{#1.sty}}
@@ -14,14 +14,21 @@
%%%\AtBeginDocument{\CodelineIndex\EnableCrossrefs}
%%%\AtEndDocument{\PrintIndex}
\begin{document}
- \def\docdate{2016/03/14}
- \def\fileversion{1.00}
+ \def\docdate{2016/04/20}
+ \def\filedate{2016/04/20}
+ \def\fileversion{1.10}
\DocInput{multidef.dtx}
\end{document}
%</driver>
%
% \fi
-% \CheckSum{206}
+%
+%
+% \changes{1.00}{2016/03/14}{Initial release}
+% \changes{1.10}{2016/04/20}{Added def. of robust commands}
+%
+%
+% \CheckSum{329}
%% \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
@@ -87,7 +94,7 @@
% calligraphic-font letters in math mode. With \pack{multidef} I now
% simply write
%\begin{verbatim}
-%\multidef{\ensuremath{\mathcal{#1}}}{A-Z}
+%\multidef[prefix=cal]{\ensuremath{\mathcal{#1}}}{A-Z}
%\end{verbatim}
% \multidef[prefix=cal]{\ensuremath{\mathcal{#1}}}{A-Z}
% and write \cs{calG} to write~\calG. Here \texttt{A-Z} is a shorthand for the
@@ -131,6 +138,34 @@
%
% \section{The code}
%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}[1994/12/01]
+\ProvidesPackage{multidef}[2016/04/20 v1.10 definition of multiple commands]
+% \end{macrocode}
+%
+% We begin with importing package \pack{trimspaces}, or to define its command
+% \cs{trim@spaces}, in order to trim unwanted spaces in arguments:
+%\begin{macro}{\trim@spaces}
+% \begin{macrocode}
+\IfFileExists{trimspaces.sty}
+ {\RequirePackage{trimspaces}}
+ {}
+%% borrowing code from trimspaces, if package was not found.
+\catcode`\Q=3
+\@ifundefined{trim@spaces}
+ {\PackageWarning{multidef}
+ {Package trimspaces.sty not found.^^JDefining \noexpand\trim@spaces myself}
+ \newcommand\trim@spaces[1]{%
+ \romannumeral-`\q\trim@trim@\noexpand#1Q Q%
+ }
+ \long\def\trim@trim@#1 Q{\trim@trim@@#1Q}
+ \long\def\trim@trim@@#1Q#2{#1}}
+ {}
+\catcode`\Q=11
+%%
+% \end{macrocode}
+%\end{macro}
+%
% We use \pack{xkeyval} to handle package and command options. The package has
% two options, \ttt{noerr} and~\ttt{nowarn}. The former tells
% \pack{multidef} not to raise an error when redefining a command (default to
@@ -169,13 +204,15 @@
% \item \ttt{arg} (and the equivalent \ttt{args}) can be used to define the
% number of arguments of the series of commands to be defined.
% \item \ttt{long} and \ttt{global} can be used to define \cs{long} and
-% \cs{global} macros.
+% \cs{global} macros,
+% \item \ttt{robust} can be used to define robust commands.
% \end{itemize}
%\begin{macro}{prefix}
%\begin{macro}{suffix}
%\begin{macro}{arg}
%\begin{macro}{long}
%\begin{macro}{global}
+%\begin{macro}{robust}
% \begin{macrocode}
\define@key{mdef}{prefix}{\def\@mdprefix{#1}}
\define@key{mdef}{p}{\def\@mdprefix{#1}}
@@ -183,15 +220,17 @@
\define@key{mdef}{s}{\def\@mdsuffix{#1}}
\define@key{mdef}{arg}{\def\@mdargs{#1}}
\define@key{mdef}{args}{\def\@mdargs{#1}}
-\define@boolkeys{mdef}{long,global}[true]
+\define@boolkeys{mdef}{long,global,robust}[true]
\presetkeys{mdef}
- {p=,s=,prefix=,suffix=,long=false,global=false,arg=0,args=0}{}
+ {p=,s=,prefix=,suffix=,long=false,global=false,robust=false,
+ arg=0,args=0}{}
% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
+%\end{macro}
%
%
% We define shorthands for defining series of commands indexed by letters of
@@ -230,19 +269,19 @@
% the remainder of the list.
%\begin{macro}{\@mdef}
% \begin{macrocode}
-\def\@mdef #1,#2\@end{\expandafter\def\expandafter\@arg
- \expandafter{\romannumeral-\expandafter`\expandafter\.#1}%
- \ifx\@arg\@mdef@az
+\def\@mdef #1,#2\@end{%
+ \edef\@mdef@arg{\trim@spaces{#1}}%
+ \ifx\@mdef@arg\@mdef@az
\expandafter\@mdef \@mdef@alphabet,\@end
\else
- \ifx\@arg\@mdef@AZ
+ \ifx\@mdef@arg\@mdef@AZ
\expandafter\@mdef \@mdef@Alphabet,\@end
\else
- \expandafter\@@mdef\@arg->->->\@end
+ \expandafter\@@mdef\@mdef@arg->->->\@end
\fi
\fi
- \def\@arg{#2}%
- \ifx\@arg\@empty\else\@mdef #2\@end\fi}
+ \def\@mdef@arg{#2}%
+ \ifx\@mdef@arg\@empty\else\@mdef #2\@end\fi}
% \end{macrocode}
%\end{macro}
%
@@ -262,10 +301,12 @@
\def\@@mdef#1->#2->#3\@end{%
\@ifundefined{\@mdprefix#1\@mdsuffix}
{\@@@mdef{#1}{#2}}
- {\edef\@mdef@redef{\the\@mdef@redeftok\@mdef@comma
- \@backslashchar\@mdprefix#1\@mdsuffix}
- \def\@mdef@comma{, }
- \@mdef@redeftok=\expandafter{\@mdef@redef}
+ {\ifKV@mdef@nowarn\else
+ \edef\@mdef@redef{\the\@mdef@redeftok\@mdef@comma
+ \@backslashchar\@mdprefix#1\@mdsuffix}
+ \def\@mdef@comma{, }
+ \global\@mdef@redeftok=\expandafter{\@mdef@redef}
+ \fi
\ifKV@mdef@noerr
\@@@mdef{#1}{#2}%
\ifKV@mdef@nowarn\else
@@ -294,28 +335,65 @@
%\end{macro}
%\end{macro}
%
-% Finally, \cs{@@@mdef} calls \cs{@mdef@def} with the appropriate
-% arguments. This is where the commands are really defined. The definition
-% uses \cs{@yargd@f}, following the definition of \cs{newcommand} in \LaTeX.
+% Finally, \cs{@@@mdef} calls \cs{@mdef@def} or \cs{@mdef@robdef} (if option
+% \ttt{robust} was passed) with the appropriate arguments. This is where the
+% commands are really defined. The definitions of \cs{@mdef@def} and
+% \cs{@mdef@robdef} use \cs{@yargd@f}, following the definition of
+% \cs{newcommand} and \cs{DeclareRobustCommand} in \LaTeX.
%\begin{macro}{\@@@mdef}
%\begin{macro}{\@mdef@def}
+%\begin{macro}{\@mdef@robdef}
% \begin{macrocode}
\def\@@@mdef#1#2{\def\@arg@{#2}%
\ifx\@arg@\@empty
- \@mdef@def{#1}{#1}%
+ \ifKV@mdef@robust
+ \expandafter\def\expandafter\@mdef@cmdname
+ \expandafter{\csname\@mdprefix#1\@mdsuffix\endcsname}%
+ \expandafter\@mdef@robdef\@mdef@cmdname{#1}%
+ \else
+ \@mdef@def{#1}{#1}%
+ \fi
\else
- \@mdef@def{#1}{#2}%
+ \ifKV@mdef@robust
+ \expandafter\def\expandafter\@mdef@cmdname
+ \expandafter{\csname\@mdprefix#1\@mdsuffix\endcsname}
+ \expandafter\@mdef@robdef\@mdef@cmdname{#2}%
+ \else
+ \@mdef@def{#1}{#2}%
+ \fi
\fi}
\def\@mdef@def#1#2{%
- \let\reserved@b\@gobble
- \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi
- \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi
- \def\l@ngrel@x{\@mdlong\@mdglobal}
+ \let\reserved@b\@gobble
+ \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi
+ \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi
+ \def\l@ngrel@x{\@mdlong\@mdglobal}
\expandafter\expandafter\expandafter\@yargd@f\expandafter\@mdargs\csname
\@mdprefix#1\@mdsuffix\expandafter\endcsname\expandafter{\@mdef@com{#2}}
}
+\def\@mdef@robdef#1#2{%
+ \edef\reserved@a{\string#1}%
+ \def\reserved@b{#1}%
+ \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
+ \global\edef#1{%
+ \ifx\reserved@a\reserved@b
+ \noexpand\x@protect
+ \noexpand#1%
+ \fi
+ \noexpand\protect
+ \expandafter\noexpand\csname
+ \expandafter\@gobble\string#1 \endcsname
+ }%
+ \let\reserved@b\@gobble
+ \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi
+ \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi
+ \def\l@ngrel@x{\@mdlong\@mdglobal}
+ \expandafter\expandafter\expandafter\@yargd@f\expandafter\@mdargs\csname
+ \expandafter\@gobble\string#1 \expandafter\endcsname
+ \expandafter{\@mdef@com{#2}}
+}
% \end{macrocode}
%\end{macro}
%\end{macro}
+%\end{macro}
% \Finale
\endinput
diff --git a/Master/texmf-dist/source/latex/multidef/multidef.ins b/Master/texmf-dist/source/latex/multidef/multidef.ins
index 6c63ae9f4f1..65c26ff701e 100644
--- a/Master/texmf-dist/source/latex/multidef/multidef.ins
+++ b/Master/texmf-dist/source/latex/multidef/multidef.ins
@@ -1,6 +1,6 @@
%\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\input docstrip
-\def\filedate{2016/03/14}
+\def\filedate{2016/04/20}
\let\MetaPrefix\DoubleperCent
\preamble