diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx | 265 |
1 files changed, 176 insertions, 89 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx b/Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx index 794a76990ec..235a400ff57 100644 --- a/Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/letltxmacro.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2008 by +% Copyright (C) 2008, 2010 by % Heiko Oberdiek <heiko.oberdiek at googlemail.com> % % This work may be distributed and/or modified under the @@ -76,7 +76,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: letltxmacro 2008/06/24 v1.3 Let assignment for LaTeX macros (HO)} +\Msg{* Package: letltxmacro 2010/09/02 v1.4 Let assignment for LaTeX macros (HO)} \Msg{************************************************************************} \keepsilent @@ -87,7 +87,7 @@ This is a generated file. -Copyright (C) 2008 by +Copyright (C) 2008, 2010 by Heiko Oberdiek <heiko.oberdiek at googlemail.com> This work may be distributed and/or modified under the @@ -153,7 +153,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{letltxmacro.drv}% - [2008/06/24 v1.3 Let assignment for LaTeX macros (HO)]% + [2010/09/02 v1.4 Let assignment for LaTeX macros (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc}[2008/08/11] \begin{document} @@ -162,7 +162,7 @@ and the derived files %</driver> % \fi % -% \CheckSum{844} +% \CheckSum{987} % % \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 @@ -183,7 +183,7 @@ and the derived files % \GetFileInfo{letltxmacro.drv} % % \title{The \xpackage{letltxmacro} package} -% \date{2008/06/24 v1.3} +% \date{2010/09/02 v1.4} % \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}} % % \maketitle @@ -235,6 +235,11 @@ and the derived files % that are derived from \cs{SavedMacro}'s macro name. Macro \cs{Macro} % can now be redefined without affecting \cs{SavedMacro}. % +% \begin{declcs}{GlobalLetLtxMacro} \M{new macro} \M{old macro} +% \end{declcs} +% Like \cs{LetLtxMacro}, but the \meta{new macro} is defined globally. +% Since version 2010/09/02~v1.4. +% % \subsection{Supported macro definition commands} % % \begin{quote} @@ -407,28 +412,37 @@ and the derived files % \subsubsection{Catcodes and identification} % % \begin{macrocode} -\begingroup - \catcode123 1 % { - \catcode125 2 % } +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ \def\x{\endgroup \expandafter\edef\csname llm@AtEnd\endcsname{% - \catcode35 \the\catcode35\relax - \catcode64 \the\catcode64\relax - \catcode123 \the\catcode123\relax - \catcode125 \the\catcode125\relax + \endlinechar=\the\endlinechar\relax + \catcode13=\the\catcode13\relax + \catcode32=\the\catcode32\relax + \catcode35=\the\catcode35\relax + \catcode61=\the\catcode61\relax + \catcode64=\the\catcode64\relax + \catcode123=\the\catcode123\relax + \catcode125=\the\catcode125\relax }% }% -\x -\catcode35 6 % # -\catcode64 11 % @ -\catcode123 1 % { -\catcode125 2 % } +\x\catcode61\catcode48\catcode32=10\relax% +\catcode13=5 % ^^M +\endlinechar=13 % +\catcode35=6 % # +\catcode64=11 % @ +\catcode123=1 % { +\catcode125=2 % } \def\TMP@EnsureCode#1#2{% \edef\llm@AtEnd{% \llm@AtEnd - \catcode#1 \the\catcode#1\relax + \catcode#1=\the\catcode#1\relax }% - \catcode#1 #2\relax + \catcode#1=#2\relax } \TMP@EnsureCode{40}{12}% ( \TMP@EnsureCode{41}{12}% ) @@ -437,11 +451,13 @@ and the derived files \TMP@EnsureCode{46}{12}% . \TMP@EnsureCode{47}{12}% / \TMP@EnsureCode{58}{12}% : -\TMP@EnsureCode{61}{12}% = \TMP@EnsureCode{62}{12}% > +\TMP@EnsureCode{91}{12}% [ +\TMP@EnsureCode{93}{12}% ] \edef\llm@AtEnd{% \llm@AtEnd \escapechar\the\escapechar\relax + \noexpand\endinput } \escapechar=92 % `\\ % \end{macrocode} @@ -450,40 +466,59 @@ and the derived files % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{letltxmacro}% - [2008/06/24 v1.3 Let assignment for LaTeX macros (HO)] + [2010/09/02 v1.4 Let assignment for LaTeX macros (HO)] % \end{macrocode} % % \subsubsection{Main macros} % % \begin{macro}{\LetLtxMacro} % \begin{macrocode} -\newcommand*{\LetLtxMacro}[2]{% +\newcommand*{\LetLtxMacro}{% + \llm@ModeLetLtxMacro{}% +} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\GlobalLetLtxMacro} +% \begin{macrocode} +\newcommand*{\GlobalLetLtxMacro}{% + \llm@ModeLetLtxMacro\global +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\llm@ModeLetLtxMacro} +% \begin{macrocode} +\newcommand*{\llm@ModeLetLtxMacro}[3]{% + \edef\llm@escapechar{\the\escapechar}% + \escapechar=-1 % \edef\reserved@a{% \noexpand\protect \expandafter\noexpand - \csname\expandafter\@gobble\string#2 \endcsname + \csname\string#3 \endcsname }% - \ifx\reserved@a#2\relax - \edef#1{% + \ifx\reserved@a#3\relax + #1\edef#2{% \noexpand\protect \expandafter\noexpand - \csname\expandafter\@gobble\string#1 \endcsname + \csname\string#2 \endcsname }% - \expandafter\let - \csname\expandafter\@gobble\string#1 \expandafter\endcsname - \csname\expandafter\@gobble\string#2 \endcsname + #1\expandafter\let + \csname\string#2 \expandafter\endcsname + \csname\string#3 \endcsname \expandafter\llm@LetLtxMacro - \csname\expandafter\@gobble\string#1 \expandafter\endcsname - \csname\expandafter\@gobble\string#2 \endcsname + \csname\string#2 \expandafter\endcsname + \csname\string#3 \endcsname{#1}% \else - \llm@LetLtxMacro{#1}{#2}% + \llm@LetLtxMacro{#2}{#3}{#1}% \fi + \escapechar=\llm@escapechar\relax } % \end{macrocode} % \end{macro} % \begin{macro}{\llm@LetLtxMacro} % \begin{macrocode} -\def\llm@LetLtxMacro#1#2{% +\def\llm@LetLtxMacro#1#2#3{% + \escapechar=92 % \expandafter\llm@CheckParams\meaning#2:->\@nil{% \begingroup \def\@protected@testopt{% @@ -512,7 +547,8 @@ and the derived files \else \edef\x{% \noexpand\@testopt - \expandafter\noexpand\csname\string#2\endcsname + \expandafter\noexpand + \csname\string#2\endcsname }% \expandafter\expandafter\expandafter\def \expandafter\expandafter\expandafter\y @@ -530,19 +566,21 @@ and the derived files \else \llm@protected\xdef\llm@GlobalTemp{% \llm@testopt - \expandafter\noexpand\csname\string#1\endcsname + \expandafter\noexpand + \csname\string#1\endcsname {\the\toks@}% }% \fi \expandafter\endgroup\ifx\llm@testopt\@empty - \let#1=#2\relax + #3\let#1=#2\relax \else - \let#1=\llm@GlobalTemp - \expandafter\let\csname\string#1\expandafter\endcsname - \csname\string#2\endcsname + #3\let#1=\llm@GlobalTemp + #3\expandafter\let + \csname\string#1\expandafter\endcsname + \csname\string#2\endcsname \fi }{% - \let#1=#2\relax + #3\let#1=#2\relax }% } % \end{macrocode} @@ -593,7 +631,7 @@ and the derived files % \end{macro} % % \begin{macrocode} -\llm@AtEnd +\llm@AtEnd% %</package> % \end{macrocode} % @@ -642,7 +680,7 @@ and the derived files \catcode`\%=14 % \catcode`\ =10 % \catcode13=5 % - \RequirePackage{letltxmacro}[2008/06/24]\relax + \RequirePackage{letltxmacro}[2010/09/02]\relax \RestoreCatcodes } \Test @@ -663,7 +701,7 @@ and the derived files \nofiles \documentclass{minimal} -\usepackage{letltxmacro}[2008/06/24] +\usepackage{letltxmacro}[2010/09/02] \usepackage{qstest} \IncludeTests{*} @@ -712,37 +750,59 @@ and the derived files } \begin{qstest}{robust}{robust} - \DeclareRobustCommand*{\TestA}{Test}% - \SaveA - \TestDef{TestA}{\protect \TestA }% - \CheckA + \begingroup + \DeclareRobustCommand*{\TestA}{Test}% + \SaveA + \TestDef{TestA}{\protect \TestA }% + \CheckA + \DeclareRobustCommand{\TestA}{Test}% + \SaveA + \TestDef{TestA}{\protect \TestA }% + \LetLtxMacro\TestB\TestA + \TestDef{TestB}{\protect \TestB }% + \TestEquals{TestB }{TestA }% + \CheckA + \GlobalLetLtxMacro\TestC\TestA + \CheckA + \endgroup + \TestDef{TestC}{\protect \TestC }% \DeclareRobustCommand{\TestA}{Test}% - \SaveA - \TestDef{TestA}{\protect \TestA }% - \LetLtxMacro\TestB\TestA - \TestDef{TestB}{\protect \TestB }% - \TestEquals{TestB }{TestA }% - \CheckA + \TestEquals{TestC }{TestA }% \end{qstest} \begin{qstest}{default}{default} - \newcommand{\TestA}[1][\relax default \empty]{TestA #1}% - \SaveA - \TestDef - {TestA}{\@protected@testopt \TestA \\TestA {\relax default \empty }}% - \LetLtxMacro\TestB\TestA + \begingroup + \newcommand{\TestA}[1][\relax default \empty]{TestA #1}% + \SaveA + \TestDef + {TestA}{\@protected@testopt \TestA \\TestA {\relax default \empty }}% + \LetLtxMacro\TestB\TestA + \TestDef + {TestB}{\@protected@testopt \TestB \\TestB {\relax default \empty }}% + \CheckA + \TestEquals{\string\TestB}{\string\TestA}% + \GlobalLetLtxMacro\TestC\TestA + \CheckA + \endgroup \TestDef - {TestB}{\@protected@testopt \TestB \\TestB {\relax default \empty }}% - \CheckA + {TestC}{\@protected@testopt \TestC \\TestC {\relax default \empty }}% + \newcommand{\TestA}[1][\relax default \empty]{TestA #1}% + \TestEquals{\string\TestC}{\string\TestA}% \end{qstest} \begin{qstest}{robustdefault}{robustdefault} - \DeclareRobustCommand{\TestA}[1][\default]{TestA}% - \SaveA - \LetLtxMacro\TestB\TestA - \TestDef{TestB}{\protect \TestB }% - \TestDef{TestB }{\@protected@testopt \TestB \\TestB {\default }}% - \CheckA + \begingroup + \DeclareRobustCommand{\TestA}[1][\default]{TestA}% + \SaveA + \LetLtxMacro\TestB\TestA + \TestDef{TestB}{\protect \TestB }% + \TestDef{TestB }{\@protected@testopt \TestB \\TestB {\default }}% + \CheckA + \GlobalLetLtxMacro\TestC\TestA + \CheckA + \endgroup + \TestDef{TestC}{\protect \TestC }% + \TestDef{TestC }{\@protected@testopt \TestC \\TestC {\default }}% \end{qstest} \begin{qstest}{plain}{plain} @@ -766,39 +826,62 @@ and the derived files \usepackage{etoolbox}[2008/06/22] \begin{qstest}{oldnewrobustcmd}{oldnewrobustcmd} - \protected\edef\TestA{% - \noexpand\@protected@testopt - \noexpand\TestA - \expandafter\noexpand\csname\string\TestA\endcsname - {\noexpand\default}% - }% - \expandafter\protected\expandafter - \def\csname\string\TestA\endcsname{TestA}% - \SaveA - \LetLtxMacro\TestB\TestA - \TestDef{TestB}{\@protected@testopt \TestB \\TestB {\default }}% + \begingroup + \protected\edef\TestA{% + \noexpand\@protected@testopt + \noexpand\TestA + \expandafter\noexpand\csname\string\TestA\endcsname + {\noexpand\default}% + }% + \expandafter\protected\expandafter + \def\csname\string\TestA\endcsname{TestA}% + \SaveA + \LetLtxMacro\TestB\TestA + \TestDef{TestB}{\@protected@testopt \TestB \\TestB {\default }}% + \protected\edef\TestC{% + \noexpand\@protected@testopt + \noexpand\TestB + \expandafter\noexpand\csname\string\TestB\endcsname + {\noexpand\default}% + }% + \TestEquals{TestB}{TestC}% + \CheckA + \GlobalLetLtxMacro\TestD\TestA + \CheckA + \endgroup + \TestDef{TestD}{\@protected@testopt \TestD \\TestD {\default }}% \protected\edef\TestC{% \noexpand\@protected@testopt - \noexpand\TestB - \expandafter\noexpand\csname\string\TestB\endcsname + \noexpand\TestD + \expandafter\noexpand\csname\string\TestD\endcsname {\noexpand\default}% }% - \TestEquals{TestB}{TestC}% - \CheckA + \TestEquals{TestD}{TestC}% \end{qstest} \begin{qstest}{newrobustcmd}{newrobustcmd} - \newrobustcmd{\TestA}[1][\default]{TestA}% - \SaveA - \LetLtxMacro\TestB\TestA - \TestDef{TestB}{\@testopt \\TestB {\default }}% + \begingroup + \newrobustcmd{\TestA}[1][\default]{TestA}% + \SaveA + \LetLtxMacro\TestB\TestA + \TestDef{TestB}{\@testopt \\TestB {\default }}% + \protected\edef\TestC{% + \noexpand\@testopt + \expandafter\noexpand\csname\string\TestB\endcsname + {\noexpand\default}% + }% + \TestEquals{TestB}{TestC}% + \CheckA + \GlobalLetLtxMacro\TestD\TestA + \CheckA + \endgroup + \TestDef{TestD}{\@testopt \\TestD {\default }}% \protected\edef\TestC{% \noexpand\@testopt - \expandafter\noexpand\csname\string\TestB\endcsname + \expandafter\noexpand\csname\string\TestD\endcsname {\noexpand\default}% }% - \TestEquals{TestB}{TestC}% - \CheckA + \TestEquals{TestD}{TestC}% \end{qstest} \begin{qstest}{robustifyopt}{robustifyopt} @@ -1061,6 +1144,10 @@ and the derived files % \item % Test file adapted for etoolbox 2008/06/22 v1.6. % \end{Version} +% \begin{Version}{2010/09/02 v1.4} +% \item +% \cs{GlobalLetLtxMacro} added. +% \end{Version} % \end{History} % % \PrintIndex |