diff options
author | Karl Berry <karl@freefriends.org> | 2011-11-25 00:11:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-11-25 00:11:53 +0000 |
commit | 0ad65f7beaddd4e930a52720af50fa3aa6ba5958 (patch) | |
tree | c31df2e1d6f4b7f87f59802b1932c08931b3e797 /Master/texmf-dist/tex | |
parent | 5949618821cfe384176ae1a4a7a032a3f6e7ee30 (diff) |
skeycommand 0.4 (20nov11)
git-svn-id: svn://tug.org/texlive/trunk@24652 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/skeycommand/skeycommand.sty | 903 |
1 files changed, 475 insertions, 428 deletions
diff --git a/Master/texmf-dist/tex/latex/skeycommand/skeycommand.sty b/Master/texmf-dist/tex/latex/skeycommand/skeycommand.sty index bcbd07963e1..869b9f8152e 100644 --- a/Master/texmf-dist/tex/latex/skeycommand/skeycommand.sty +++ b/Master/texmf-dist/tex/latex/skeycommand/skeycommand.sty @@ -1,6 +1,6 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % % -% This is file 'skeycommand.sty', version 0.3. % +% This is file 'skeycommand.sty', version 0.4. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -16,477 +16,524 @@ % implied warranties of merchantability and fitness for a particular % % purpose. % % % -% Copyright (c) 2010 Ahmed Musa (a.musa@rocketmail.com). % +% Copyright (c) 2011 Ahmed Musa (a.musa@rocketmail.com). % % % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -\begingroup -\catcode064 11% @ -\catcode123 01% { -\catcode125 02% } -\def\SKC@tempa{\endgroup - \edef\SKC@restorecodes{% - \catcode035 \the\catcode035% # - \catcode064 \the\catcode064% @ - \catcode123 \the\catcode123% { - \catcode125 \the\catcode125% } - \catcode061 \the\catcode061% = - }% -} -\SKC@tempa -\catcode035 06% # -\catcode061 12% = -\catcode064 11% @ -\catcode123 01% { -\catcode125 02% } -\def\SKC@catcode#1#2{% - \edef\SKC@restorecodes{% - \SKC@restorecodes - \catcode#1 \the\catcode#1\relax - }% - \catcode#1 #2\relax -} -\AtEndOfPackage{% - \SKV@AfterPackageEnd{% - \SKC@restorecodes - \SKV@Undef!{\SKC@catcode\SKC@restorecodes}% +\@ifpackageloaded{catoptions}{% + \@ifpackagelater{catoptions}{2011/10/22}{}{% + \@latex@error{Loaded version of catoptions package is + not current}\@ehc }% +}{% + \RequirePackage{catoptions}[2011/10/22]% } -\SKC@catcode{032}{10}% SP -\SKC@catcode{033}{12}% ! -\SKC@catcode{036}{03}% $ -\SKC@catcode{038}{03}% & -\SKC@catcode{040}{12}% ( -\SKC@catcode{041}{12}% ) -\SKC@catcode{042}{12}% * -\SKC@catcode{043}{12}% + -\SKC@catcode{044}{12}% , -\SKC@catcode{045}{12}% - -\SKC@catcode{047}{12}% / -\SKC@catcode{058}{12}% : -\SKC@catcode{059}{12}% ; -\SKC@catcode{063}{12}% ? -\SKC@catcode{091}{12}% [ -\SKC@catcode{093}{12}% ] -\SKC@catcode{126}{13}% ~ -\def\SKC@rcsid$#1: #2 #3 #4 #5${#4 v#3} -\ProvidesPackage{skeycommand}[% - \SKC@rcsid - $Id: skeycommand.sty,v 0.3 2010/05/21 09:00:00 Ahmed Musa $ - Defining new commands and environments using keys (AM) -] +\UseNormalCatcodes +\StyleFilePurpose{Create commands and environments with keys (AM)} +\StyleFileRCSInfo +$Id: skeycommand.sty,v 0.4 2011/10/20 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{skeycommand}[\StyleFileInfo] \NeedsTeXFormat{LaTeX2e}[1996/12/01] -\ifcase0% - \ifx\eTeXversion\SKC@undefined1\else\ifnum\eTeXversion<\tw@1\fi\fi -\else - \PackageError{skeycommand}% - {eTeX not loaded or old version}% - {This package requires eTeX version 2 or later.}% - \endinput -\fi -\@ifpackageloaded{skeyval}{% - \@ifpackagecurrent{skeyval}{2010/05/01}{}{% - \PackageError{skeycommand}% - {Your loaded version of skeyval package is not current}% - {You need version 0.7 (or higher) of skeyval package.}% - \endinput - }% +\SetStyleFileMessages[skc@]{info}{warn}{err} +\loadifnotloaded{ltxkeys}[2011/10/22] +\newvariables{if}[skc@]{inkey}[false] +\ltxkeys@biboolkeys[SKC]{skeycommand}[skc@]{verbose,silent}[true]{% + \ifskc@verbose\cpt@verbosetrue\fi }{% - \RequirePackage[keyparser=;,keyprefix=KV,keyfamily=skeycommand, - macroprefix=skc@]{skeyval}[2010/05/01] -} -\TestProvidedCommand\newdef{}{\let\newdef\SKV@newdef} -\TestProvidedCommand\robustdef{}{\let\robustdef\SKV@pdef} -\TestProvidedCommand\redef{}{\let\redef\SKV@redef} -\UseSkeyvalSetkeys -\ReserveMacroPrefixNames*{SKC@} -\ReserveFamilyNames*{skeycommand} -\robustdef*\SKC@info#1{\PackageInfo{skeycommand}{#1\@gobble}} -\robustdef*\SKC@warn#1{\PackageWarningNoLine{skeycommand}{#1}} -\robustdef*\SKC@err#1#2{\PackageError{skeycommand}{#1}{#2}} -\NewBooleans[SKC@sw]{a}[false] -\newbiboolkeys[KV]{skeycommand}[SKC@]{verbose}[true]{silent}{% - \setkeys[KV]{skeyval}{verbose=true}}% - {\setkeys[KV]{skeyval}{verbose=false}} -\DeclareOptionX*{\SKC@warn{Unknown option '\CurrentOption' ignored}} -\ExecuteOptionsX[KV]<skeycommand>{verbose=false} -\ProcessOptionsX*[KV]<skeycommand>\relax -\robustdef*\skeycommand#1{\setkeys[KV]{skeycommand}{#1}} -\newdef*\SKC@fdigit#1{% - \let\SKC@resvda\@empty - \SKV@tfor{#1}\SKC@resvdb{% - \SKV@addtolist[,]\SKC@resvda\SKC@resvdb + \ifskc@silent\cpt@verbosefalse\fi +} +\ltxkeys@declareoption*{\skc@warn{Unknown option '\CurrentOption' ignored}} +\ltxkeys@executeoptions[SKC]<skeycommand>{verbose=false} +\ltxkeys@processoptions*[SKC]<skeycommand>\relax +\robust@def*\skeycommand#1{% + \ifblankTF{#1}{\ltxkeys@setkeys[SKC]{skeycommand}{#1}}% +} +\robust@def*\skc@testltopt#1#2{\ifnextcharTF<{#1}{#1<{#2}>}} +\robust@def*\skc@testpnopt#1#2{\ifnextcharTF({#1}{#1({#2})}} +\robust@def*\skc@scantoksa#1{% + \begingroup + \def\siso@do##1{\catcode`##1\string=12\relax}% + \siso@@loop{=,;|-+?><}% + \cptscantokens#1% + \postgroupdef#1\endgroup +} +\robust@def*\skc@scantoksb{\cpt@testcl\skc@sc@ntoksb} +\robust@def\skc@sc@ntoksb#1{% + \def\csv@do##1{% + \cptscantokens{##1}% + \ifcpt@cl\global\fi\let##1=##1% }% - \SKC@swatrue - \XKV@whilist\SKC@resvda\SKC@resvdb\ifSKC@swa\fi{% - \SKV@in@o\SKC@resvdb{0123456789}\SKC@swafalse\SKC@swatrue + \csv@@parse[,]{#1}% +} +\robust@def*\skc@definekeys{% + \begingroup + \endlinechar\m@one + \cpt@testopt\skc@d@finekeys{SKC}% +} +\robust@def*\skc@d@finekeys[#1]#2{% + \cpt@testopt{\expandafter\endgroup\skc@d@f@nekeys{#1}{#2}}{}% +} +\robust@def*\skc@d@f@nekeys#1#2[#3]#4{% + \begingroup + \ltxkeys@makepf{#1}% + \ltxkeys@makehdr{#2}% + \trim@@space{#1}\skc@keypref + \trim@@space{#2}\skc@keyfam + \trim@@space{#3}\skc@macpref + \toks@{}% + \def\skc@keyvals{}% + \def\skc@splita##1={% + \begingroup + \defpass\skc@rsvda####1\skc@nil{\endgroup + \skc@splitb##1/####1/^?/\skc@nil + }.% }% -} -\let\SKC@rskey\SKV@resolvekey -\newdef*\SKV@everyeoehook{} -\robustdef*\everyeoe#1{% - \SKV@ifempty{#1}% - {\let\SKV@everyeoehook\@empty}% - {\SKV@prepto!\SKV@everyeoehook{#1}}% -} -\everyeoe{\@ignoretrue} -\robustdef*\newkeycmd{\@star@or@long\SKC@keycmd@i} -\robustdef*\csnewkeycmd{\SKV@aftercs\newkeycmd} -\SKV@emptycmds{\SKC@keycmdlist,\SKC@k@ycmdlist} -\newdef*\SKC@keycmd@i#1{% - \SKV@ensurescape{#1}% - \def\SKC@keycmdname{#1}% - \edef\SKC@tfam{\expandafter\@gobble\string#1}% - \edef\SKC@pref{\SKV@threexp\SKV@carcube - \expandafter\@gobble\string#1xxx\@nil}% - \edef\SKC@pref{\SKC@pref @}% - \SKV@scantoksa{\SKC@tfam,\SKC@pref}% - \SKV@testopth\SKC@keycmd@ii\SKC@pref -} -\newdef\SKC@keycmd@ii<#1>{% - \SKV@ifnotblank{#1}\relax\SKC@nilprefix - \SKC@badprefix{#1}% - \edef\SKC@pref{#1}% - \edef\SKC@tempa##1{\skvoptions{##1,keyfamily=\SKC@tfam, - macroprefix=\SKC@pref}}% - \SKC@tempa{keyparser=;,keyprefix=KV}% - \SKV@testoptp\SKC@keycmd@iii{}% -} -\newdef\SKC@keycmd@iii(#1){% - \SKV@ifnotempty{#1}\relax\SKC@nilkeylist - \SKC@keycmd@iv{#1}% - \SKV@despacelist*\SKC@keycmdlist - \SKV@despacelist*\SKC@k@ycmdlist - \define@keylist*\SKC@keycmdlist - \edef\SKC@tempa{\setkeys[KV]{\SKC@tfam}{\SKC@k@ycmdlist}}% - \SKC@tempa - \SKV@testopt\SKC@keycmd@v{0}% -} -\newdef\SKC@keycmd@iv#1{% - \SKV@emptycmds!{\SKC@keycmdlist,\SKC@k@ycmdlist}% - \XKV@checksanitizea{#1}\SKC@tempa - \SKV@normalizea\SKC@tempa - \SKV@for*[,]\SKC@tempa\SKC@tempa{% - \expandafter\SKC@getkeyname\SKC@tempa==\@nil - \SKC@addtokeylist\SKC@tkey\SKC@tval + \def\skc@splitb##1/##2/##3/##4\skc@nil{% + \ifblankTF{##1}{% + \ifblankTF{##2##3}{}{\skc@err{Empty key name}\@ehc}% + }{% + \ltxkeys@findpointers{##1}% + \let\skc@keyname\ltxkeys@tkey + \ifcsndefTF{\skc@keypref @\skc@keyfam @\skc@keyname}{% + \skc@err{Key '\skc@keyname' already defined in family + \MsgBrk '#2' with prefix '#1'}\@ehc + }{}% + \ifstrcmpTF{##2}{^?}{% + \def\skc@keydefault{}% + }{% + \simpleexpandarg\trim@@space{\@gobble##2}\skc@keydefault + }% + \ifstrcmpTF{##3}{^?}{% + \def\skc@keycallback{}% + }{% + \trim@@space{##3}\skc@keycallback + }% + \edef\skc@keyvals{% + \csliststack,\skc@keyvals\expandcsonce\skc@keyname=% + \oifstrcmpTF\skc@keydefault{true}{false}{% + \expandcsonce\skc@keydefault + }% + }% + \def\skc@defkey{\ltxkeys@boolkey}% + \oifstrcmpTF\skc@keydefault{true}{}{% + \oifstrcmpTF\skc@keydefault{false}{}{% + \def\skc@defkey{\ltxkeys@cmdkey}% + }% + }% + \cptpassexpanded{% + \toks@{\the\toks@ + \skc@defkey[\skc@keypref]{\skc@keyfam}[\skc@macpref]% + {\skc@keyname}[\expandcsonce\skc@keydefault]% + {\expandcsonce\skc@keycallback}% + }% + }% + }% }% -} -\newdef\SKC@keycmd@v[#1]{% - \SKC@paramerr{#1}% - \SKV@testopt{\SKC@keycmd@vi[#1]}{}% -} -\let\SKC@tag\z@ -\newdef\SKC@keycmd@vi[#1][#2]#3{% - \let\SKC@tag\@ne - \edef\SKC@resvda##1##2{% - ##1[\the\numexpr#1+1]\SKV@ifblank{#2}{}{[\unexpanded{#2}]}% - {\setkeys[KV]{\SKC@tfam}{####\the\numexpr#1+1}##2}% + \long\def\csv@do##1{% + \cpt@checkeq##1\cpt@nil{% + \skc@splita##1\skc@nil + }{% + \skc@splitb##1/^?/^?/\skc@nil + }% }% - \SKV@ifx\l@ngrel@x\relax - {\def\SKC@resvdb{\newtwooptcmd*}}% - {\let\SKC@resvdb\newtwooptcmd}% - \SKC@resvda{\expandafter\SKC@resvdb\SKC@keycmdname}{#3}% - \let\SKC@tag\z@ -} -\robustdef*\renewkeycmd{\@star@or@long\SKC@renewkeycmd@i} -\robustdef*\csrenewkeycmd{\SKV@aftercs\renewkeycmd} -\newdef*\SKC@renewkeycmd@i#1{% - \SKV@ifdef#1{}% - {\SKC@err{Command '\string#1' undefined}% - {Undefined command '\string#1' can't be redefined.\SKV@MB - Use '\string\newkeycmd' instead.}% + \csv@@parse[,]{#4}% + \cptexpandsecond\endgroup{% + \the\toks@ + \ifcsnullTF\skc@keyvals{}{\noexpand\ltxkeys@setkeys + [\skc@keypref]{\skc@keyfam}{\expandcsonce\skc@keyvals}% }% - \let\SKV@ifdefinable\SKC@rc@ifdefinable - \SKC@keycmd@i#1% -} -\robustdef*\newkeyenviron{\@star@or@long\SKC@keyenviron@i} -\robustdef*\csnewkeyenviron{\SKV@aftercs\newkeyenviron} -\newdef\SKC@keyenviron@i#1{% - \SKV@ensurenoscape{#1}% - \SKV@ifcsdef{#1}{% - \SKC@err{You have submitted an existing macro '\string#1' as an\SKV@MB - environment name}{'\string#1' not allowed as environment name.}% - }{}% - \edef\SKC@tfam{#1}% - \edef\SKC@pref{\SKV@carcube#1xxx\@nil @}% - \edef\SKC@keycmdname{\SKV@noexpcs{#1}}% - \SKV@testopth\SKC@keyenviron@ii\SKC@pref -} -\newdef\SKC@keyenviron@ii<#1>{% - \SKV@ifnotblank{#1}\relax\SKC@nilprefix - \SKC@badprefix{#1}% - \edef\SKC@pref{#1}% - \edef\SKC@tempa##1{% - \skvoptions{##1,keyfamily=\SKC@tfam,macroprefix=\SKC@pref}}% - \SKC@tempa{keyparser=;,keyprefix=KV}% - \SKV@testoptp\SKC@keyenviron@iii{}% -} -\newdef\SKC@keyenviron@iii(#1){% - \SKV@ifnotempty{#1}\relax\SKC@nilkeylist - \SKC@keycmd@iv{#1}% - \define@keylist*\SKC@keycmdlist - \edef\SKC@tempa{\setkeys[KV]{\SKC@tfam}{\SKC@k@ycmdlist}}% - \SKC@tempa - \SKV@testopt\SKC@keyenviron@v{0}% -} -\newdef\SKC@keyenviron@v[#1]{% - \SKC@paramerr{#1}% - \SKV@testopt{\SKC@keyenviron@vi[#1]}{}% -} -\newdef\SKC@keyenviron@vi[#1][#2]#3#4{% - \let\SKC@tag\@ne - \edef\SKC@resvda##1##2{% - ##1[\the\numexpr#1+1]\SKV@ifblank{#2}{}{[\unexpanded{#2}]}% - {\setkeys[KV]{\SKC@tfam}{####\the\numexpr#1+1}##2}% }% - \SKV@ifx\l@ngrel@x\relax{% - \def\SKC@resvdb{\SKV@csdef*}% - \def\SKC@resvdc{\newtwooptcmd*}% +} +\def\skc@everyeoehook{} +\robust@def*\EveryEndOfKeyEnviron#1{% + \ifnullTF{#1}{% + \gdef\skc@everyeoehook{}% }{% - \let\SKC@resvdb\SKV@csdef - \let\SKC@resvdc\newtwooptcmd + \xdef\skc@everyeoehook{% + \unexpanded{#1}\expandcsonce\skc@everyeoehook + }% }% - \SKC@resvdb{end\SKC@tfam}{#4\SKV@everyeoehook}% - \SKC@resvda{\expandafter\SKC@resvdc\SKC@keycmdname}{#3}% - \let\SKC@tag\z@ -} -\robustdef*\renewkeyenviron{\@star@or@long\SKC@renewkeyenviron@i} -\robustdef*\csrenewkeyenviron{\SKV@aftercs\renewkeyenviron} -\newdef*\SKC@renewkeyenviron@i#1{% - \SKV@ifcsdef{#1}{}{% - \SKC@err{Environment '#1' undefined}% - {Undefined environment '#1' can't be redefined.}% + \begingroup + \edef\skc@tempa{\string\@ignoretrue}% + \edef\skc@tempb{\string\ignorespacesafterend}% + \edef\skc@tempc{% + \expandafter\strip@prefix\meaning\skc@everyeoehook }% - \SKV@Undef+!{#1,end#1}% - \SKC@keyenviron@i{#1}% -} -\newdef\SKC@getkeyname#1=#2=#3\@nil{% - \XKV@g@tkeyname#1=\@nil\SKC@tkey - \SKV@expnext\SKV@sp@def\SKC@tkey\SKC@tkey - \def\SKC@tval{#2}% - \SKV@oifempty{\SKC@tkey}{% - \SKV@ifempty{#2}{}% - {\SKC@err{No key specified for value '#2'}% - {Key required for value '#2'.}% + \oifinsetTF\skc@tempa\skc@tempc{% + \oifinsetTF\skc@tempb\skc@tempc{% + \skc@err{Bad '\string\EveryEndOfKeyEnviron'}{% + You can't have both '\string\@ignoretrue' and + '\string\ignorespacesafterend' in + '\string\EveryEndOfKeyEnviron'.}% + }{% + \skc@checkbadeoe\@ignoretrue + }% + }{% + \oifinsetFT\skc@tempb\skc@tempc{}{% + \skc@checkbadeoe\ignorespacesafterend + }% + }% + \endgroup +} +\new@def*\skc@checkbadeoe#1{% + \begingroup + \edef\skc@tempa##1{\def##1####1\detokenize{#1}####2\relax}% + \skc@tempa\skc@tempa{% + \ifblankTF{##2}{% + \ifskc@verbose + \skc@info{Good last token '\detokenize{#1}' in + '\string\EveryEndOfKeyEnviron'}% + \fi + }{% + \xifinsetTF{\detokenize{#1}}{\detokenize{##2}}{% + \skc@err{'\detokenize{#1}' repeated in + '\string\EveryEndOfKeyEnviron'.}{% + Multiple '\detokenize{#1}' not allowed in + '\string\EveryEndOfKeyEnviron'.}% + }{% + \skc@err{Bad last token in '\string\EveryEndOfKeyEnviron'}% + {'\detokenize{#1}' not the last token in + '\string\EveryEndOfKeyEnviron'.}% }% - }{}% - \SKV@ifnotempty{#3}{}% - {\SKC@err{No value specified for key '#1'}% - {Value required for key '#1'.}}% -} -\newdef\SKC@addtokeylist#1#2{% - \SKV@checkchoice{#2}{true,on,false,off}{% - \def\SKC@tempa{bool}}{\def\SKC@tempa{cmd}}% - \SKV@oifblank{#1}{}{% - \edef\SKC@resvd##1{\SKV@addtolist![;]##1{\SKC@tempa,% - \SKV@expox{#1},\SKV@expox{#2},}}% - \SKC@resvd\SKC@keycmdlist - \SKV@expnext\SKC@fpointers#1% - \edef\SKC@resvd##1{\SKV@addtolist![,]##1{\SKV@expox\SKC@resa - =\SKV@expox{#2}}}% - \SKC@resvd\SKC@k@ycmdlist + }% + }% + \cptexpandsecond\skc@tempa + {\expandafter\strip@prefix\meaning\skc@everyeoehook\relax}% + \endgroup +} +\newletcs\skceveryeoe=\EveryEndOfKeyEnviron +\EveryEndOfKeyEnviron\ignorespacesafterend +\robust@def*\newkeycmd{\cpt@starorlong\skc@keycmd@i} +\robust@def*\csnnewkeycmd{\aftercsname\newkeycmd} +\new@def*\skc@keycmd@i#1{% + \let\long@or@relax\l@ngrel@x + \ifescapedTF{#1}{}{% + \skc@err{Illegal command name: + \MsgBrk command not escaped}\@ehc + }% + \def\skc@cmdname{#1}% + \edef\skc@currfam{\cptgobblescape{#1}}% + \edef\skc@macpref{\cptthreexp\@carcube + \expandafter\@gobble\string#1xxx\@nil @}% + \skc@scantoksb{\skc@currfam,\skc@macpref}% + \skc@testltopt\skc@keycmd@ii\skc@macpref +} +\new@def\skc@keycmd@ii<#1>{% + \cptexpandarg\skc@macprefixerr{#1}% + \edef\skc@macpref{#1}% + \skc@testpnopt\skc@keycmd@iii{}% +} +\new@def\skc@keycmd@iii(#1){% + \ifnullFT{#1}{}\skc@nilkeylisterr + \cptexpandsecond\skc@definekeys + {[SKC]{\skc@currfam}[\skc@macpref]}{#1}% + \cpt@testopt\skc@keycmd@iv{0}% +} +\new@def\skc@keycmd@iv[#1]{% + \skc@paramnoerr{#1}% + \cpt@testopt{\skc@keycmd@v#1}{}% +} +\new@def\skc@keycmd@v#1[#2]#3{% + \skc@inkeytrue + \skc@keycmd@vi{#1}{#2}{#3}% + \ifx\long@or@relax\relax + \def\skc@rsvdb{\newtwooptcmd*}% + \else + \let\skc@rsvdb\newtwooptcmd + \fi + \skc@rsvda{\expandafter\skc@rsvdb\skc@cmdname}% + \skc@inkeyfalse +} +\robust@def*\skc@keycmd@vi#1#2#3{% + \edef\skc@rsvda##1{% + ##1[\the\numexpr#1+1]\ifblankTF{#2}{}{[\unexpanded{#2}]}{% + \ltxkeys@setkeys[SKC]{\skc@currfam}{####\the\numexpr#1+1}% + \unexpanded{#3}% + }% }% } -\SKV@def*\SKC@fpointers#1{% - \SKC@rskey{#1}\uservalue\savevalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\guservalue\savevalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\savevalue\uservalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\gsavevalue\uservalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\guservalue\gsavevalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\gsavevalue\guservalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\uservalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\guservalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\savevalue\@nil\SKC@resa{}% - {\SKC@rskey{#1}\gsavevalue\@nil\SKC@resa{}{}}}}}}}}}}% -} -\robustdef*\newtwooptcmd{\@star@or@long\SKC@newcommand@i} -\newdef*\SKC@newcommand@i#1{\SKV@testopt{\SKC@newcommand@ii#1}0} -\newdef*\SKC@newcommand@ii#1[#2]{% - \SKV@if@brack{\SKC@xargdef#1[#2]}{\SKC@argdef#1[#2]}} -\newdef\SKC@argdef#1[#2]#3{\SKV@ifdefinable#1{\SKC@yargdef#1\@ne{#2}{#3}}} -\newdef\SKC@xargdef#1[#2][#3]#4{% - \SKV@ifdefinable#1{% - \edef\SKC@resvda##1##2##3{% - \def##1{##2\SKV@noexpcs{\string#1}{##3}}}% - \SKC@resvda#1{\SKC@protected@testopt#1}{#3}% - \SKV@aftercs\SKC@yargdef{\string#1}\tw@{#2}{#4}% +\robust@def*\renewkeycmd{\cpt@starorlong\skc@renewkeycmd@i} +\robust@def*\csnrenewkeycmd{\aftercsname\renewkeycmd} +\new@def*\skc@renewkeycmd@i#1{% + \ifdefTF#1{}{% + \skc@err{Command '\string#1' undefined}% + {Undefined command '\string#1' can't be redefined.\MsgBrk + Use '\string\newkeycmd' instead.}% + }% + \let\ifcsdefinable\rc@ifcsdefinable + \skc@keycmd@i#1% +} +\robust@def*\newkeyenviron{\cpt@starorlong\skc@keyenviron@i} +\robust@def*\csnnewkeyenviron{\aftercsname\newkeyenviron} +\new@def\skc@keyenviron@i#1{% + \let\long@or@relax\l@ngrel@x + \ifescapedTF{#1}{% + \skc@err{Illegal environment name: + \MsgBrk no escape expected}\@ehc + }{}% + \ifcsndefFT{#1}{}{% + \skc@err{You have submitted an existing macro + '\string#1' as an\MsgBrk environment name}% + {'\string#1' not allowed as environment name.}% + }% + \edef\skc@currfam{#1}% + \edef\skc@macpref{\@carcube#1xxx\@nil @}% + \edef\skc@cmdname{\noexpandcsn{#1}}% + \skc@testltopt\skc@keyenviron@ii\skc@macpref +} +\new@def\skc@keyenviron@ii<#1>{% + \cptexpandarg\skc@macprefixerr{#1}% + \edef\skc@macpref{#1}% + \skc@testpnopt\skc@keyenviron@iii{}% +} +\new@def\skc@keyenviron@iii(#1){% + \ifnullFT{#1}{}\skc@nilkeylisterr + \cptexpandsecond\skc@definekeys + {[SKC]{\skc@currfam}[\skc@macpref]}{#1}% + \cpt@testopt\skc@keyenviron@v{0}% +} +\new@def\skc@keyenviron@v[#1]{% + \skc@paramnoerr{#1}% + \cpt@testopt{\skc@keyenviron@vi#1}{}% +} +\new@def\skc@keyenviron@vi#1[#2]#3#4{% + \skc@inkeytrue + \skc@keycmd@vi{#1}{#2}{#3}% + \ifx\long@or@relax\relax + \def\skc@rsvdb{\newtwooptcmd*}% + \else + \let\skc@rsvdb\newtwooptcmd + \fi + \skc@rsvda{\expandafter\skc@rsvdb\skc@cmdname}% + \edef\skc@rsvda##1{% + \long@or@relax\def\noexpandcsn{end\skc@currfam}% + {##1\expandcsonce\skc@everyeoehook}% + }% + \skc@rsvda{#4}% + \skc@inkeyfalse +} +\robust@def*\renewkeyenviron{\cpt@starorlong\skc@renewkeyenviron@i} +\robust@def*\csnrenewkeyenviron{\aftercsname\renewkeyenviron} +\new@def*\skc@renewkeyenviron@i#1{% + \ifcsndefTF{#1}{}{% + \skc@err{Environment '#1' undefined}% + {Undefined environment '#1' can't be redefined.}% + }% + \undefcsn{#1}\undefcsn{end#1}% + \skc@keyenviron@i{#1}% +} +\robust@def*\newtwooptcmd{\cpt@starorlong\skc@newcommand@i} +\new@def*\skc@newcommand@i#1{% + \let\long@or@relax\l@ngrel@x + \cpt@testopt{\skc@newcommand@ii#1}0% +} +\new@def*\skc@newcommand@ii#1[#2]{% + \cpt@ifbrack{\skc@xargdef#1{#2}}{\skc@argdef#1{#2}}% +} +\new@def\skc@argdef#1#2#3{\ifcsdefinable#1{\skc@yargdef#1{1}{#2}{#3}}} +\new@def\skc@xargdef#1#2[#3]#4{% + \ifcsdefinable#1{% + \edef\skc@rsvda##1##2##3{% + \def##1{##2\noexpandcsn{\string#1}{##3}}% + }% + \skc@rsvda#1{\@protected@testopt#1}{#3}% + \aftercsname\skc@yargdef{\string#1}{2}{#2}{#4}% }% } -\newdef\SKC@protected@testopt#1{% - \SKV@ifx\protect\@typeset@protect\SKV@testopt{\protect#1}% -} -\newdef\SKC@yargdef#1#2#3{% - \SKV@ifx{#2}\tw@ - {\edef\SKC@shear##11{[\detokenize{####1}]}}% - {\let\SKC@shear\@gobble}% - \SKV@expnext\SKC@yargd@f{\the\numexpr#3}#1% -} -\newdef*\SKC@dotparse@a#1{% - \SKV@toks{}% - \edef\SKC@resa{\unexpanded{#1}.}% - \def\SKC@resb##1.##2\@nil{% - \SKV@in@o{[}{##1}% - {\SKV@toks\expandafter{\the\SKV@toks##1}}% - {\SKV@toks\expandafter{\the\SKV@toks{##1}}}% - \SKV@ifempty{##2}{}{\SKC@resb##2\@nil}% +\new@def\skc@yargdef#1#2#3{% + \ifnum#2=2\relax + \edef\skc@shear##11{[\detokenize{####1}]}% + \else + \let\skc@shear\@gobble + \fi + \cptexpandarg\skc@yargd@f{\the\numexpr#3}#1% +} +\new@def*\skc@dotparse@a#1{% + \begingroup + \toks@{}% + \def\reserved@f##1.##2\skc@nil{% + \oifinsetTF{[}{##1}{% + \toks@\expandafter{\the\toks@##1}% + }{% + \toks@\expandafter{\the\toks@{##1}}% + }% + \ifnullTF{##2}{}{\reserved@f##2\skc@nil}% }% - \expandafter\SKC@resb\SKC@resa\@nil - \edef\SKC@resa{\the\SKV@toks}% -} -\newdef*\SKC@dotparse@b#1{% - \SKV@toks{}% - \edef\SKC@resa{\unexpanded{#1}.}% - \def\SKC@resb##1.##2\@nil{% - \SKV@toks\expandafter{\the\SKV@toks##1}% - \SKV@ifempty{##2}{}{\SKC@resb##2\@nil}% + \reserved@f#1.\skc@nil + \edef\reserved@f{\the\toks@}% + \postgroupdef\reserved@f\endgroup +} +\new@def*\skc@dotparse@b#1{% + \begingroup + \toks@{}% + \def\reserved@f##1.##2\skc@nil{% + \toks@\expandafter{\the\toks@##1}% + \ifnullTF{##2}{}{\reserved@f##2\skc@nil}% }% - \expandafter\SKC@resb\SKC@resa\@nil - \edef\SKC@resa{\the\SKV@toks}% + \reserved@f#1.\skc@nil + \edef\reserved@f{\the\toks@}% + \postgroupdef\reserved@f\endgroup } -\newdef\SKC@yargd@f#1#2{% - \edef\SKC@resvdb{\detokenize{0####1.####2.####3.####4.####5.% +\new@def\skc@yargd@f#1#2{% + \begingroup + \edef\skc@rsvdb{\detokenize{0####1.####2.####3.####4.####5.% ####6.####7.####8.####9.#####1}}% - \def\SKC@resvda##1#1##2\@nil{% - \def\SKC@resvdb{##1}% - \def\SKC@resvda####1{% - \def\SKC@resvda########1####1########2\@nil{% - \SKV@ifempty{########1}{% - \edef\SKC@tempa{\SKC@shear####1########2#1}% - \let\SKC@tempb\SKC@tempa - \let\SKC@tempc\SKC@tempa + \def\skc@rsvda##1#1##2\skc@nil{% + \def\skc@rsvdb{##1}% + \def\skc@rsvda####1{% + \def\skc@rsvda########1####1########2\skc@nil{% + \ifnullTF{########1}{% + \edef\skc@tempa{\skc@shear####1########2#1}% + \let\skc@tempb\skc@tempa + \let\skc@tempc\skc@tempa }{% - \edef\SKC@resvda{\SKC@shear########1####1}% - \SKV@expnext\SKC@dotparse@a\SKC@resvda - \let\SKC@tempa\SKC@resa - \SKV@expnext\SKC@dotparse@b\SKC@resvda - \let\SKC@tempb\SKC@resa - \edef\SKC@resvda{########2#1}% - \SKV@expnext\SKC@dotparse@b\SKC@resvda - \edef\SKC@tempc{\SKC@tempb(\SKC@resa)}% + \edef\skc@rsvda{\skc@shear########1####1}% + \simpleexpandarg\skc@dotparse@a\skc@rsvda + \let\skc@tempa\reserved@f + \simpleexpandarg\skc@dotparse@b\skc@rsvda + \let\skc@tempb\reserved@f + \edef\skc@rsvda{########2#1}% + \simpleexpandarg\skc@dotparse@b\skc@rsvda + \edef\skc@tempc{\skc@tempb(\reserved@f)}% }% }% - \expandafter\SKC@resvda\SKC@resvdb\@nil + \expandafter\skc@rsvda\skc@rsvdb\skc@nil }% - \SKV@ifnum{#1}=\z@{% - \SKV@emptycmds{\SKC@tempa,\SKC@tempb,\SKC@tempc}% - }{% - \SKV@expnext\SKC@resvda{\the\numexpr#1-1}% - }% - }% - \expandafter\SKC@resvda\SKC@resvdb\@nil - \SKV@scantoksa{\SKC@tempa,\SKC@tempb,\SKC@tempc}% - \edef\SKC@resvda{\expandafter\@gobble\string#2@SKC}% - \def\SKC@resvdc{% - \edef\SKC@resvdb{\l@ngrel@x\def\SKV@noexpcs\SKC@resvda\SKC@tempc}% - \SKC@resvdb - }% - \edef\SKC@resvdb{% - \ifnum#1<\tw@ - \ifx\SKC@shear\@gobble - \ifx\SKC@tag\@ne - \l@ngrel@x\def\noexpand#2% - {\noexpand\SKV@testoptp\SKV@noexpcs\SKC@resvda{}}% - \unexpanded{\edef\SKC@resvdb{\l@ngrel@x\def\SKV@noexpcs - \SKC@resvda(\SKC@tempc)}\SKC@resvdb}% - \else - \l@ngrel@x\def\noexpand#2\SKC@tempb - {\SKV@noexpcs\SKC@resvda{\SKC@tempa}}% - \noexpand\SKC@resvdc - \fi - \else - \l@ngrel@x\def\noexpand#2\SKC@tempb - {\SKV@noexpcs\SKC@resvda\SKC@tempa}% - \noexpand\SKC@resvdc - \fi + \ifnum#1=\z@pt + \cptemptifycsset{\skc@tempa,\skc@tempb,\skc@tempc}% \else - \l@ngrel@x\def\noexpand#2\SKC@tempb - {\noexpand\SKV@testoptp{\SKV@noexpcs\SKC@resvda\SKC@tempa}{}}% - \noexpand\SKC@resvdc + \simpleexpandarg\skc@rsvda{\the\numexpr#1-1}% \fi }% - \SKC@resvdb -} -\newdef\SKC@reargdef#1[#2]{\SKC@yargdef#1\@ne{#2}} -\robustdef*\renewtwooptcmd{\@star@or@long\SKC@renewcommand@i} -\newdef*\SKC@renewcommand@i#1{% - \SKV@ifdef#1{}% - {\SKC@err{Command '\string#1' undefined}% - {Command '\string#1' can't be redefined.}% + \expandafter\skc@rsvda\skc@rsvdb\skc@nil + \skc@scantoksb{\skc@tempa,\skc@tempb,\skc@tempc}% + \edef\skc@rsvda{\cptgobblescape{#2@skc@}}% + \let\reserved@e\relax + \let#2\relax + \cptpassexpanded{\endgroup + \def\reserved@e{% + \long@or@relax + \def\noexpandcsn\skc@rsvda\expandcsonce\skc@tempc + }% + \ifnumcmpTF#1<\tw@{% + \ifxTF\skc@shear\@gobble{% + \ifskc@inkey + \long@or@relax\def#2% + {\skc@testpnopt\noexpandcsn\skc@rsvda{}}% + \long@or@relax\def\noexpandcsn\skc@rsvda(\skc@tempc)% + \else + \long@or@relax\def#2\skc@tempb + {\noexpandcsn\skc@rsvda{\skc@tempa}}% + \reserved@e + \fi + }{% + \long@or@relax\def#2\skc@tempb + {\noexpandcsn\skc@rsvda\skc@tempa}% + \reserved@e + }% + }{% + \long@or@relax\def#2\skc@tempb + {\skc@testpnopt{\noexpandcsn\skc@rsvda\skc@tempa}{}}% + \reserved@e }% - \let\SKV@ifdefinable\SKC@rc@ifdefinable - \SKC@newcommand@i#1% -} -\let\SKC@ifd@finable\SKV@ifdefinable -\newdef\SKC@rc@ifdefinable#1#2{\let\SKV@ifdefinable\SKC@ifd@finable#2} -\newdef*\newtwooptenviron{\@star@or@long\SKC@newenvironment@i} -\newdef*\SKC@newenvironment@i#1{\SKV@testopt{\SKC@newenv@a#1}0} -\newdef*\SKC@newenv@a#1[#2]{% - \SKV@if@brack{\SKC@newenv@b#1[#2]}{\SKC@newenv{#1}{[#2]}}} -\newdef*\SKC@newenv@b#1[#2][#3]{\SKC@newenv{#1}{[#2][{#3}]}} -\newdef*\renewtwooptenviron{\@star@or@long\SKC@renewenvironment@i} -\newdef*\SKC@renewenvironment@i#1{% - \SKV@ifcsdef{#1}{}{% - \SKC@err{Environment '#1' undefined}% - {Undefined environment '#1' can't be redefined.}% }% - \SKV@Undef+!{#1,end#1}% - \SKC@newenvironment@i{#1}% -} -\newdef\SKC@newenv#1#2#3#4{% - \SKV@ifcsdef{#1}{}{\SKV@csletcs*{#1}{end#1}}% - \SKV@aftercs\SKC@newcommand@i{#1}#2{#3}% - \l@ngrel@x\@namedef{end#1}{#4}% -} -\robustdef*\SKC@nilprefix{% - \SKC@err{% - No macro prefix submitted. The prefix will\SKV@MB - be used to hold your values for the declared keys\SKV@MB - }{% - Keycommand requires macro prefix. I guess you\SKV@MB - submitted an empty prefix using '<>'. I can use\SKV@MB - the default macro prefix (the first three\SKV@MB - letters of your key command) if you don't submit\SKV@MB - any prefix. In that case leave out '<>' from your\SKV@MB +} +\new@def\skc@reargdef#1[#2]{\skc@yargdef#1{1}{#2}} +\robust@def*\renewtwooptcmd{\cpt@starorlong\skc@renewcommand@i} +\new@def*\skc@renewcommand@i#1{% + \ifdefTF#1{}{% + \skc@err{Undefined command '\string#1' can't be + redefined}\@ehc + }% + \let\ifcsdefinable\rc@ifcsdefinable + \skc@newcommand@i#1% +} +\new@def*\newtwooptenviron{\cpt@starorlong\skc@newenvironment@i} +\new@def*\skc@newenvironment@i#1{% + \let\long@or@relax\l@ngrel@x + \cpt@testopt{\skc@newenv@a#1}0% +} +\new@def*\skc@newenv@a#1[#2]{% + \cpt@ifbrack{\skc@newenv@b#1[#2]}{\skc@newenv{#1}{[#2]}}% +} +\new@def\skc@newenv#1#2#3#4{% + \ifcsndefTF{#1}{}{\letcsntocsn{#1}{end#1}}% + \aftercsname\skc@newcommand@i{#1}#2{#3}% + \long@or@relax\@namedef{end#1}{#4}% +} +\new@def*\skc@newenv@b#1[#2][#3]{\skc@newenv{#1}{[#2][{#3}]}} +\new@def*\renewtwooptenviron{\cpt@starorlong\skc@renewenvironment@i} +\new@def*\skc@renewenvironment@i#1{% + \ifcsndefTF{#1}{}{% + \skc@err{Undefined environment '#1' can't be redefined}\@ehc + }% + \undefcsn{#1}\undefcsn{end#1}% + \skc@newenvironment@i{#1}% +} +\robust@def*\skc@nilprefixerr{% + \skc@err{No macro prefix submitted. The prefix will\MsgBrk + be used to hold your values for the declared keys}{% + Keycommand requires macro prefix. I guess you\MsgBrk + submitted an empty prefix using '<>'. I can use\MsgBrk + the default macro prefix (the first three\MsgBrk + letters of your key command) if you don't submit\MsgBrk + any prefix. In that case leave out '<>' from your\MsgBrk command. }% } -\robustdef*\SKC@badprefix#1{% - \SKC@fdigit{#1}% - \unless\ifSKC@swa\SKV@afterfi - \SKC@err{% - '\string#1' is likely a wrong macro prefix +\new@def*\skc@ifdigitpresent#1{% + \begingroup + \cpt@choicefdfalse + \def\tsv@do##1{% + \ifinsetTF{##1}{0123456789}{% + \cpt@choicefdtrue\cptbreakloop + }{}% + }% + \tsv@@parse{#1}% + \expandafter\endgroup\ifcpt@choicefd + \expandafter\@iden\else\expandafter\@gobble\fi +} +\new@def*\skc@macprefixlist{} +\robust@def*\skc@macprefixerr#1{% + \xifblankTF{#1}{% + \skc@nilprefixerr + }{% + \xifinsetTF{,#1,}{,\skc@macprefixlist,}{% + \skc@err{Macro prefix '#1' already used, + \MsgBrk or name '#1' illegal}\@ehc }{% - I expected letters here, not digits.\SKV@MB - OK, digits are actually acceptable as macro\SKV@MB - prefix but you need to be wary of them if they\SKV@MB - appear in your control sequences. Also, I fear\SKV@MB - you may have wrongly entered the number of\SKV@MB - arguments of your key command here, instead\SKV@MB - of putting it in the right place (in square brackets). + \edef\skc@macprefixlist{\csliststack,\skc@macprefixlist#1}% + \skc@ifdigitpresent{#1}{% + \skc@err{'\string#1' is likely a wrong macro prefix}{% + I expected letters here, not digits.\MsgBrk + OK, digits are actually acceptable as macro\MsgBrk + prefix but you need to be wary of them if they\MsgBrk + appear in your control sequences. Also, I fear\MsgBrk + you may have wrongly entered the number of\MsgBrk + arguments of your key command here, instead\MsgBrk + of putting it in the right place, ie, in square brackets. + }% + }% }% - \fi + }% } -\robustdef*\SKC@nilkeylist{% - \SKC@err{% - No key list submitted or wrong command syntax.\SKV@MB - Please see the user guide. - }{% - Keycommand requires keys. Perhaps you submitted\SKV@MB - an empty key list, or your arguments to command\SKV@MB - are inconsistent. Please see the user guide.\SKV@MB +\robust@def*\skc@nilkeylisterr{% + \skc@err{No key list submitted or wrong command syntax.\MsgBrk + Please see the user guide.}{Key-commands require keys. + Perhaps you submitted\MsgBrk an empty key list, or your + arguments to command\MsgBrk are inconsistent. Please see + the user guide.\MsgBrk }% } -\newdef*\SKC@paramerr#1{% - \SKV@ifnum{#1}<9{}{% - \SKC@err{% - Number '\string#1' of parameters too large - }{% - You're limited to 8 parameters here.\SKV@MB - If necessary, you can use keys to submit\SKV@MB - more variables. In fact, you can use keys to\SKV@MB +\new@def*\skc@paramnoerr#1{% + \ifnum#1<9\relax\else + \skc@err{Number '\string#1' of parameters too large}{% + You're limited to 8 parameters here.\MsgBrk + If necessary, you can use keys to submit\MsgBrk + more variables. In fact, you can use keys to\MsgBrk submit all your variables. }% - }% + \fi } \endinput |