diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/keycommand')
-rw-r--r-- | Master/texmf-dist/tex/latex/keycommand/keycommand.sty | 305 |
1 files changed, 177 insertions, 128 deletions
diff --git a/Master/texmf-dist/tex/latex/keycommand/keycommand.sty b/Master/texmf-dist/tex/latex/keycommand/keycommand.sty index 9f79ac612aa..3bf7e801bd1 100644 --- a/Master/texmf-dist/tex/latex/keycommand/keycommand.sty +++ b/Master/texmf-dist/tex/latex/keycommand/keycommand.sty @@ -8,7 +8,7 @@ %% %% This is a generated file. %% -%% keycommand : key-value interface for commands and environments in LaTeX [v3.14 2010/04/18] +%% keycommand : key-value interface for commands and environments in LaTeX [v3.141 2010/04/25] %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either @@ -29,14 +29,8 @@ \ProvidesPackage{keycommand} [2010/04/18 v3.14 - key-value interface for commands and environments in LaTeX] \def\kcmd@pkg@name{keycommand} -\RequirePackage{etex,kvsetkeys,xkeyval,etoolbox,etextools} -\def\kcmd@Xsetkeys{\XKV@testopta{\XKV@testoptc\XKV@setkeys}}% in case \setkeys was overwritten -\@ifpackagelater{etextools}{2009/08/27}\relax - {\PackageError\kcmd@pkg@name{keycommand requires an implementation of\MessageBreak - package etextools later than 2009/08/27.\MessageBreak - Please update your distribution with a recent version of etextools}% - {The keycommand package will not be loaded.}% - \expandafter\endinput} +\RequirePackage{etex,kvsetkeys,xkeyval,etoolbox} +\protected\def\kcmd@Xsetkeys{\XKV@sttrue\XKV@plfalse\XKV@testoptc\XKV@setkeys}% in case \setkeys \let\kcmd@AtEnd\@empty \def\TMP@EnsureCode#1#2{% \edef\kcmd@AtEnd{% @@ -52,21 +46,41 @@ \TMP@EnsureCode{46}{12}% . dot \TMP@EnsureCode{47}{8}% / slash (etextools) \AtEndOfPackage{\kcmd@AtEnd\undef\kcmd@AtEnd} +\iffalse%\ifdefined\pdfmatch% use \pdfmatch if present + \long\def\kcmd@ifstrdigit#1{\csname @\ifnum\pdfmatch + {\detokenize{^[[:space:]]*[[:digit:]][[:space:]]*$}}{\detokenize{#1}}=1 % + first\else second\fi oftwo\endcsname} +\else% use filter, very efficient ! +\def\kcmd@ifstrdigit#1{% + \kcmd@nbk#1//% + {\expandafter\expandafter\expandafter\kcmd@ifstrdigit@i + \expandafter\expandafter\expandafter{\detokenize\expandafter{\number\number0#1}}}% + {\@secondoftwo}//% +} +\def\kcmd@ifstrdigit@i#1{% + \def\kcmd@ifstrdigit@ii##1#1##2##3\kcmd@ifstrdigit@ii{% + \csname @\ifx##20first\else second\fi oftwo\endcsname + }\kcmd@ifstrdigit@ii 00 01 02 03 04 05 06 07 08 09 0#1 \relax\kcmd@ifstrdigit@ii +} +\fi \def\kcmd@keyfam#1{\detokenize{keycmd->}\expandafter\@gobble\string#1} +\def\kcmd@nbk#1#2/#3#4#5//{#4}% \newrobustcmd\kcmd@normalize@setkeys[4]{% - \kv@normalize{#4}\expandafter\let\expandafter\kv@list\expandafter\@empty + \kv@normalize{#4}\toks@{}% \expandafter\kv@parse@normalized\expandafter{\kv@list}{\kcmd@normalize@braces{#2}}% - \expandafter\@swaparg\expandafter{\kv@list,}{\kcmd@Xsetkeys*{#2}}% - \ettl@nbk#3//% undeclared keys are assigned to "OtherKeys" - {\csedef{#2@#3}{\expandonce{\XKV@rm}}}% (if specified, ie not empty) - {\expandafter\ettl@nbk\XKV@rm//% (otherwise a recoverable error is thown) + \edef\kv@list{\kcmd@Xsetkeys{\unexpanded{#2}}{\the\toks@}}\kv@list + \kcmd@nbk#3//% undeclared keys are assigned to "OtherKeys" + {\cslet{#2@#3}\XKV@rm}% (if specified, ie not empty) + {\expandafter\kcmd@nbk\XKV@rm//% (otherwise a recoverable error is thown) {\PackageError\kcmd@pkg@name{The key-value pairs :\MessageBreak \XKV@rm\MessageBreak cannot be processed for key-command \string#1\MessageBreak - See the definition of the key-command!}{}}{}//}//} + See the definition of the key-command!}{}}{}//}//% +} \long\def\kcmd@normalize@braces#1#2#3{% This is kvsetkeys processor for normalizing braces - \edef\kv@list{\expandonce\kv@list,% - #2\if @\detokenize{#3}@\else ={{{\unexpanded{#3}}}}\fi}} + \toks@\expandafter{\the\toks@,#2}% + \ifx @\detokenize{#3}@\else \toks@\expandafter{\the\toks@={{{#3}}}}\fi +} \def\kcmd@check@typeofkey#1{% expands to \kcmd@check@typeofkey@bool#1bool //% {\kcmd@check@typeofkey@enumst#1enum* //% @@ -74,15 +88,15 @@ {\kcmd@check@typeofkey@choicest#1choice* //% {\kcmd@check@typeofkey@choice#1choice //% 05//}4//}3//}2//}1//} -\def\kcmd@check@typeofkey@bool #1bool #2//{\ettl@nbk#1//} +\def\kcmd@check@typeofkey@bool #1bool #2//{\kcmd@nbk#1//} \def\kcmd@get@keyname@bool #1bool #2//{#2} -\def\kcmd@check@typeofkey@enumst #1enum* #2//{\ettl@nbk#1//} +\def\kcmd@check@typeofkey@enumst #1enum* #2//{\kcmd@nbk#1//} \def\kcmd@get@keyname@enumst #1enum* #2//{#2} -\def\kcmd@check@typeofkey@enum #1enum #2//{\ettl@nbk#1//} +\def\kcmd@check@typeofkey@enum #1enum #2//{\kcmd@nbk#1//} \def\kcmd@get@keyname@enum #1enum #2//{#2} -\def\kcmd@check@typeofkey@choicest #1choice* #2//{\ettl@nbk#1//} +\def\kcmd@check@typeofkey@choicest #1choice* #2//{\kcmd@nbk#1//} \def\kcmd@get@keyname@choicest #1choice* #2//{#2} -\def\kcmd@check@typeofkey@choice #1choice #2//{\ettl@nbk#1//} +\def\kcmd@check@typeofkey@choice #1choice #2//{\kcmd@nbk#1//} \def\kcmd@get@keyname@choice #1choice #2//{#2} \protected\long\def\kcmd@definekey#1#2#3#4#5{% define the keys using xkeyval macros \ifcase\kcmd@check@typeofkey{#4}\relax% standard @@ -107,25 +121,29 @@ \ifx#2\global\relax #2\csletcs{KV@#3@#4}{KV@#3@#4}% globalize #2\csletcs{KV@#3@#4@default}{KV@#3@#4@default}% globalize default value - \fi} -\long\def\kcmd@firstchoiceof#1,#2\@nil{\unexpanded{#1}} -\long\def\kcmd@define@choicekey#1#2#3#4#5#6{\begingroup\edef\kcmd@define@choicekey{\endgroup + \fi +} +\long\def\kcmd@firstchoiceof#1,#2\kcmd@nil{\unexpanded{#1}} +\long\def\kcmd@define@choicekey#1#2#3#4#5#6{% + \begingroup\edef\kcmd@define@choicekey{\endgroup \noexpand\define@choicekey#2+{#3}{#4} [\noexpand\val\noexpand\nr]% {\unexpanded{#5}}% list of allowed values - [{\kcmd@firstchoiceof#5,\@nil}]% default value + [{\kcmd@firstchoiceof#5,\kcmd@nil}]% default value {\csedef{#3@#4}{\unexpanded{#6}}}% define key value if in the allowed list - {\kcmd@error@handler\noexpand#1{#3}{#4}{\kcmd@firstchoiceof#5,\@nil}}% error handler - }\kcmd@define@choicekey} + {\kcmd@error@handler\noexpand#1{#3}{#4}{\kcmd@firstchoiceof#5,\kcmd@nil}}% error handler + }\kcmd@define@choicekey +} \def\kcmd@define@boolkey#1#2#3#4{\begingroup - \ettl@nbk#4//{\def\default{#4}}{\def\default{true}}//% + \kcmd@nbk#4//{\def\default{#4}}{\def\default{true}}//% \edef\kcmd@define@boolkey{\endgroup \noexpand\define@choicekey*+{#2}{#3}[\noexpand\val\noexpand\nr]% {false,true} - [{\expandonce\default}]% + [{\unexpanded\expandafter{\default}}]% {\csedef{#2@#3}{\noexpand\number\noexpand\nr}}% - {\kcmd@error@handler\noexpand#1{#2}{#3}{\expandonce\default}}% - }\kcmd@define@boolkey} + {\kcmd@error@handler\noexpand#1{#2}{#3}{\unexpanded\expandafter{\default}}}% + }\kcmd@define@boolkey +} \protected\long\def\kcmd@error@handler#1#2#3#4{% \PackageError\kcmd@pkg@name{% Value `\val\space' is not allowed in key #3\MessageBreak @@ -133,75 +151,96 @@ I'll use the default value `#4' for this key.\MessageBreak See the definition of the key-command!}{% \csdef{#2@#3}{#4}}} -\def\kcmd@undefinekeys#1#2{% #1 = global, #2 = family +\protected\def\kcmd@undefinekeys#1#2{% #1 = global, #2 = family \ifcsundef{#2.keylist} - {} - {\expandnext{\csvloop[\kcmd@undefinekey{#1}{#2}]}{\csname #2.keylist\endcsname}}% - \cslet{#2.keylist}\noexpand\@gobble} + {\cslet{#2.keylist}\@gobble} + {\expandafter\expandafter\expandafter\docsvlist + \expandafter\expandafter\expandafter{% + \csname #2.keylist\endcsname}% + \cslet{#2.keylist}\@gobble}% +} \def\kcmd@undefinekey#1#2#3{% #1 = global, #2 = family, #3 = key #1\csundef{KV@#2@#3}% #1\csundef{KV@#2@#3@default}% } +\def\kcmd@setdefaults#1{% + \ifcsundef{#1.keylist}{} + {\expandafter\expandafter\expandafter\docsvlist + \expandafter\expandafter\expandafter{% + \csname #1.keylist\endcsname}}% +} \protected\long\def\kcmd@def#1#2[#3][#4][#5]#6#7{% - \@ifdefinable#1{\kcmd@defcommand#1[{#3}][{#4}][{#5}]{#6}{#2}{#7}}} + \ifx#1\kcmd@donot@provide\else + \@ifdefinable#1{\kcmd@defcommand#1[{#3}][{#4}][{#5}]{#6}{#2}{#7}}% + \fi +} \protected\long\def\kcmd@defcommand#1[#2][#3][#4]#5#6#7{% \edef\kcmd@fam{\kcmd@keyfam{#1}}\let\commandkey\relax\let\getcommandkey\relax + \let#1\relax \cslet\kcmd@fam\relax + \def\do{\kcmd@undefinekey{\kcmd@gbl}{\kcmd@fam}}% \edef\kcmd@defcommand{\endgroup \kcmd@undefinekeys{\kcmd@gbl}{\kcmd@fam}% undefines all keys for this keycommand family - \kcmd@mount@unexpandchar{\kcmd@fam}{\expandonce\kcmd@unexpandchar}% + \ifx\kcmd@unexpandchar\@empty\else + \kcmd@mount@unexpandchar{\kcmd@fam}{\unexpanded\expandafter{\kcmd@unexpandchar}}% + \fi \unexpanded{\kv@parse{#2,#3}}{\kcmd@definekey\noexpand#1{\kcmd@gbl}{\kcmd@fam}}% defines keys \csdef{\kcmd@fam.commandkey}####1{\noexpand\csname\kcmd@fam @####1\endcsname}% \csdef{\kcmd@fam.getcommandkey}####1{% \unexpanded{\unexpanded\expandafter\expandafter\expandafter}{% \noexpand\csname\kcmd@fam @####1\endcsname}}% - % \let\commandkey\noexpandcs{\kcmd@fam.\kcmd@plus get\fi commandkey}% - % \let\getcommandkey\noexpandcs{\kcmd@fam.getcommandkey}% - \kcmd@plus% \newkeycommand+ - \csdef{\kcmd@fam}{\kcmd@yargedef{\kcmd@gbl}{\kcmd@long}{\noexpandcs\kcmd@fam} - {\number#4}{#6}{\csname\kcmd@fam.unexpandchar\endcsname}}% - \unless\ifx#6\relax% that means we have to define a key-environment - \def#6{\kcmd@yargedef{\kcmd@gbl}{\kcmd@long}{#6}% - 0\relax{\csname\kcmd@fam.unexpandchar\endcsname}}% + \kcmd@ifplus% \newkeycommand+ / \newkeyenvironment+ + \csdef{\kcmd@fam}{% + \kcmd@yargedef{\kcmd@gbl}{\kcmd@long}\csname\kcmd@fam\endcsname + {\number#4}{\noexpand#6}{\csname\kcmd@fam.unexpandchar\endcsname}}% + \ifx#6\@gobble\else \def#6{% that means we have to define a key-environment + \kcmd@yargedef{\kcmd@gbl}{\kcmd@long}{#6}% + 0\relax{\csname\kcmd@fam.unexpandchar\endcsname}}% \fi - \else% \newkeycommand - \csdef{\kcmd@fam}{\kcmd@yargdef{\kcmd@gbl}{\kcmd@long}{\noexpandcs\kcmd@fam} - {\number#4}{#6}}% - \unless\ifx#6\relax% that means we have to define a key-environment - \def#6{\kcmd@yargdef{\kcmd@gbl}{\kcmd@long}{#6}0\relax}% + \else% \newkeycommand / \newkeyenvironment + \csdef{\kcmd@fam}{% + \kcmd@yargdef{\kcmd@gbl}{\kcmd@long}\csname\kcmd@fam\endcsname + {\number#4}{\noexpand#6}}% + \ifx#6\@gobble\else \def#6{% that means we have to define a key-environment + \kcmd@yargdef{\kcmd@gbl}{\kcmd@long}{#6}0\relax}% \fi \fi + \let\commandkey\relax\let\getcommandkey\relax\let#1\relax + \def\noexpand\do####1{\unexpanded{\expandafter\noexpand\csname}KV@\kcmd@fam @####1@default% + \endcsname}% \kcmd@gbl\protected\edef#1{% entry point - \let\noexpand\noexpand\commandkey\noexpand\noexpand\noexpandcs{% - \kcmd@fam.\kcmd@plus get\fi commandkey}% - \let\noexpand\noexpand\getcommandkey\noexpand\noexpand\noexpandcs{% - \kcmd@fam.getcommandkey}% - \noexpand\csvloop[\noexpand\kcmd@resetdefault{\kcmd@fam}]{\noexpandcs{\kcmd@fam.keylist}}% + \let\getcommandkey\unexpanded{\expandafter\noexpand\csname}\kcmd@fam.getcommandkey% + \endcsname + \kcmd@ifplus \let\commandkey\getcommandkey + \else \letcs\commandkey{\kcmd@fam.commandkey}% + \fi + \noexpand\kcmd@setdefaults{\kcmd@fam}% \noexpand\noexpand\noexpand\@testopt{% - \kcmd@setkeys\noexpand\noexpand#1{\kcmd@fam}{\kcmd@otherkeys{#3}}}{}}% - \noexpandcs\kcmd@fam% - }\kcmd@defcommand{#5}{#7}% + \kcmd@setkeys#1{\kcmd@fam}{\kcmd@otherkey{#3}}}{} + }% + \csname\kcmd@fam\endcsname% expand \kcmd@yargedef or \kcmd@yargdef + }\kcmd@defcommand{#5}{#7}% #5 = definition, #7 = definition end-envir } \protected\long\def\kcmd@setkeys#1#2#3[#4]{% \kcmd@normalize@setkeys{#1}{#2}{#3}{#4}\csname#2\endcsname} -\def\kcmd@resetdefault#1#2{\noexpandcs{KV@#1@#2@default}} -\long\def\kcmd@otherkeys#1{\ettl@nbk#1//{\kcmd@@therkeys#1=\@nil}{}//} -\long\def\kcmd@@therkeys#1=#2\@nil{#1} -\protected\def\kcmd@mount@unexpandchar#1#2{% - \ettl@nbk#2//{% - \protected\csdef{#1.unexpandchar}{\begingroup - \catcode`\~\active \lccode`\~`#2 \lccode`#2 0\relax - \lowercase{\def~{\catcode`#2\active - \long\def~########1~{\unexpanded{########1}}}% - \ettl@aftergroup@def~\endgroup~}}}% - {\cslet{#1.unexpandchar}\@empty}//% +\long\def\kcmd@otherkey#1{\kcmd@nbk#1//{\kcmd@otherkey@name#1=\kcmd@nil}{}//} +\long\def\kcmd@otherkey@name#1=#2\kcmd@nil{#1} +\protected \def \kcmd@mount@unexpandchar#1#2{% + \protected\csdef{#1.unexpandchar}{\begingroup + \catcode`\~\active \lccode`\~`#2 \lccode`#2 0\relax + \lowercase{% + \expandafter\endgroup\expandafter\def\expandafter~{% + \catcode`#2\active + \long\def~########1~{\unexpanded{########1}}}% + ~}% + }% } \protected \def \kcmd@yargdef #1#2#3#4#5{\begingroup \def \kcmd@yargd@f ##1#4##2##{\afterassignment#5\endgroup #1#2\expandafter\def\expandafter#3\@gobble ##1#4% }\kcmd@yargd@f 0##1##2##3##4##5##6##7##8##9###4% } -\protected\def\kcmd@yargedef#1#2#3#4#5#6{\begingroup - \letcs\kcmd@nargs{kcmd@#4of9}% +\protected \def \kcmd@yargedef#1#2#3#4#5#6{\begingroup + \expandafter\let\expandafter\kcmd@nargs\csname kcmd@#4of9\endcsname \long\def\kcmd@yarg@edef##1##2{\afterassignment#5\endgroup #1\edef#3{\begingroup #6% #2\edef\unexpanded{#3##2}{\endgroup\unexpanded{##1}% @@ -216,84 +255,94 @@ \expandafter\def\expandafter#3\@gobble ##1#4% }\kcmd@yarged@f 0##1##2##3##4##5##6##7##8##9###4% } -\def\kcmd@XofNINE#1{% +\def\do#1{% \def\kcmd@XofNine##1#1##2##{% \expandafter\csedef{kcmd@#1of9}####1####2####3####4####5####6####7####8####9{% \@gobble ##1#1}% }\kcmd@XofNine 0##1##2##3##4##5##6##7##8##9###1{}% } -\csvloop*[\kcmd@XofNINE]{1,2,3,4,5,6,7,8,9,0} -\undef\kcmd@XofNine\undef\kcmd@XofNINE -\protected\def\newkeycommand{\begingroup - \let\kcmd@gbl\@empty\kcmd@modifiers\new@keycommand} -\protected\def\renewkeycommand{\begingroup - \let\kcmd@gbl\@empty\kcmd@modifiers\renew@keycommand} -\protected\def\providekeycommand{\begingroup - \let\kcmd@gbl\@empty\kcmd@modifiers\provide@keycommand} -\protected\def\kcmd@modifiers#1{% - \futuredef[*+]\kcmd@modifiers{% only once inside group - \edef\kcmd@long{\expandafter\kcmd@ifstar\kcmd@modifiers*\relax}% - \edef\kcmd@plus{\expandafter\kcmd@ifplus\kcmd@modifiers+\relax}% - \@testopt{\kcmd@unexpandchar#1}{}}} -\def\kcmd@ifstar#1*#2\relax{\ettl@nbk#2//{}\long//} -\def\kcmd@ifplus#1+#2\relax{\ettl@nbk#2//{\noexpand\iftrue}{\noexpand\iffalse}//} -\def\kcmd@unexpandchar#1[#2]{\def\kcmd@unexpandchar{#2}% only once inside group... - \kcmd@plus \ettl@nbk#2// - {\def\kcmd@unexpandchar@activate{\catcode`#2 \active}}% - {\let\kcmd@unexpandchar@activate\relax}//% - \else\ettl@nbk#2//% - {\PackageError\kcmd@pkg@name{shortcut option for \string\unexpanded\MessageBreak - You can't use a shortcut option for \string\unexpanded\MessageBreak - without the \string+ form of \string\newkeycommand!}% - {I will ignore this option and proceed.}% - \let\kcmd@unexpandchar\@empty}% - {}//% +\docsvlist{1,2,3,4,5,6,7,8,9,0} +\undef\kcmd@XofNine +\newrobustcmd*\newkeycommand{\begingroup + \let\kcmd@gbl\@empty\kcmd@star@or@long\new@keycommand} +\newrobustcmd*\renewkeycommand{\begingroup + \let\kcmd@gbl\@empty\kcmd@star@or@long\renew@keycommand} +\newrobustcmd*\providekeycommand{\begingroup + \let\kcmd@gbl\@empty\kcmd@star@or@long\provide@keycommand} +\def\kcmd@star@or@long#1{\@ifstar + {\let\kcmd@long\@empty\kcmd@plus#1} + {\def\kcmd@long{\long}\kcmd@plus#1}} +\def\kcmd@@ifplus#1{\@ifnextchar +{\@firstoftwo{#1}}}% same as LaTeX's \@ifstar +\def\kcmd@plus#1{\kcmd@@ifplus + {\def\kcmd@ifplus{\iftrue}\kcmd@testopt#1} + {\def\kcmd@ifplus{\iffalse}\kcmd@testopt#1}} +\def\kcmd@testopt#1{\@testopt{\kcmd@unexpandchar#1}{}} +\def\kcmd@unexpandchar#1[#2]{% + \kcmd@ifplus + \kcmd@nbk#2// + {\def\kcmd@unexpandchar{#2}% only once inside group... + \def\kcmd@unexpandchar@activate{\catcode`#2 \active}% + }{% + \let\kcmd@unexpandchar\@empty + \let\kcmd@unexpandchar@activate\relax + }//% + \else \let\kcmd@unexpandchar\@empty + \kcmd@nbk#2//% + {\PackageError\kcmd@pkg@name{shortcut option for \string\unexpanded\MessageBreak + You can't use a shortcut option for \string\unexpanded\MessageBreak + without the \string+ form of \string\newkeycommand!}% + {I will ignore this option and proceed.}% + }% + {}//% \fi#1} -\protected\def\new@keycommand#1{\@testopt{\@newkeycommand#1}{}} -\protected\def\@newkeycommand#1[#2]{% #2 = key=values or N=mandatory args - \kcmd@plus \kcmd@unexpandchar@activate \fi% activates unexpand-char before reading definition - \ifstrnum{#2}% +\def\new@keycommand#1{\@testopt{\@newkeycommand#1}0} +\long\def\@newkeycommand#1[#2]{% #2 = key=values or N=mandatory args + \kcmd@ifplus \kcmd@unexpandchar@activate \fi% activates unexpand-char before reading definition + \kcmd@ifstrdigit{#2}% {\@new@key@command#1[][][{#2}]}% no kv, no optkey, number of args {\@testopt{\@new@keycommand#1[{#2}]}0}}% kv, check for optkey/nr of args -\protected\def\@new@keycommand#1[#2][#3]{% - \ifstrnum{#3}% +\long\def\@new@keycommand#1[#2][#3]{% + \kcmd@ifstrdigit{#3}% {\@new@key@command#1[{#2}][][{#3}]}% no optkey {\@testopt{\@new@key@command#1[{#2}][{#3}]}0}} -\protected\long\def\@new@key@command#1[#2][#3][#4]#5{% - \kcmd@def#1\relax[{#2}][{#3}][{#4}]{#5}{}} -\protected\def\renew@keycommand#1{\begingroup +\long\def\@new@key@command#1[#2][#3][#4]#5{% + \kcmd@def#1\@gobble[{#2}][{#3}][{#4}]{#5}{}} +\def\renew@keycommand#1{\begingroup \escapechar\m@ne\edef\@gtempa{{\string#1}}% \expandafter\@ifundefined\@gtempa {\endgroup\@latex@error{\noexpand#1undefined}\@ehc} \endgroup \let\@ifdefinable\@rc@ifdefinable - \new@keycommand#1} -\protected\def\provide@keycommand#1{% + \new@keycommand#1% +} +\def\provide@keycommand#1{\begingroup \escapechar\m@ne\edef\@gtempa{{\string#1}}% \expandafter\@ifundefined\@gtempa - {\new@keycommand#1} - {\@testopt{\provide@key@command\kcmd@notdefinable}{}}} -\protected\def\provide@key@command#1[#2]{\@tempswafalse\kcmd@def#1{#2}} -\protected\def\newkeyenvironment{\begingroup - \let\kcmd@gbl\@empty\kcmd@modifiers\new@keyenvironment} -\protected\def\renewkeyenvironment{\begingroup - \let\kcmd@gbl\@empty\kcmd@modifiers\renew@keyenvironment} + {\endgroup\new@keycommand#1} + {\endgroup\def\kcmd@donot@provide{\renew@keycommand\kcmd@donot@provide + }\kcmd@donot@provide}% +} +\let\kcmd@donot@provide\@empty% it must not be undefined +\newrobustcmd*\newkeyenvironment{\begingroup + \let\kcmd@gbl\@empty\kcmd@star@or@long\new@keyenvironment} +\newrobustcmd\renewkeyenvironment{\begingroup + \let\kcmd@gbl\@empty\kcmd@star@or@long\renew@keyenvironment} \def\new@keyenvironment#1{\@testopt{\@newkeyenva{#1}}{}} -\def\@newkeyenva#1[#2]{% - \ifstrnum{#2}% +\long\def\@newkeyenva#1[#2]{% + \kcmd@ifstrdigit{#2}% {\@newkeyenv{#1}{[][][{#2}]}} {\@testopt{\@newkeyenvb{#1}[{#2}]}{}}} -\def\@newkeyenvb#1[#2][#3]{% - \ifstrnum{#3}% +\long\def\@newkeyenvb#1[#2][#3]{% + \kcmd@ifstrdigit{#3}% {\@newkeyenv{#1}{[{#2}][][{#3}]}} {\@testopt{\@newkeyenvc{#1}{[{#2}][{#3}]}}0}} -\def\@newkeyenvc#1#2[#3]{\@newkeyenv{#1}{#2[{#3}]}} +\long\def\@newkeyenvc#1#2[#3]{\@newkeyenv{#1}{#2[{#3}]}} \long\def\@newkeyenv#1#2{% - \kcmd@plus \kcmd@unexpandchar@activate \fi + \kcmd@ifplus \kcmd@unexpandchar@activate \fi \kcmd@keyenvir@def{#1}{#2}% } \long\def\kcmd@keyenvir@def#1#2#3#4{% - \cslet{end#1}\protected + \expandafter\let\csname end#1\endcsname\relax \expandafter\kcmd@def\csname #1\expandafter\endcsname\csname end#1\endcsname#2{#3}{#4}% } \def\renew@keyenvironment#1{% @@ -305,11 +354,11 @@ \newcommand*\ifcommandkey[1]{\csname @\expandafter\expandafter\expandafter - \ettl@nbk\commandkey{#1}//{first}{second}//% + \kcmd@nbk\commandkey{#1}//{first}{second}//% oftwo\endcsname} -\newcommand\showcommandkeys[1]{\let\do\showcommandkey\docsvlist{#1}} -\newcommand\showcommandkey[1]{key \string"#1\string" = % - \expandnext\expandnext\expandnext\detokenize{\commandkey{#1}}\par} +\newrobustcmd*\showcommandkeys[1]{\let\do\showcommandkey\docsvlist{#1}} +\newrobustcmd*\showcommandkey[1]{key \string"#1\string" = % + \detokenize\expandafter\expandafter\expandafter{\commandkey{#1}}\par} \endinput %% %% End of file `keycommand.sty'. |