diff options
author | Karl Berry <karl@freefriends.org> | 2011-12-21 23:44:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-12-21 23:44:02 +0000 |
commit | 117036c8b17ada73b5a49c31661201ffdf6a55d8 (patch) | |
tree | 45e6c2fad0d1192d07e8024887a556c4b75c5624 /Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty | |
parent | 96d75501059aaba75f35e407391703be9cf3b21f (diff) |
ltxkeys 0.0.3 (19dec11)
git-svn-id: svn://tug.org/texlive/trunk@24898 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty | 582 |
1 files changed, 460 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty b/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty index 7b735cc143c..ad892504860 100644 --- a/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty +++ b/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty @@ -1,6 +1,6 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % % -% This is file 'ltxkeys.sty', version 0.0.2, October 2011. % +% This is file 'ltxkeys.sty', version 0.0.3, December 2011. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -21,23 +21,22 @@ %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \@ifpackageloaded{catoptions}{% - \@ifpackagelater{catoptions}{2011/10/22}{}{% + \@ifpackagelater{catoptions}{2011/12/10}{}{% \@latex@error{Loaded version of catoptions package is not current}\@ehc }% }{% - \RequirePackage{catoptions}[2011/10/22]% + \RequirePackage{catoptions}[2011/12/10]% } \UseNormalCatcodes -\StyleFilePurpose{A robust and fast key-value parser (AM)} +\StyleFilePurpose{A robust key-value parser (AM)} \StyleFileRCSInfo -$Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ +$Id: ltxkeys.sty,v 0.0.3 2011/12/17 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{ltxkeys}[\StyleFileInfo] -\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\NeedsTeXFormat{LaTeX2e}[2011/06/27] \SetStyleFileMessages[ltxkeys@]{info}{warn}{err} -\catcode`\&=3 -\catcode`\^=3 \cpt@setupsafeactivesedef +\catcode`\&=3 \new@def\ltxkeys@afterfi#1\ltxkeys@fi{\fi#1} \new@def\ltxkeys@after@i#1\ltxkeys@else#2\ltxkeys@fi{\fi#1} \new@def\ltxkeys@after@ii#1\ltxkeys@else#2\ltxkeys@fi{\fi#2} @@ -45,7 +44,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \newletcs\ltxkeys@fi\fi \new@def*\ltxkeys@ehc{% \ifx\protect\string\ltxkeys@afterfi - A serious error has been ecountered.\MsgBrk + A serious error has occurred.\MsgBrk Try typing <return>\space to proceed.\MsgBrk If that fails, type X and then <return>\space to quit. \ltxkeys@fi @@ -62,21 +61,19 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \newletcs\ltxkeys@nil\relax \new@def*\ltxkeys@nnil{\ltxkeys@nil} \new@def*\ltxkeys@quark{\@gobble\ltxkeys@quark} +\new@def*\ltxkeys@antiquark{\@gobble\ltxkeys@antiquark} \new@def*\ltxkeys@cdr#1#2\ltxkeys@nil{#2} \new@def*\ltxkeys@spcdr#1#2\ltxkeys@nil{\detokenize{#2}} -\new@def\ltxkeys@ifxTF#1#2{% - \ifx#1#2\ltxkeys@quark - \expandafter\iofii\else\expandafter\iiofii\fi -} \new@def\ltxkeys@ifxFT#1#2{\ltxkeys@ifxTF{#1}{#2}\iiofii\iofii} -\new@def\ltxkeys@ifcseqTF#1#2{% +\new@def\ltxkeys@ifxTF#1#2{% \expandafter\cptswap\cpt@car#1\ltxkeys@quark\car@nil - {\expandafter\ltxkeys@ifxTF\cpt@car#2\relax\car@nil}% + {\expandafter\ifx\cpt@car#2\ltxkeys@antiquark\car@nil}% + \expandafter\iofii\else\expandafter\iiofii\fi } \new@def*\ltxkeys@ifcsemptyTF#1{% \expandafter\ltxkeys@ifxTF\cpt@car#1\ltxkeys@quark\car@nil\@empty } -\robust@def*\ltxkeys@letmanytocs#1#2{\cptfor#1\dofor{\let##1=#2}} +\robust@def*\ltxkeys@letmanytocs#1#2{\cptfor#1\dofor{\let##1= #2}} \robust@def*\ltxkeys@error#1#2{\ltxkeys@err{#1}{#2}\@gobble} \robust@def*\ltxkeys@debug#1#{% \ifboolTF{ltxkeys@tracingkeys}{% @@ -92,19 +89,19 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@d@bug#1#2{% \wlog{\ifcpt@st^^J\fi ltxkeys debug [#1] #2.}% } -\newvariables{if}[ltxkeys@]{break,st,pl,cl,sw,sv,nv,noval,pxop,exop, +\cptnewvariables{if}[ltxkeys@]{break,st,pl,cl,sw,sv,nv,noval,pxop,exop, preset,disable,ini,kf,rm,ssk,dec,dep,twk,tracingkeys,useempty,chdef, swa,reservenopath,global,protected,inkeycmd}[false] -\newvariables{if}{inputvalid}[false] -\newvariables{switch}{infdpointers,infdp@inters}[false] -\newvariables{count}[ltxkeys@]{csvdepth,keydepth}[\z@pt] +\cptnewvariables{if}{inputvalid}[false] +\cptnewvariables{switch}{infdpointers,infdp@inters}[false] +\cptnewvariables{count}[ltxkeys@]{csvdepth,keydepth}[\z@pt] \robust@def*\setslavewithmaster{\global\ltxkeys@ssktrue} \robust@def*\setnoslavewithmaster{\global\ltxkeys@sskfalse} \setnoslavewithmaster \robust@def*\allowemptykeypath{\global\ltxkeys@useemptytrue} \robust@def*\disallowemptykeypath{\global\ltxkeys@useemptyfalse} \DefSuffixChecker\ltxkeys@suffixcheck{*}{+}{!} -\let\ltxkeys@documentclass\cpt@undefined +\newletcs\ltxkeys@documentclass\cpt@undefined \robust@def*\ltxkeys@getdocumentclass{% \def\csv@do##1{% \filename@parse{##1}% @@ -120,7 +117,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \csv@@parse*\@filelist \ifdefTF\ltxkeys@documentclass{}{% \ltxkeys@debug{==}{'ltxkeys' package loaded before - \string\documentclass: \MsgBrk no problem}% + \string\documentclass:\MsgBrk no problem}% }% } \cptpassunexpanded{% @@ -208,18 +205,34 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \@do#1,\@nil\@nil,% } \new@def*\ltxkeys@iffirstnull#1#2{\ltxkeys@ifcsemptyTF#1{}{#1#2}} +\robust@def*\ltxkeys@remdottrimspaces#1#2{% + \cptexpandbracenext\ltxkeys@trimspaces{\@gobble#1}#2% +} +\robust@def*\ltxkeys@simplesplitkeyval#1{% + \expandafter\ltxkeys@simplespl@tkeyval#1=^?^=^?^=\ltxkeys@nil +} +\robust@def*\ltxkeys@simplespl@tkeyval#1={% + \def\reserved@a##1={% + \def\reserved@a####1=####2\ltxkeys@nil{% + \ltxkeys@trimspaces{#1}\key@name + \ltxkeys@remdottrimspaces{##1}\key@value + \ltxkeys@remdottrimspaces{####1}\remainder + }% + \reserved@a.% + }% + \reserved@a.% +} \robust@def*\ltxkeys@splitkeyattrib#1{% \begingroup \def\ltxkeys@splita##1/##2/{% \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name}% \ltxkeys@ifrejname{% - \ltxkeys@err{Wrong syntax for attributes of a key} - \ltxkeys@ehc + \ltxkeys@err{Wrong syntax for attributes of a key}\ltxkeys@ehc }% \ltxkeys@splitb.% }% \def\ltxkeys@splitb##1/{% - \s@expandarg\ltxkeys@trimspaces{\@gobble##1}\key@default + \ltxkeys@remdottrimspaces{##1}\key@default \ltxkeys@splitc.% }% \def\ltxkeys@splitc##1/{% @@ -228,22 +241,23 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@splitd.% }% \def\ltxkeys@splitd##1/##2\ltxkeys@nil{% - \s@expandarg\ltxkeys@trimspaces{\@gobble##1}\key@dependants + \ltxkeys@remdottrimspaces{##1}\key@dependants }% - \ltxkeys@splita#1/^?/^?/^?/^?/^?/\ltxkeys@nil + \ltxkeys@splita#1/^?^/^?^/^?^/^?^/^?^/\ltxkeys@nil \let\do\cpt@csexit \cptexpanded{\endgroup \do\key@type\do\key@name\do\key@default\do\key@macro \do\key@dependants }% } -\new@def*\ltxkeys@rej{^?} +\new@def*\ltxkeys@rej{^?^} +% Does #1 start with '.code'? If it does, remove '.code': \robust@def*\ltxkeys@stripdotcode#1{% \ltxkeys@trimspacesincs#1% \xifinsetTF{\relax\detokenize{.code=}}{\relax\cptoxdetok{#1}}{% \def\reserved@a##1.code=##2\ltxkeys@nil{% \def\reserved@a####1.\ltxkeys@nil{% - \s@expandarg\ltxkeys@trimspaces{\@gobble####1}#1% + \ltxkeys@remdottrimspaces{####1}#1% }% \reserved@a.##2\ltxkeys@nil }% @@ -255,7 +269,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \xifinsetTF{\detokenize{/.code=}}{\detokenize{#1}}{% \def\reserved@a##1/.code=##2\ltxkeys@nil{% \def\reserved@a####1.\ltxkeys@nil{% - \s@expandarg\ltxkeys@trimspaces{\@gobble####1}\reserved@a + \ltxkeys@remdottrimspaces{####1}\reserved@a \edef#2{\expandcsonce{\@gobble##1}/\expandcsonce\reserved@a}% }% \reserved@a.##2\ltxkeys@nil @@ -275,7 +289,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@trimspaces{#1}\reserved@a \ltxkeys@trimspaces{#2}\reserved@b \ltxkeys@stfalse - \cptexpandargonce\ltxkeys@in@a\reserved@a\reserved@b + \cptexpandtwoargsonce\ltxkeys@in@a\reserved@a\reserved@b \ifin@ } \robust@def*\ltxkeys@ifchcfd#1\endgroup{% @@ -309,21 +323,27 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \fi #2% } -\new@def\ltxkeys@stripouterbraces#1#2{% - \romannumeral\expandafter\ltxkeys@str@pouterbraces - \expandafter{\romannumeral\number#1000m}{#2}% +\new@def\ltxkeys@stripNouterbraces#1#2{% + \romannumeral\expandafter\ltxkeys@str@pNouterbraces + \expandafter{\romannumeral\number#1000m}\strip@nil#2\strip@nil } -\new@def\ltxkeys@str@pouterbraces#1#2{% +\new@def\ltxkeys@str@pNouterbraces#1\strip@nil#2\strip@nil{% \ifbracedTF{#2}{% \expandafter\ifnullTF\expandafter{\@gobble#2}{% \expandafter\ifnullTF\expandafter{\@gobble#1}{0 #2}{% - \s@expandarg\ltxkeys@str@pouterbraces{\@gobble#1}#2% + \cptexpandbracenext\ltxkeys@str@pNouterbraces{\@gobble#1}% + \strip@nil#2\strip@nil }% }{0 #2}% }{0 #2}% } -\robust@def\ltxstripouterbraces#1#2#3{% - \edef#3{\unexpanded\cptthreexp{\ltxkeys@stripouterbraces{#1}{#2}}}% +\new@def*\ltxkeys@stripallouterbraces#1{\ltxkeys@stripNouterbraces\@m{#1}} +\new@def*\ltxkeys@stripallouterbracesincs#1{% + \ifmacroTF{#1}{% + \edef#1{\cptexpandbracenext{\ltxkeys@stripNouterbraces\@m}{#1}}% + }{% + \cpt@notcserr{#1}% + }% } \robust@def*\ltxkeys@getbasechars{\cpt@teststopt\ltxkeys@g@tchars{1}} \robust@def*\ltxkeys@g@tchars[#1]#2#3{% @@ -409,6 +429,31 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% } +\provide@def\all@to@endif#1\endif{#1} +\provide@def\first@to@endif#1#2\endif{#1} +\new@def*\ltxkeys@ifcassenumcmpTF#1#2#3{% + \ifdim#1pt#2pt % + \expandafter\iofii\else\expandafter\iiofii\fi +} +\new@def\ltxkeys@ifcasse#1{% + \ifstrcmpTF{#1}\elseif{% + \all@to@endif + }{% + \ifstrcmpTF{#1}\endif{}{\ltxkeys@ifcasse@a{#1}}% + }% +} +\new@def\ltxkeys@ifcasse@a#1#2{% + \ifstrcmpTF{#2}\elseif{% + \all@to@endif + }{% + \ifstrcmpTF{#2}\endif{}{% + \ltxkeystestcmd{#1}{#2}\first@to@endif{\ltxkeys@ifcasse@b{#1}}% + }% + }% +} +\new@def\ltxkeys@ifcasse@b#1#2{% + \ifstrcmpTF{#2}\endif{}{\ltxkeys@ifcasse@a{#1}}% +} \robust@def*\ltxkeys@removeelements{\cpt@teststopt\ltxkeys@rem@veelements,} \robust@def*\ltxkeys@rem@veelements[#1]{% \cpt@testpnopt{\ltxkeys@rem@veelem@nts{#1}}\@ne @@ -416,10 +461,10 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \robust@def\ltxkeys@rem@veelem@nts#1(#2)#3#4{% \let\ltxkeys@tempa#3% \ifcpt@st\else - \ifnum#2=\z@pt\cptthreexp\cpt@gobbletorelax\fi + \ifnum#2=\z@pt\cptthreexp\cptgobbletorelax\fi \fi \iflacus#4\dolacus - \expandafter\cpt@gobbletorelax + \expandafter\cptgobbletorelax \fi \begingroup \let\detk\detokenize @@ -464,10 +509,10 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \robust@def\ltxkeys@r@pl@ceelements#1(#2)#3#4{% \let\ltxkeys@tempa#3% \ifcpt@st\else - \ifnum#2=\z@pt\cptthreexp\cpt@gobbletorelax\fi + \ifnum#2=\z@pt\cptthreexp\cptgobbletorelax\fi \fi \iflacus#4\dolacus - \expandafter\cpt@gobbletorelax + \expandafter\cptgobbletorelax \fi \begingroup \let\if@replst\ifcpt@st @@ -621,6 +666,25 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@error{User input '\ltxkeys@userinput' not in list of nominations ||\ltxkeys@nominations||}\ltxkeys@ehc } +\robust@def*\ltxkeys@ifoneincsvlist{\cpt@teststopt\ltxkeys@ifoneincsvl@st,} +\robust@def*\ltxkeys@ifoneincsvl@st[#1]#2#3{% + \begingroup + \ifcpt@st + \let\test@list#2% + \let\master@list#3% + \else + \edef\test@list{\unexpanded{#2}}% + \edef\master@list{\unexpanded{#3}}% + \fi + \csv@@normalize*[#1]\master@list + \cpt@choicefdfalse + \def\csv@do##1{% + \oifinset@sp@TF#1{##1}\master@list{\cpt@choicefdtrue\loopbreak}{}% + }% + \csv@@parse*[#1]\test@list + \expandafter\endgroup + \ifcpt@choicefd\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +} \robust@def*\ltxkeys@ifincsvlistTF{\cpt@teststopt\ltxkeys@ifincsvlist,} \robust@def*\ltxkeys@ifincsvlist[#1]{% \cpt@testpnopt{\ltxkeys@if@ncsvlist#1}{1}% @@ -636,7 +700,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \cpt@cnta\z@pt \def\ltxkeys@itemspresent{}% \def\ltxkeys@do##1{% - \xifinsetFT{\detokenize{#1##1#1}} + \xifinsetFT{\detokenize{#1##1#1}}% {\parser\cptoxdetok\ltxkeys@tempb\parser}{}{% \edef\ltxkeys@itemspresent {\csliststack,\ltxkeys@itemspresent\unexpanded{##1}}% @@ -658,6 +722,26 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \noexpand\@firstoftwo\fi }% } +\robust@def*\ltxkeys@ifoneintokenlist{\cpt@testst\ltxkeys@ifoneint@kenlist} +\robust@def*\ltxkeys@ifoneint@kenlist#1#2{% + \begingroup + \ifcpt@st + \let\test@list#1% + \let\master@list#2% + \else + \edef\test@list{\unexpanded{#1}}% + \edef\master@list{\unexpanded{#2}}% + \fi + \cpt@choicefdfalse + \def\tsv@do##1{% + \edef\reserved@a{\ltxkeys@stripNouterbraces{1}{##1}}% + \xifinsetTF{\cptoxdetok\reserved@a} + {\cptoxdetok\master@list}{\cpt@choicefdtrue\loopbreak}{}% + }% + \tsv@@parse*\test@list + \expandafter\endgroup + \ifcpt@choicefd\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +} \robust@def*\ltxkeys@ifintsvlistTF{% \cpt@testst{\cpt@testpnopt\ltxkeys@ifintsvlist{1}}% } @@ -768,11 +852,11 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ifcsdefinable{#1}\relax \begingroup \ltxkeys@letmanytocs{#1,\ifstrcmpTF,\cptexpandnext, - \ltxkeys@ifcseqTF,\listbreak,\ltxkeys@parser@nil}\relax + \ltxkeys@ifxTF,\listbreak,\ltxkeys@parser@nil}\relax \def\elta##1{\noexpandcsn{\cptgobblescape#1@list@##1}}% \def\eltb##1{\cptexpandnext{\elta{b}##1}{########1}% #2\ltxkeys@parser@nil#2?{}}% - \def\eltc{\ltxkeys@ifcseqTF!\unexpanded{{####1}{####4}% + \def\eltc{\ltxkeys@ifxTF!\unexpanded{{####1}{####4}% {\unexpanded{####4}}}}% \cptexpanded{\endgroup \def#1####1{% @@ -780,7 +864,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \def\elta{a}####1{\eltb!}% \def\elta{b}####1####2#2####3?####4####5{% - \ltxkeys@ifcseqTF\ltxkeys@parser@nil{####2}{\eltc}{% + \ltxkeys@ifxTF\ltxkeys@parser@nil{####2}{\eltc}{% \ifstrcmpTF{####2}{\listbreak}{\eltc}{% \elta{b}{####1}####3?{####4####5{####2}}{####5}% }% @@ -1047,17 +1131,17 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \csn@xdef{\ltxkeys@hdr#1keys}{\expandcsonce{#2}}% }% } -\robust@def*\ltxkeys@addtop@intedkeys#1#2#3{% - \edef\ltxkeys@tempa{#2{\expandcsonce{#3}}}% - \letcstocsn\reserved@e{@\ltxkeys@hdr#1keys}% +\robust@def*\ltxkeys@addtosavedvalue#1#2{% + \edef\ltxkeys@tempa{#1{\expandcsonce{#2}}}% + \letcstocsn\reserved@e{\ltxkeys@hdr @savedvaluelist}% \ifdefTF\reserved@e{% - \xifinsetTF{,\cptoxdetok\ltxkeys@tempa,}{,\cptoxdetok\reserved@e,}% - {}{% - \csn@xdef{@\ltxkeys@hdr#1keys}% + \oifinset@sp@TF,\ltxkeys@tempa\reserved@e{}{% + \csn@xdef{\ltxkeys@hdr @savedvaluelist}% {\csliststack,\reserved@e\expandcsonce\ltxkeys@tempa}% }% }{% - \csn@xdef{@\ltxkeys@hdr#1keys}{\expandcsonce\ltxkeys@tempa}% + \csn@xdef{\ltxkeys@hdr @savedvaluelist}% + {\expandcsonce\ltxkeys@tempa}% }% } \new@def*\ltxkeys@currtriple{% @@ -1155,8 +1239,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \def\@do##1,##2,##3;{% \ifnot@nil{##1}{% \ifnum\numexpr - \ifdefTF##2{0}{-1}\ltxkeys@ifcsemptyTF##2{-1}{0}% - \ifdefTF##3{0}{-1}\ltxkeys@ifcsemptyTF##3{-1}{0}<\z@pt + \ifdefTF##2{0}{-1}\ltxkeys@ifcsemptyTF##2{-1}{+0}% + \ifdefTF##3{+0}{-1}\ltxkeys@ifcsemptyTF##3{-1}{+0}<\z@pt \else \oifinset@sp@FT,##2##3{}{% \ltxkeys@error{##1 '##2' is reserved} @@ -1302,6 +1386,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@boolkey@e#1#2#3#4#5{% + % We've delayed the calling of \ltxkeys@checkdefkey till + % here because of biboolkeys: \def\reserved@a##1#2\ltxkeys@nil{% \def\ltxkeys@macpref{##1}% }% @@ -1316,25 +1402,47 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ {##1}{true,false}#5}% }% } +% \ltxkeys@biboolkeys[pref]{fam}[mp]{key1,key2}[dft]{key1-fn}{key2-fn} +% \ltxkeys@biboolkeys+[pref]{fam}[mp]{key1,key2}[dft]{key1-fn}{key2-fn} +% {<fallback>} +% <fallback> will be called if input isn't valid (ie, not in the +% set {true | false}. \robust@def*\ltxkeys@biboolkeys{% \ltxkeys@swtrue \ltxkeys@testpl{\ltxkeys@testopt@e\ltxkeys@biboolkeys@a{}}% } \robust@def*\ltxkeys@newbiboolkeys{\ltxkeys@chdeftrue\ltxkeys@biboolkeys} +% #1: <mp> +% #2: keys +% #3: default value \robust@def*\ltxkeys@biboolkeys@a#1#2[#3]{% \ifboolTF{ltxkeys@pl}\ltxkeys@biboolkeys@c\ltxkeys@biboolkeys@b {#1}{#2}{#3}% } +% #1: <mp> +% #2: keys +% #3: default value +% #4: callback for primary boolean key +% #5: callback for secondary boolean key \robust@def*\ltxkeys@biboolkeys@b#1#2#3#4#5{% \ltxkeys@biboolkeys@d{#1}{#2}{#3}% \ltxkeys@tempa{#4}% \ltxkeys@tempb{#5}% } +% #1: <mp> +% #2: keys +% #3: default value +% #4: callback for primary boolean key +% #5: callback for secondary boolean key +% #6: callback if user-supplied value isn't valid \robust@def*\ltxkeys@biboolkeys@c#1#2#3#4#5#6{% \ltxkeys@biboolkeys@d{#1}{#2}{#3}% \ltxkeys@tempa{#4}{#6}% \ltxkeys@tempb{#5}{#6}% } +% #1: <mp> +% #2: keys +% #3: default value \robust@def*\ltxkeys@biboolkeys@d#1#2#3{% \ltxkeys@ifeltcountTF[,](=)\tw@{#2}{}{% \ltxkeys@error{Biboolean keys '#2' not equal to 2}\ltxkeys@ehc @@ -1355,16 +1463,26 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ {\ltxkeys@keys\ltxkeys@nil{\ltxkeys@ttpref}{\ltxkeys@tfam}}% \undefcs\ltxkeys@tkeya } +% #1: primary key +% #2: secondary key +% #3: <mp> +% #4: default value +% #5: key prefix +% #6: key family \robust@def\ltxkeys@biboolkeys@e#1#2#3#4#5#6{% \ifltxkeys@pl + % For primary key: \long\def\ltxkeys@tempa##1##2{% + % ##1->callback if input is valid, ##2->callback otherwise \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#1}{#1}{#3#1}{#4}{{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#1\ltxkeys@resa}% ##1\relax \ltxkeys@biboolkeys@f{#1}{#2}{#3#1}{#5}{#6}% }{##2}}% }% + % For secondary key: \long\def\ltxkeys@tempb##1##2{% + % ##1->callback if input is valid, ##2->callback otherwise \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#2\ltxkeys@resa}% ##1\relax @@ -1372,14 +1490,18 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }{##2}}% }% \else + % For primary key: \long\def\ltxkeys@tempa##1{% + % ##1->callback if input is valid \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#1}{#1}{#3#1}{#4}{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#1\ltxkeys@resa}% ##1\relax \ltxkeys@biboolkeys@f{#1}{#2}{#3#1}{#5}{#6}% }% }% + % For secondary key: \long\def\ltxkeys@tempb##1{% + % ##1->callback if input is valid \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#2\ltxkeys@resa}% ##1\relax @@ -1389,14 +1511,39 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \fi } \robust@def\ltxkeys@biboolkeys@f#1#2#3#4#5{% + % If #1 is not being called by its twin (#2): \iftogTF{\ltxkeys@hdr#1}{}{% + % Set flag to show that #2 is being set within its twin (#1): \settogtrue{\ltxkeys@hdr#2}% \cptexpandarg{\ltxkeys@setkeys[#4]{#5}}{#2=\thebool@reverse{#3}}% \settogfalse{\ltxkeys@hdr#2}% }% } +%%++ +% \ltxkeys@stylekey[<pref>]{<fam>}[<mp>]{<key>}[<dft>](<deps>){<fn>}. +% The dependants <deps> have the syntax: +% {<keytype>/<keyname>/<dft>/<callback>; another set of dependant; etc}. +% +% <keytype> can be 'ord' (ordinary key), 'cmd' (command key), 'bool' +% (boolean key), or 'choice' (choice key). +% +% If the *-form is used, all undefined dependants will be defined and set +% on the fly as the parent is being set. If the *-form isn't used and +% undefined dependants occur, then an error message will be flagged +% at the time the parent is being set. + +% It is possible to refer to the parent key's name and current value +% (with \parentkey and \parentval) and parent key's callback +% (with full macro name) within <dft> and <callback> of <deps>. +% +% '#1' in the callback of dependant key refers to the current value of +% the dependant key. + \robust@def*\ltxkeys@stylekey{% \ltxkeys@swfalse + % The test for star here is for the 2 types of style key. + % The test for defining a default for the key is at + % \ltxkeys@testopt@f, via \ltxkeys@testopt@e. \ltxkeys@testst{% \cpt@cnta\ifltxkeys@st1\else0\fi\relax \ltxkeys@testopt@e\ltxkeys@stylekey@a{style}% @@ -1447,12 +1594,18 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% } + +% #1: style type, '1' (*-form) or '0' (plain, non-*-form). +% #2: <macro prefix> \robust@def*\ltxkeys@setdependants#1#2{% \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr\ltxkeys@tkey @dependants}% + % If no dependants: \ltxkeys@ifcsemptyTF\ltxkeys@tempa{}{% \cpt@sttrue \expandafter\cpt@csvnormalize \expandafter[\ltxkeys@keyparser]\ltxkeys@tempa + % If we're in \ltxkeys@declarekeys, don't set dependants + % when setting up defaults: \ifboolTF{ltxkeys@dec}{}{% \cptexpandargonce{\ltxkeys@s@tdependants{#1}{#2}}\ltxkeys@tempa }% @@ -1466,9 +1619,12 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@s@td@p@ndants{#1}% }% \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@keyparser]}{#3}% + % We're in a group: so \ifblankTF can be temporarily redefined: \let\ifblankTF\relax \cptpassexpanded{% \endgroup + % If we're in dependant keys, use the user-supplied value + % of parent key to initialize the slave key in \ltxkeys@declarekeys: \noexpand\ltxkeys@deptrue \ifblankTF{\the\toks0}{}% {\ltxkeys@setkeys[\expandcsonce\ltxkeys@ttpref]% @@ -1496,14 +1652,20 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@s@td@pendants#1{% \begingroup \def\key@name{}\def\key@default{}\def\key@macro{}% + % '#1' may come with nested parameters that will make it + % impossible to include '#1' directly in \temp@err. + % So we put '#1' in a token register: \@temptokena{#1}% \def\ltxkeys@splita##1/##2/{% \ifblankTF{##1##2}{% + % No keys to read (remove forward slashes): \ltxkeys@err{Something is wrong with dependant keys}\ltxkeys@ehc \expandafter\gobble@to@sentinel\expandafter \ltxkeys@nil\ltxkeys@keyparser }{% \ltxkeys@trimspaces{##1}\key@type + % To avoid back-linking, a style key can't have another + % style key as a dependant: \expandafter\ltxkeys@striplaststar \key@type\@empty*\@empty\ltxkeys@nil\key@type \xifstrcmpFT\key@type{sty}{}{% @@ -1536,7 +1698,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \edef\key@macro{\unexpanded{##2}}% \ltxkeys@stripdotcode\key@macro }% - \ltxkeys@splita#1/^?/^?/^?/\ltxkeys@nil + \ltxkeys@splita#1/^?^/^?^/^?^/\ltxkeys@nil \let\do\cpt@csexit \cptpassexpanded{% \endgroup @@ -1551,6 +1713,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }{% \cptpassexpanded{% + % Test if the parent was defined with the + % *-form of \ltxkeys@stylekey, ie, if #1=1 or 0: \ifnum\numexpr#1=\@ne \toks1{% \the\toks1\oifblankTF{\the\toks1}{}{\ltxkeys@keyparser}% @@ -1565,6 +1729,20 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% } + +%%++ +% \ltxkeys@choicekey*+![<pref]{<fam>}[<mp>]{<key>}[<bin>]{<alt>}[<dft>]{<f1>}{<f2>} +% If <mp> is absent, then \ltxkeys@choicekey uses \chc<pref>@<family>@<key> +% to hold user input. +% +% When there are no callbacks in <alt> ist has the syntax +% {choice1, choice2, etc}. +% +% But when <alt> has callbacks, it has the syntax: +% {choice1/.code=callback1; choice2/.code=callback2; etc}. +% +% It is possible to refer to the current value of <key> as '#1' in <alt>. +% \robust@def*\ltxkeys@choicekey{% \ltxkeys@swfalse \ltxkeys@suffixcheck{\ltxkeys@teststpl{\ltxkeys@testcl @@ -1574,6 +1752,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \newletcs\ltxkeys@choicekeys\ltxkeys@choicekey \robust@def*\ltxkeys@newchoicekey{\ltxkeys@chdeftrue\ltxkeys@choicekey} \newletcs\ltxkeys@newchoicekeys\ltxkeys@newchoicekey +% #1: <mp> (prefix for user-input holder) name; +% #2: keynames \robust@def*\ltxkeys@choicekey@a[#1]#2{% \edef\ltxkeys@macpref{#1}% \begingroup @@ -1581,10 +1761,13 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \catcode`\;=12\catcode`\.=12 \cpt@testopt{\expandafter\endgroup\ltxkeys@choicekey@b{#1}{#2}}{}% } +% #3: bin +% #4 alt values \robust@def*\ltxkeys@choicekey@b#1#2[#3]#4{% \ifblankTF{#4}{% \ltxkeys@err{Choice key can't have empty nominations}\ltxkeys@ehc }{}% + % Make \ltxkeys@chclist for the choice key: \ltxkeys@makechclist{#4}{0}% \cpt@ifbrack{% \ltxkeys@sttrue\ltxkeys@bracedefault @@ -1593,6 +1776,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@stfalse\ltxkeys@choicekey@c{#1}{#2}{#3}{#4}[]% }% } +% #1: mp, #2: keynames, #3: bin, #4: alt, #5: default \robust@def*\ltxkeys@choicekey@c#1#2#3#4[#5]{% \ltxkeys@commanormalize{#2}\ltxkeys@tempa \edef\ltxkeys@tempa{\unexpanded{{#1}}{\expandcsonce\ltxkeys@tempa}}% @@ -1602,6 +1786,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@tempa{#3}{#4}{#5}% } +% #1: mp, #2: keyname, #3: default \robust@def*\ltxkeys@choicekey@d#1#2#3{% \ltxkeys@findpointers{#2}% \ltxkeys@debug{==}{Choice key '\ltxkeys@tkey' is being defined}% @@ -1613,30 +1798,37 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ {#1\ltxkeys@tkey}{##1}{##2}{##3}% }% } +% #1: mp, #2: keynames, #3: bin, #4: alt, #5: default, #6: cbk \robust@def*\ltxkeys@choicekey@e#1#2#3#4#5#6{% \edef\ltxkeys@loopcbk##1{% \ltxkeys@choicekey@d{#1}{##1}\unexpanded{{#5}}% \noexpand\ltxkeys@resa\unexpanded{{#3}{#4}{{#6}}}% }% \ifinsetTF,{#2}{% - \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \def\ltxkeys@do##1{% + \ltxkeys@loopcbk{##1}% + }% \ltxkeys@parse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% } +% #1: mp, #2: keyname, #3: bin, #4: alt, #5: default, #6: cbk1, #7: cbk2 \robust@def*\ltxkeys@choicekey@f#1#2#3#4#5#6#7{% \edef\ltxkeys@loopcbk##1{% \ltxkeys@choicekey@d{#1}{##1}\unexpanded{{#5}}% \noexpand\ltxkeys@resa\unexpanded{{#3}{#4}{{#6}{#7}}}% }% \ifinsetTF,{#2}{% - \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \def\ltxkeys@do##1{% + \ltxkeys@loopcbk{##1}% + }% \ltxkeys@parse1{#2}% }{% \ltxkeys@loopcbk{#2}% }% } +% #1: keymacro, #2: mp+keyname, #3: bin, #4: alt, #5: cbk \robust@def*\ltxkeys@choicekey@g#1#2#3#4#5{% \ifinsetTF{/.code=}{#4}{% \def\ltxkeys@tempa{\ltxkeys@executechclist}% @@ -1661,9 +1853,13 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ {\expandcsonce\ltxkeys@chclist}\unexpanded{#5}% \expandcsonce\ltxkeys@tempa{\unexpanded{#4}}% }% + % Believe it or not, this is one of the tricks that works: \def\ltxkeys@tempa{\def#1####1}% \expandafter\ltxkeys@tempa\expandafter{#1}% } +% Make the list of valid alternate values of a choice key: +% #1: alt-list (containing choice callbacks) +% #2: caller identifier (0 for defining, 1 for setting key) \robust@def*\ltxkeys@makechclist#1#2{% \begingroup \def\ltxkeys@chclist{}% @@ -1674,15 +1870,17 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempd{##1}{##2}% }% \def\ltxkeys@tempd##1##2{% - \expandafter\ltxkeys@trimspaces\expandafter - {\@gobble##1}\ltxkeys@tempa + \ltxkeys@remdottrimspaces{##1}\ltxkeys@tempa \ifcase#2\relax + % We're defining a choice key: \cptaddtolist*[,]\ltxkeys@chclist\ltxkeys@tempa \or + % We're setting a choice key: \cptexpandarg\lowercase{% \def\noexpand\ltxkeys@tempa{\expandcsonce\ltxkeys@tempa}% \def\noexpand\ltxkeys@tval{\expandcsonce\ltxkeys@tval}% }% + % The comparison must be catcode agonistic: \oifstrcmpTF\ltxkeys@tempa\ltxkeys@tval{% \edef\ltxkeys@chclist{\unexpanded{##2}}% \loopbreak @@ -1710,11 +1908,15 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \postgroupdef\ltxkeys@chclist\endgroup } +% Execute the callback for alternate values of a choice key: +% #1: alt-list (containing choice callbacks) \robust@def*\ltxkeys@executechclist#1{% \begingroup \ltxkeys@makechclist{#1}{1}% \expandafter\endgroup\ltxkeys@chclist } +% #1: key name +% #2: default value \robust@def*\ltxkeys@definedefault#1#2{% \xifstrcmpTF{\detokenize{#2}}{\detokenize{\parentval}}{% \s@expandarg\ltxkeys@trimspaces{#2}\ltxkeys@tempa @@ -1746,7 +1948,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@novalfalse \begingroup \def\ltxkeys@tempa##1=##2\ltxkeys@nil{\endgroup - \s@expandarg\ltxkeys@trimspaces{\@gobble##1}#3% +% \s@expandarg\ltxkeys@trimspaces{\@gobble##1}#3% + \ltxkeys@remdottrimspaces{##1}#3% \let\CurrentVal#3% }% \ltxkeys@tempa.#2\ltxkeys@nil @@ -1758,6 +1961,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@getkeyname#1=\ltxkeys@nil#2% \ltxkeys@getkeyvalue#1=\ltxkeys@nil#3% } +% Keys that must (or not) appear in \usepackage and \RequirePackage: +% \ltxkeys@optionkeys[<prf>]{<fam>}{<keys>} \robust@def*\ltxkeys@optionkeys{% \ltxkeys@notinpkgclserr\ltxkeys@optionkeys \cpt@testst\ltxkeys@opti@nkeys @@ -1804,6 +2009,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@parse1{#2}% } +% Make defined keys option-keys from their <pref> and <fam>. +% The starred (*) variant makes non-option keys. \robust@def*\ltxkeys@makeoptionkeys{% \cpt@teststopt\ltxkeys@m@keoptionkeys{KV}% } @@ -1838,6 +2045,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@testcl{\ltxkeys@testopt@g{emptifyh@ndledkeys}{handled}}% } \robust@def*\ltxkeys@savevaluekeys{% + % \<KV>@<fam>@savevalue@keys is used by pointed keys. \ltxkeys@testopt@g{h@ndledkeys}{savevalue}% } \newletcs\ltxkeys@addsavevaluekeys\ltxkeys@savevaluekeys @@ -1928,8 +2136,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@testsavevaluekey{% - \ltxkeys@debug{==}{Testing if '\ltxkeys@tkey' is a - savevalue key}% + \ltxkeys@debug{==}{Testing if '\ltxkeys@tkey' is a savevalue key}% \ltxkeys@iftkeyinlist{savevaluekeys}{% \ltxkeys@svtrue }{% @@ -1937,6 +2144,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@debug{==}{'\ltxkeys@tkey' is not a savevalue key}% }% } +% Test for option or non-option keys: \robust@def*\ltxkeys@testoptionkey#1{% \begingroup \def\ltxkeys@tempc{\ifstrcmpTF{#1}{non}{not }{}}% @@ -1979,6 +2187,15 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% } + +% Gather keys and their values for use in (declaring +% or defining keys). \key@vals must have been initialized +% by the caller. +% +% #1: default value +% #2: Key macro (for testing if it contains '\ltxkeys@setaliaskey'). +% If the key macro contains '\ltxkeys@setaliaskey', then the key is a +% twin/alias key: \robust@def*\ltxkeys@accumkeyvals#1#2{% \ifblankTF{#1}{% \ltxkeys@twkfalse @@ -1998,20 +2215,37 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \edef\key@vals{% \csliststack,\key@vals\expandcsonce\key@name=% \ifltxkeys@dep + % We're dealing with a dependant key; use the user-supplied value: \expandcsonce\elt \else \ifstrcmpTF{#1}{true}{false}{\expandcsonce\elt}% \fi }% + % Set slave key with master when 'ltxkeys@ssk' is true, whether + % or not the key macro contains '\ltxkeys@setaliaskey': \ifltxkeys@ssk \gletcs\key@vals\key@vals \else + % If the key macro contains '\ltxkeys@setaliaskey', don't include + % it in the list: \ifltxkeys@twk\else \gletcs\key@vals\key@vals \fi \fi \endgroup } +% Define boolean and command keys compactly & robustly: +% 1. \ltxkeys@definekeys[pref]{<fam>}[macropf]{<keyname>=<dft> +% /<callback>; ...}. +% Key default value and macro can be absent, +% but boolean keys must have values (<true> | <false>), +% to be distinguishable from cmd keys. +% 2. Use \ltxkeys@checkchoice or \CheckUserInput to introduce +% choice keys as command keys. +% 3. Ordinary and choice keys can't be introduced directly by +% this command (use \ltxkeys@declarekeys). +% 4. The *-form can be used to define new keys (in the sense +% of \newcommand). \robust@def*\ltxkeys@definekeys{% \begingroup \endlinechar\m@one @@ -2031,6 +2265,10 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \toks@{}% \def\key@vals{}% + % We want \ltxkeys@definekeys to have a slightly different + % syntax to \ltxkeys@declarekeys. So we use '=' here. But + % the equality sign can always be replaced with '/' and + % this won't cause any problems: \def\ltxkeys@splita##1={\ltxkeys@splitc##1/.}% \def\ltxkeys@splitb##1/{\ltxkeys@splitc##1/.}% \def\ltxkeys@splitc##1/##2/##3/##4\ltxkeys@nil{% @@ -2052,7 +2290,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \oifblankTF{\@gobble##2}{% \def\key@default{}% }{% - \s@expandarg\ltxkeys@trimspaces{\@gobble##2}\key@default + \ltxkeys@remdottrimspaces{##2}\key@default }% \edef\key@macro{\unexpanded{##3}}% \ltxkeys@stripdotcode\key@macro @@ -2082,12 +2320,13 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@removedotcode{##1}\ltxkeys@tempa \expandafter\ltxkeys@in\expandafter*\expandafter =\expandafter{\ltxkeys@tempa}{% - \expandafter\ltxkeys@splita\ltxkeys@tempa/^?/^?/\ltxkeys@nil + \expandafter\ltxkeys@splita\ltxkeys@tempa/^?^/^?^/\ltxkeys@nil }{% - \expandafter\ltxkeys@splitb\ltxkeys@tempa/^?/^?/\ltxkeys@nil + \expandafter\ltxkeys@splitb\ltxkeys@tempa/^?^/^?^/\ltxkeys@nil }% }% \cptexpandsecond{\ltxkeys@parse1}{[\ltxkeys@keyparser]}{#4}% + % Define and initialize the keys here directly: \cptexpandsecond\endgroup{% \the\toks@ \noexpand\ltxkeys@twkfalse @@ -2099,6 +2338,24 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@decfalse } \new@def*\ltxkeys@badkeytypes{} +% Robustly define keys of all types by one command: +% 1. \ltxkeys@declarekeys[pref]{<fam>}[macropf]{<keytype>/<keyname> +% /<dft>/<callback><parser> ...}. +% Key default and macro can be absent. +% 2. keytype = <ord> | <cmd> | <sty> | <sty*> | <bool> | <choice>. +% 3. Choice keys must have their names associated with +% their admissible values in the format <keyname.chclist>. +% 4. * -> We're defining new keys (in the sense of \newcommand). +% +% Example: +% \ltxkeys@declarekeys*[KV]{<fam>}[mp@]{% +% cmd/keya/mm/\def\x##1{##1*#1*##1}; +% bool/keyb; +% sty/keyc/xxx/\def\y##1{##1yyy#1}; +% sty*/keyd/mm/\def\y##1{##1#1}/cmd>keye>#1>\def\z####1{####1+##1+####1} +% } +% Notice the >...> for the dependant key attributes. +% \robust@def*\ltxkeys@declarekeys{% \begingroup \endlinechar\m@one @@ -2124,7 +2381,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \toks@{}% \def\ltxkeys@splita##1/##2/{% \ifescapedTF{##1}{% - \ltxkeys@err{Key type can't be a macro: '\detokenize{##1}'} + \ltxkeys@err{Key type can't be a macro: '\detokenize{##1}'}% \ltxkeys@ehc }{}% \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name}% @@ -2142,11 +2399,11 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@ehc \fi \ifx\key@name\@empty - \ltxkeys@err{Empty key name in \string\ltxkeys@declarekeys} + \ltxkeys@err{Empty key name in \string\ltxkeys@declarekeys}% \ltxkeys@ehc \fi \ltxkeys@ifrejname{% - \ltxkeys@err{Wrong syntax for \string\ltxkeys@declarekeys} + \ltxkeys@err{Wrong use syntax for \string\ltxkeys@declarekeys}% \ltxkeys@ehc }% \ifltxkeys@inkeycmd @@ -2247,11 +2504,12 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% \ifdefTF\ltxkeys@keyparser{% - \stripallouterbracesincs\ltxkeys@keyparser + \ltxkeys@stripallouterbracesincs\ltxkeys@keyparser }{% \def\ltxkeys@keyparser{;}% }% \ifblankTF{#1}{% + % No 'onekeytype': \edef\ltxkeys@tempa{\unexpanded{#5}}% }{% \def\ltxkeys@tempa{}% @@ -2265,7 +2523,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \def\ltxkeys@do##1{% \ifblankTF{##1}{}{% - \ltxkeys@splita##1/^?/^?/^?/^?/\ltxkeys@nil + \ltxkeys@splita##1/^?^/^?^/^?^/^?^/\ltxkeys@nil }% }% \cptexpandsecond{\ltxkeys@parse0} @@ -2278,6 +2536,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ifx\ltxkeys@badkeytypes\@empty\else \cpt@err{Invalid key types '\ltxkeys@badkeytypes'}\ltxkeys@ehc \fi + % Initialize keys: \ltxkeys@ifcsemptyTF\key@vals{}{% \cptexpandargonce{\ltxkeys@setkeys[#2]{#3}}\key@vals }% @@ -2290,7 +2549,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ } \robust@def\ltxkeys@declarekeys@e#1{% \ifblankTF{#1}{% - \def\key@dependants{}\cpt@gobbletorelax + \def\key@dependants{}\cptgobbletorelax }{}% \begingroup \ifinsetTF{>}{#1}{}{% @@ -2318,7 +2577,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \def\key@dependants{}% \def\ltxkeys@do##1{% - \ltxkeys@splita##1>^?>^?>^?>\ltxkeys@nil + \ltxkeys@splita##1>^?^>^?^>^?^>\ltxkeys@nil }% \ltxkeys@parse1[,]{#1}% \postgroupdef\key@dependants\endgroup @@ -2350,7 +2609,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempa#2/\unexpanded{##1}% }% }% - \cptexpandsecond{\def\ltxkeys@tempa{}\ltxkeys@parse1} + \cptexpandsecond{\def\ltxkeys@tempa{}\ltxkeys@parse1}% {[\ltxkeys@keyparser]{\expandcsonce\ltxkeys@tempa}}% }% \cptexpandsecond{\endgroup\csn@edef} @@ -2407,7 +2666,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \def\ltxkeys@tempa{}% \def\ltxkeys@do##1{% - \ltxkeys@splita##1/^?/^?/^?/^?/\ltxkeys@nil + \ltxkeys@splita##1/^?^/^?^/^?^/^?^/\ltxkeys@nil }% \cptexpandsecond{\ltxkeys@parse1} {[\ltxkeys@keyparser]{\expandcsnonce{xfamilykeys@id@#1}}}% @@ -2441,19 +2700,21 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \ltxkeys@splitkeyval##1\ltxkeys@nil\ltxkeys@tkey\ltxkeys@tval \ifcsndefFT{\ltxkeys@hdr\ltxkeys@tkey}{% - \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined.} + \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined.}% \ltxkeys@ehc }{% - \ifcsndefTF{@\ltxkeys@hdr#1setkeys}{}{% - \cptemptifycsn{@\ltxkeys@hdr#1setkeys}% + \ifcsndefTF{\ltxkeys@hdr#1setkeys@alreadysaved}{}{% + \csn@def{\ltxkeys@hdr#1setkeys@alreadysaved}{}% }% - \xifinsetTF{,\cptoxdetok\ltxkeys@tkey,} - {,\cptsxdetok{\usename{@\ltxkeys@hdr#1setkeys},}}{% + % You can't enter the same key twice in either + % preset or post-set lists in the same family and prefix: + \xifinsetTF{,\cptoxdetok\ltxkeys@tkey,}% + {,\cptsxdetok{\usename{\ltxkeys@hdr#1setkeys@alreadysaved},}}{% \ltxkeys@err{Double entry for key '\ltxkeys@currtriple' in\MsgBrk #1set key list}\ltxkeys@ehc }{% \edef\ltxkeys@rsvda{\csliststack,\ltxkeys@rsvda - \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{} + \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{}% {=\expandcsonce\ltxkeys@tval}}% \edef\ltxkeys@rsvdb{\csliststack,\ltxkeys@rsvdb \expandcsonce\ltxkeys@tkey}% @@ -2461,21 +2722,24 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% }% \ltxkeys@parse3{#2}% + % '...@alreadysaved' saves key names irrespective + % of value, for testing if a preset key is being saved twice: \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% \ifcsndefTF{\ltxkeys@hdr#1setkeys}{% \cptpassexpanded{% \cptfiltermergekv\noexpandcsn{\ltxkeys@hdr#1setkeys}% {\expandcsonce\ltxkeys@rsvda}\noexpand\nofilter - \cptfiltermergecsv\noexpandcsn{@\ltxkeys@hdr#1setkeys} + \cptfiltermergecsv\noexpandcsn{\ltxkeys@hdr#1setkeys@alreadysaved}% {\ltxkeys@rsvdb}\noexpand\nofilter }% }{% \csn@edef{\ltxkeys@hdr#1setkeys}{\expandcsonce\ltxkeys@rsvda}% - \csn@edef{@\ltxkeys@hdr#1setkeys}{\expandcsonce\ltxkeys@rsvdb}% + \csn@edef{\ltxkeys@hdr#1setkeys@alreadysaved}% + {\expandcsonce\ltxkeys@rsvdb}% }% \ifltxkeys@cl \globalizecsn{\ltxkeys@hdr#1setkeys}% - \globalizecsn{@\ltxkeys@hdr#1setkeys}% + \globalizecsn{\ltxkeys@hdr#1setkeys@alreadysaved}% \fi }% } @@ -2488,18 +2752,18 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \def\ltxkeys@do##1{% \ltxkeys@splitkeyval##1=\ltxkeys@nil\ltxkeys@tkey\ltxkeys@tval \ifcsndefFT{\ltxkeys@hdr\ltxkeys@tkey}{% - \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined} + \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined}% \ltxkeys@ehc }{% \xifinsetTF{,\cptoxdetok\ltxkeys@tkey=\cptoxdetok\ltxkeys@tval,}% {,\cptsxdetok{\usename{\ltxkeys@hdr#1setkeys}},}{% \edef\ltxkeys@rsvda{\csliststack,\ltxkeys@rsvda - \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{} + \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{}% {=\expandcsonce\ltxkeys@tval}}% \edef\ltxkeys@rsvdb{\csliststack,\ltxkeys@rsvdb \expandcsonce\ltxkeys@tkey}% }{% - \ltxkeys@err{Key '\ltxkeys@currtriple' not a #1set key} + \ltxkeys@err{Key '\ltxkeys@currtriple' not a #1set key}% \ltxkeys@ehc }% }% @@ -2507,14 +2771,14 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@parse3{#2}% \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% \cptpassexpanded{% - \cptfilterremovekv\noexpandcsn{\ltxkeys@hdr#1setkeys} + \cptfilterremovekv\noexpandcsn{\ltxkeys@hdr#1setkeys}% {\expandcsonce\ltxkeys@rsvda}\noexpand\nofilter - \cptfilterremovecsv\noexpandcsn{@\ltxkeys@hdr#1setkeys} + \cptfilterremovecsv\noexpandcsn{\ltxkeys@hdr#1setkeys@alreadysaved}% {\ltxkeys@rsvdb}\noexpand\nofilter }% \ifltxkeys@cl \globalizecsn{\ltxkeys@hdr#1setkeys}% - \globalizecsn{@\ltxkeys@hdr#1setkeys}% + \globalizecsn{\ltxkeys@hdr#1setkeys@alreadysaved}% \fi }% }% @@ -2525,9 +2789,12 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ and family '\ltxkeys@tfam'}\ltxkeys@ehc }{% \usename{\ifltxkeys@cl g\fi undefcsn}{\ltxkeys@hdr#1setkeys}% - \usename{\ifltxkeys@cl g\fi undefcsn}{@\ltxkeys@hdr#1setkeys}% + \usename{\ifltxkeys@cl g\fi undefcsn}% + {\ltxkeys@hdr#1setkeys@alreadysaved}% }% } +% Set a main key after setting its twin/alias. This is NOT +% related to dependant or style keys: \robust@def*\ltxkeys@setaliaskey#1{% \ltxkeys@commanormalize{#1}\ltxkeys@tempa \xifinsetTF{,}{\cptoxdetok\ltxkeys@tempa}{% @@ -2573,6 +2840,8 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@tempa#1..\ltxkeys@nil } +% #1: key prefix +% #2: key family \robust@def*\ltxkeys@setinitialkeyvals#1#2{% \ltxkeys@initrue \ifcsndefFT{#1@#2@initialkeyvals}{}{% @@ -2585,6 +2854,15 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@inifalse } + +% \ltxkeys@initializekeys[<prefixes>]{<fams>}[<na>] +% 1. Preset all keys defined in families <fams>; +% ignore keys listed in <na>. <na> comes from key-val +% pairs that the user wants to use as current values +% of keys. Their keys are to be ignored when setting +% up defaults. +% 2. The key-val list to be preset comes from the macros +% \<pref>@<fam>@initialkeyvals: \robust@def*\ltxkeys@initializekeys{% \cpt@testopt\ltxkeys@in@tializekeys{KV}% } @@ -2614,6 +2892,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ {[\ltxkeys@keynames]{\expandcsonce\ltxkeys@resa}}% \ltxkeys@inifalse } +% Remove disabled and pox keys: \robust@def*\ltxkeys@remdispox#1{% \begingroup \letcstocsn\ltxkeys@tempd{\ltxkeys@hdr disabledkeys}% @@ -2621,7 +2900,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \letcstocsn\ltxkeys@tempe{\ltxkeys@hdr poxkeys}% \ifdefTF\ltxkeys@tempe{}{\def\ltxkeys@tempe{}}% \ltxkeys@ifcsemptyTF\ltxkeys@tempd{% - \ltxkeys@ifcsemptyTF\ltxkeys@tempe\cpt@gobbletorelax\relax + \ltxkeys@ifcsemptyTF\ltxkeys@tempe\cptgobbletorelax\relax }{}% \edef\ltxkeys@tempd {\expandcsonce\ltxkeys@tempd,\expandcsonce\ltxkeys@tempe}% @@ -2635,6 +2914,10 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \cpt@relax \postgroupdef#1\endgroup } +% \ltxkeys@launchkeys*+[<prefix>]{<fams>}{<curr>} +% 1. First preset all family keys before setting keys in <curr>. +% 2. <curr> are the key-vals to be set in the current run; they +% will be ignored when initializing the keys of families <fams>: \robust@def*\ltxkeys@launchkeys{% \ltxkeys@teststpl{\cpt@testopt\ltxkeys@l@unchkeys{KV}}% } @@ -2649,7 +2932,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }{}% \cptexpandsecond\ltxkeys@in@ti@lizekeys {{\ltxkeys@prefs}{\ltxkeys@fams}}[#3]% - \ifblankTF{#3}\cpt@gobbletorelax\relax + \ifblankTF{#3}\cptgobbletorelax\relax \begingroup \def\ltxkeys@resa{}% \def\ltxkeys@do##1{% @@ -2828,7 +3111,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \MsgBrk in families '\ltxkeys@fams'}\ltxkeys@ehc \fi }{% - \xifinsetTF{,\ltxkeys@tkey,}{,\ltxkeys@nakeys,}{}{% + \oifinset@sp@TF,\ltxkeys@tkey\ltxkeys@nakeys{}{% \ltxkeys@setkeys@d }% }% @@ -2942,7 +3225,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \edef\reserved@e{\ltxkeys@currtriple,\InnocentVal}% \@onelevel@sanitize\reserved@e \letcstocsn\reserved@f{\ltxkeys@hdr executedkeys}% - \xifinsetTF{*\reserved@e*}{*\reserved@f*}{% + \oifinset@sp@TF*\reserved@e\reserved@f{% \ltxkeys@debug{!!}{Key '\ltxkeys@currtriple' multiply set with same value}% }{% @@ -2961,7 +3244,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ifcsndefTF{\ltxkeys@hdr savevaluekeys}{\ltxkeys@testsavevaluekey}{}% }% \ifboolTF{ltxkeys@sv}{% - \ltxkeys@addtop@intedkeys{savevalue}\ltxkeys@tkey\ltxkeys@tval + \ltxkeys@addtosavedvalue\ltxkeys@tkey\ltxkeys@tval }{}% \ifboolTF{ltxkeys@noval}{% \ifcsndefTF{\ltxkeys@hdr needvaluekeys}{\ltxkeys@testneedvaluekey}{}% @@ -3037,7 +3320,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \edef\ltxkeys@tempc{\unexpanded{##2}}% \ltxkeys@ifxTF\ltxkeys@tempc\ltxkeys@nnil\@secondoftwo\@firstoftwo }% - \cptsevenxp\reserved@a\usename{@\ltxkeys@hdr savevaluekeys}% + \cptsevenxp\reserved@a\usename{\ltxkeys@hdr @savedvaluelist}% #1{\ltxkeys@nil}\ltxkeys@nil } \robust@def*\ltxkeys@replacepointers#1{% @@ -3119,29 +3402,33 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@getinnovalnopad{\ltxkeys@swafalse\ltxkeys@g@tinnoval} \robust@def*\ltxkeys@g@tinnoval{% \begingroup - \ltxkeys@ifxTF\ltxkeys@tval\@empty{% + \ltxkeys@ifcsemptyTF\ltxkeys@tval{% \def\InnocentVal{???}% }{% + \@tempcnta\z@pt \def\InnocentVal{}% \def\ltxkeys@tempa{\\}% - \def\@do##1##2##3##4##5##6##7##8##9\@@{% - \def\siso@do####1{% - \def\reserved@a{####1}% - \edef\InnocentVal{% - \InnocentVal - \ifx\reserved@a\ltxkeys@tempa - \ifltxkeys@swa\@space\fi - \else - \if\reserved@a\cpt@leftbracechar[\else - \if\reserved@a\cpt@rightbracechar]\else####1\fi + \def\do##1{% + \def\reserved@a{##1}% + \ltxkeys@ifxTF\reserved@a\ltxkeys@nnil{}{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta<20\relax + \edef\InnocentVal{% + \InnocentVal + \ifx\reserved@a\ltxkeys@tempa + \ifltxkeys@swa\@space\fi + \else + ##1% \fi - \fi - }% + }% + \else + \def\do####1\ltxkeys@nil{}% + \fi + \do }% - \siso@@loop{##1##2##3##4##5##6##7##8}% }% - \expandafter\@do\detokenize\expandafter - {\ltxkeys@tval}\\\\\\\\\\\\\\\\\\\@@ + \expandafter\do\detokenize\expandafter + {\ltxkeys@tval}\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ltxkeys@nil }% \postgroupdef\InnocentVal\endgroup } @@ -3349,16 +3636,25 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \cpt@testfam{\ltxkeys@d@cl@r@opti@n{#1}}% } \robust@def*\ltxkeys@d@cl@r@opti@n#1<#2>{\ltxkeys@tempa[#1]{#2}} + \robust@def*\ltxkeys@declaremultitypeoptions{% - \cpt@teststopt\ltxkeys@d@claremultitypeoptions{KV}% + \cpt@testst\ltxkeys@d@claremultitypeoptions } \newletcs\declaremultitypeoptions\ltxkeys@declaremultitypeoptions -\robust@def*\ltxkeys@d@claremultitypeoptions[#1]{% - \cpt@testfam{\ltxkeys@d@cl@remultitypeoptions{#1}}% +\robust@def*\ltxkeys@d@claremultitypeoptions{% + \cpt@testpnopt\ltxkeys@d@cl@remultitypeoptions{}% } -\robust@def*\ltxkeys@d@cl@remultitypeoptions#1<#2>{% - \cptsafeactivesedef\reserved@b{#2}% - \cptexpanded{\ltxkeys@declarekeys\ifcpt@st*\fi[#1]{\reserved@b}}% +\robust@def*\ltxkeys@d@cl@remultitypeoptions(#1){% + \cpt@testopt{\ltxkeys@d@cl@rem@ltitypeoptions{#1}}{KV}% +} +\robust@def*\ltxkeys@d@cl@rem@ltitypeoptions#1[#2]{% + \cpt@testfam{\ltxkeys@d@cl@rem@ltitypeopti@ns{#1}{#2}}% +} +\robust@def*\ltxkeys@d@cl@rem@ltitypeopti@ns#1#2<#3>{% + \cptexpanded{% + \ltxkeys@declarekeys\ifcpt@st*\fi + \iflacus#1\dolacus\else(#1)\fi[#2]{#3}% + }% } \robust@def*\ltxkeys@executeoptions#1{% \ltxkeys@nostarform{#1}\ltxkeys@executeoptions @@ -3396,6 +3692,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \reserved@a }% } + \def\ltxkeys@processedoptions{} \robust@def*\ltxkeys@processoptions{% \ifcsndefTF{\@currname @\@currext @ltxkeys@beginprocessopt}{% @@ -3619,7 +3916,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@err{Number of delimiters exceeds number of parameters}\ltxkeys@ehc \fi - \xifinsetTF{,\expandcsonce\ltxkeys@tempa,} + \xifinsetTF{,\expandcsonce\ltxkeys@tempa,}% {,1,2,3,4,5,6,7,8,9,}{}{% \ltxkeys@err{Invalid delimiter syntax: \MsgBrk no digit [1-9] found before @@ -3683,6 +3980,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ifkeyval##1\then\expandafter\iofii\else\expandafter\iiofii\fi }% \long\def\reserved@a##1##2\ltxkeys@nil{% + % \ifswitch won't work here: \ifcondTF\if##1\fi{% ##2% }{% @@ -3838,6 +4136,44 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ } \ltxkeys@everyeoe\ignorespacesafterend +\robust@def*\setvarvalues{\cpt@testopt\ltxkeys@setvarvalues{var@subfam}} +\robust@def*\ltxkeys@setvarvalues[#1]#2{\pathkeys{pathkeys@var@fam/#1/set:#2}} +\new@def*\getvarvalue{\cpt@newxtestopt\ltxkeys@getvarvalue{var@subfam}} +\new@def*\ltxkeys@getvarvalue[#1]#2{\pathkeysval{pathkeys@var@fam/#1/#2}} +\robust@def*\ltxkeys@declarevariables{% + \cpt@testopt\ltxkeys@d@clarevariables{var@subfam}% +} +\robust@def*\ltxkeys@d@clarevariables[#1]#2{% + \begingroup + \def\elt##1{\oifstrcmpTF{^?^}{##1}{}{/\expandcsonce##1}}% + \cptdocommalist{#2}{% + \ltxkeys@d@cl@revariables##1=^?^=^?^=\ltxkeys@nil + }% + \cptexpanded{\endgroup + \pathkeys{pathkeys@var@fam/#1/define*:\expandcsonce\key@list}% + }% +} +\robust@def*\ltxkeys@d@cl@revariables#1={% + \def\reserved@a##1={% + \def\reserved@a####1=####2\ltxkeys@nil{% + \ltxkeys@trimspaces{#1}\reserved@a + \ltxkeys@remdottrimspaces{##1}\reserved@b + \ltxkeys@remdottrimspaces{####1}\reserved@c + \cptexpanded{% + \cptgaddtolist[;]\noexpand\key@list{% + \cptexpandbracenext{\cptifcasse\ifstrcmpTF}\reserved@a + {true}{bool}{false}{bool}% + \elseif + cmd% + \endif + /\expandcsonce\reserved@a\elt\reserved@b\elt\reserved@c + }% + }% + }% + \reserved@a.% + }% + \reserved@a.% +} \robust@def*\ltxkeys@emergencystop{% \immediate\write\sixt@@n{OK, I'm exiting now.}% \interactionmode\z@pt @@ -3870,7 +4206,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ value '\InnocentVal' ignored.}% } \ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{keyparser}[{;}]{% - \stripallouterbracesincs\ltxkeys@keyparser + \ltxkeys@stripallouterbracesincs\ltxkeys@keyparser } \ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{% \needvalue{keydepthlimit}% @@ -3887,7 +4223,7 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ }{% \ltxkeys@setaliaskey{keydepthlimit}% } -\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{pathkeys}{% +\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{pathkeys}[true]{% \ifltxkeys@pathkeys \ltxkeys@afterprocessoptions{\RequirePackage{pathkeys}}% \fi @@ -3899,7 +4235,9 @@ $Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ltxkeys@executeoptions[KV]<ltxkeys> {keyparser,keydepthlimit=4}\relax \ltxkeys@processoptions*[KV]<ltxkeys>\relax + \cpt@optioncleanup\ltxkeys@processedoptions + \robust@def*\ltxkeys@options#1{% \ifblankTF{#1}{}{\ltxkeys@setkeys[KV]{ltxkeys}{#1}}% } |