diff options
author | Karl Berry <karl@freefriends.org> | 2011-11-25 00:12:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-11-25 00:12:36 +0000 |
commit | 5d91a4309dbff9d6757412edf6618f731fef9809 (patch) | |
tree | d181a66a46502d2d9c58145a3e5b96663f359654 /Master/texmf-dist/tex/latex | |
parent | 0ad65f7beaddd4e930a52720af50fa3aa6ba5958 (diff) |
ltxkeys 0.0.2 (20nov11)
git-svn-id: svn://tug.org/texlive/trunk@24653 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty | 3304 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ltxkeys/pathkeys.sty | 615 |
2 files changed, 3093 insertions, 826 deletions
diff --git a/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty b/Master/texmf-dist/tex/latex/ltxkeys/ltxkeys.sty index a1ff1d3b98a..7b735cc143c 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.1, July 2011. % +% This is file 'ltxkeys.sty', version 0.0.2, October 2011. % % % % This package and accompanying files may be distributed and/or % % modified under the conditions of the LaTeX Project Public License, % @@ -20,87 +20,333 @@ % % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% -\RequirePackage{catoptions}[2011/07/30] +\@ifpackageloaded{catoptions}{% + \@ifpackagelater{catoptions}{2011/10/22}{}{% + \@latex@error{Loaded version of catoptions package is + not current}\@ehc + }% +}{% + \RequirePackage{catoptions}[2011/10/22]% +} \UseNormalCatcodes -\StyleFilePurpose{Robust and fast key-value parser} +\StyleFilePurpose{A robust and fast key-value parser (AM)} \StyleFileRCSInfo -$Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ +$Id: ltxkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ \ProvidesPackage{ltxkeys}[\StyleFileInfo] -\NeedsTeXFormat{LaTeX2e}[1996/12/01] +\NeedsTeXFormat{LaTeX2e}[2005/12/01] \SetStyleFileMessages[ltxkeys@]{info}{warn}{err} +\catcode`\&=3 +\catcode`\^=3 +\cpt@setupsafeactivesedef +\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} +\newletcs\ltxkeys@else\else +\newletcs\ltxkeys@fi\fi +\new@def*\ltxkeys@ehc{% + \ifx\protect\string\ltxkeys@afterfi + A serious error has been ecountered.\MsgBrk + Try typing <return>\space to proceed.\MsgBrk + If that fails, type X and then <return>\space to quit. + \ltxkeys@fi +} +\robust@def*\ltxkeys@specialhandler{% + \cpt@testopt\ltxkeys@sp@cialhandler{}% +} +\robust@def*\ltxkeys@sp@cialhandler[#1]#2{% + \begingroup + \toks1{\endgroup\newcsnpdef*{#1@#2@handler}##1##2}% + \def\reserved@a{\the\toks\expandafter1\expandafter{\the\toks0}}% + \afterassignment\reserved@a\toks0=% +} +\newletcs\ltxkeys@nil\relax +\new@def*\ltxkeys@nnil{\ltxkeys@nil} +\new@def*\ltxkeys@quark{\@gobble\ltxkeys@quark} +\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{% + \expandafter\cptswap\cpt@car#1\ltxkeys@quark\car@nil + {\expandafter\ltxkeys@ifxTF\cpt@car#2\relax\car@nil}% +} +\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@error#1#2{\ltxkeys@err{#1}{#2}\@gobble} -\robust@def*\ltxkeys@vwarn#1{% - \ifltxkeys@verbose\wlog{[ltxkeys debug] -- #1.}\fi +\robust@def*\ltxkeys@debug#1#{% + \ifboolTF{ltxkeys@tracingkeys}{% + \ifstrcmpTF{#1}{*}{% + \cpt@sttrue\ltxkeys@d@bug + }{% + \cpt@stfalse\ltxkeys@d@bug + }% + }{% + \@gobbletwo + }% } -\robust@def*\ltxkeys@vinfo#1{% - \ifltxkeys@verbose\wlog{[ltxkeys debug] ++ #1.}\fi +\robust@def*\ltxkeys@d@bug#1#2{% + \wlog{\ifcpt@st^^J\fi ltxkeys debug [#1] #2.}% } -\newvariables{if}[ltxkeys@]{break,st,pl,sw,sv,nv,noval,pxop,exop,% - inpreset,kf,rm,ssk,dec,dep,twk,verbose,swa}[false] +\newvariables{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] -\robust@def*\SetSlaveWithMaster{\global\ltxkeys@ssktrue} -\robust@def*\SetNoSlaveWithMaster{\global\ltxkeys@sskfalse} -\SetNoSlaveWithMaster +\newvariables{switch}{infdpointers,infdp@inters}[false] \newvariables{count}[ltxkeys@]{csvdepth,keydepth}[\z@pt] -\newletcs\ltxkeys@nil\relax -\new@def*\ltxkeys@nnil{\ltxkeys@nil} -\ifdefTF\cpt@documentclass{}{% - \ltxkeys@err{No \string\documentclass}\@ehc - \emptifycsset{\cpt@documentclass,\cpt@classoptionslist}% +\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 +\robust@def*\ltxkeys@getdocumentclass{% + \def\csv@do##1{% + \filename@parse{##1}% + \ifx\filename@ext\@clsextension + \ifcsndefFT{opt@\filename@area\filename@base.\filename@ext}{}{% + \xdef\ltxkeys@documentclass{% + \filename@area\filename@base.\filename@ext + }% + \loopbreak + }% + \fi + }% + \csv@@parse*\@filelist + \ifdefTF\ltxkeys@documentclass{}{% + \ltxkeys@debug{==}{'ltxkeys' package loaded before + \string\documentclass: \MsgBrk no problem}% + }% +} +\cptpassunexpanded{% + \ifdefFT\@filelist{}{% + \ltxkeys@ifxTF\@filelist\@gobble{}{% + \ltxkeys@ifcsemptyTF\@filelist{}\ltxkeys@getdocumentclass + }% + }% + \ifdefFT\ltxkeys@documentclass{% + \let\ltxkeys@classoptionslist\@empty + }{% + \ifdefFT\@classoptionslist{}{% + \ltxkeys@ifcsemptyTF\@classoptionslist{}{% + \kv@@normalize*\@classoptionslist + }% + }% + \let\ltxkeys@classoptionslist\@classoptionslist + \def\csv@do##1{% + \ifinsetTF{=}{##1}{}{% + \cptgaddtolist\@classoptionslist{##1}% + }% + }% + \cptexpandbracenext + {\def\@classoptionslist{}\csv@@loop}\@classoptionslist + \def\@fileswith@ptions##1[##2]##3{% + \edef\ltxkeys@tempa{\cptcommanormalize{##3}}% + \cptfor xkeyval,kvoptions,catoptions\dofor{% + \xifinsetFT{,####1,}{,\ltxkeys@tempa,}{}{% + \let\@classoptionslist\ltxkeys@classoptionslist + \forbreaktrue + }% + }% + \cpt@ifbrack{\@fileswith@pti@ns##1[##2]##3}% + {\@fileswith@pti@ns##1[##2]##3[]}% + }% + }% +} +\robust@def*\ltxkeys@testst#1{% + \cpt@ifstar{\ltxkeys@sttrue#1}{\ltxkeys@stfalse#1}% +} +\robust@def*\ltxkeys@testpl#1{% + \cpt@ifplus{\ltxkeys@pltrue#1}{\ltxkeys@plfalse#1}% +} +\robust@def*\ltxkeys@testcl#1{% + \cpt@ifclam{\ltxkeys@cltrue#1}{\ltxkeys@clfalse#1}% } -\robust@def*\ltxkeys@testst#1{\cpt@ifstar{\ltxkeys@sttrue#1}{\ltxkeys@stfalse#1}} -\robust@def*\ltxkeys@testpl#1{\cpt@ifplus{\ltxkeys@pltrue#1}{\ltxkeys@plfalse#1}} \robust@def*\ltxkeys@teststpl#1{\ltxkeys@testst{\ltxkeys@testpl{#1}}} \robust@def*\ltxkeys@state{% - \ltxkeys@keys,\ltxkeys@prefs,\ltxkeys@fams,\ltxkeys@nakeys,\ltxkeys@tpref,% - \ltxkeys@ttpref,\ltxkeys@tfam,\ltxkeys@tkey,\ltxkeys@tval,\ifltxkeys@st,% - \ifltxkeys@pl,\ifltxkeys@kf,\ifltxkeys@pxop,\ifltxkeys@exop,\CurrentKeyval,% - \CurrentKey,\CurrentVal -} -\robust@def*\ltxkeys@trimspaces{\begingroup\ltxkeys@tr@mspaces} -\robust@def*\ltxkeys@trimspacesincs#1{\s@expandarg\ltxkeys@trimspaces{#1}#1} -\defpass\reserved@a#1{% - \long\def\ltxkeys@tr@mspaces##1##2{% - \edef\reserved@a{% - \expandcsonce{\romannumeral-`\q - \ltxkeys@trimspace.##1\trimsp@nil#1\trimsp@nil}% - }% - \ifxTF##2\reserved@a{% - \cptpassacross##2\endgroup - }{% - \let##2=\reserved@a - \expandafter\ltxkeys@tr@mspaces\expandafter{##2}##2% + \ltxkeys@keys,\ltxkeys@prefs,\ltxkeys@fams,\ltxkeys@nakeys, + \ltxkeys@tpref,\ltxkeys@ttpref,\ltxkeys@tfam,\ltxkeys@tkey, + \ltxkeys@tval,\ifltxkeys@st,\ifltxkeys@pl,\ifltxkeys@cl, + \ifltxkeys@kf,\ifltxkeys@pxop,\ifltxkeys@exop,\ifltxkeys@ini, + \CurrentKeyval,\CurrentKey,\CurrentVal +} +\robust@def\ltxkeys@trimspacesincs#1{% + \expandafter\ltxkeys@trimspaces\expandafter{#1}{#1}% +} +\robust@def\ltxkeys@trimspaces#1#2{% + \begingroup + \ifcase\if.\ltxkeys@spcdr#2.0\ltxkeys@nil\else1\fi + \if\expandafter\cpt@car\string#2\car@nil + \@backslashchar0\else1\fi\relax\else + \ltxkeys@err{'\detokenize{#2}' has illegal form}\ltxkeys@ehc + \fi + \ltxkeys@tr@mspaces{#1}{#2}% +} +\long\def\ltxkeys@tr@mspaces#1#2{% + \edef\trimmed{% + \expandcsonce{\romannumeral-`\q\ltxkeys@trimspace.#1& &}% + }% + \ltxkeys@ifxTF#2\trimmed{% + \expandafter\endgroup\expandafter\edef\expandafter + #2\expandafter{\expandafter\unexpanded\expandafter{#2}}% + }{% + \let#2=\trimmed + \expandafter\ltxkeys@tr@mspaces\expandafter{#2}#2% + }% +} +\long\def\ltxkeys@trimspace#1 &{\ltxkeys@tr@mspace#1&} +\long\def\ltxkeys@tr@mspace#1{\expandafter\noexpand\@gobble#1} +\robust@def*\ltxkeys@trimspacesset#1{% + \def\@do##1##2,{% + \ifnot@nil{##1}{\ltxkeys@trimspaces{##1}##2\@do}% + }% + \@do#1,\@nil\@nil,% +} +\new@def*\ltxkeys@iffirstnull#1#2{\ltxkeys@ifcsemptyTF#1{}{#1#2}} +\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@splitb.% }% - \long\def\ltxkeys@trimspace##1#1\trimsp@nil{% - \ltxkeys@tr@mspace##1\trimsp@nil + \def\ltxkeys@splitb##1/{% + \s@expandarg\ltxkeys@trimspaces{\@gobble##1}\key@default + \ltxkeys@splitc.% + }% + \def\ltxkeys@splitc##1/{% + \edef\key@macro{\unexpanded\expandafter{\@gobble##1}}% + \ltxkeys@stripdotcode\key@macro + \ltxkeys@splitd.% }% - \long\def\ltxkeys@tr@mspace##1\trimsp@nil##2{% - \expandafter\noexpand\@gobble##1% + \def\ltxkeys@splitd##1/##2\ltxkeys@nil{% + \s@expandarg\ltxkeys@trimspaces{\@gobble##1}\key@dependants }% -}{ } -\robust@def*\ltxkeys@oneoftwo#1\endgroup{% + \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{^?} +\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% + }% + \reserved@a.##2\ltxkeys@nil + }% + \expandafter\reserved@a#1.\ltxkeys@nil + }{}% +} +\robust@def*\ltxkeys@removedotcode#1#2{% + \ltxkeys@trimspaces{#1}#2% + \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 + \edef#2{\expandcsonce{\@gobble##1}/\expandcsonce\reserved@a}% + }% + \reserved@a.##2\ltxkeys@nil + }% + \expandafter\reserved@a\expandafter.#2.\ltxkeys@nil + }{}% +} +\robust@def*\ltxkeys@in{\cpt@testst\ltxkeys@in@a} +\robust@def*\ltxkeys@in@a#1#2{% + \def\in@@##1#1##2\in@@{% + \ifblankTF{##2}\in@false\in@true + \ifboolTF{cpt@st}{\ifboolTF{in@}}{}% + }% + \in@@#2{\in@@}#1\in@@ +} +\robust@def*\ltxkeys@iffound#1\in#2\then{% + \ltxkeys@trimspaces{#1}\reserved@a + \ltxkeys@trimspaces{#2}\reserved@b + \ltxkeys@stfalse + \cptexpandargonce\ltxkeys@in@a\reserved@a\reserved@b + \ifin@ +} +\robust@def*\ltxkeys@ifchcfd#1\endgroup{% \let\@firstoftwo\relax \let\@secondoftwo\relax \cptpassexpanded{% \endgroup \ifcase#1\relax - \if@boolTF{cpt@choicefd}\@firstoftwo\@secondoftwo + \ifboolTF{cpt@choicefd}\@firstoftwo\@secondoftwo \or - \if@boolTF{cpt@choicefd}\@secondoftwo\@firstoftwo + \ifboolTF{cpt@choicefd}\@secondoftwo\@firstoftwo \else - \ltxkeys@err{Invalid number '#1'}\noexpand\@ehc + \ltxkeys@err{Invalid number '#1'}\ltxkeys@ehc \fi }% } -\robust@def*\ltxkeys@getorder#1#2{% - \def\ltxkeys@order{-1}% +\robust@def*\ltxkeys@getlasttoken#1{% + \def\ltxkeys@resttokens{}% + \ltxkeys@g@tlasttoken#1\ltxkeys@g@tlasttoken + \ltxkeys@g@tlasttoken\ltxkeys@getlasttoken +} +\robust@def*\ltxkeys@g@tlasttoken#1#2{% + \ifx#2\ltxkeys@g@tlasttoken + \edef\ltxkeys@lasttoken{\unexpanded{#1}}% + \def\reserved@a##1\ltxkeys@getlasttoken{}% + \expandafter\reserved@a + \else + \edef\ltxkeys@resttokens + {\expandcsonce\ltxkeys@resttokens\unexpanded{#1}}% + \expandafter\ltxkeys@g@tlasttoken + \fi + #2% +} +\new@def\ltxkeys@stripouterbraces#1#2{% + \romannumeral\expandafter\ltxkeys@str@pouterbraces + \expandafter{\romannumeral\number#1000m}{#2}% +} +\new@def\ltxkeys@str@pouterbraces#1#2{% + \ifbracedTF{#2}{% + \expandafter\ifnullTF\expandafter{\@gobble#2}{% + \expandafter\ifnullTF\expandafter{\@gobble#1}{0 #2}{% + \s@expandarg\ltxkeys@str@pouterbraces{\@gobble#1}#2% + }% + }{0 #2}% + }{0 #2}% +} +\robust@def\ltxstripouterbraces#1#2#3{% + \edef#3{\unexpanded\cptthreexp{\ltxkeys@stripouterbraces{#1}{#2}}}% +} +\robust@def*\ltxkeys@getbasechars{\cpt@teststopt\ltxkeys@g@tchars{1}} +\robust@def*\ltxkeys@g@tchars[#1]#2#3{% \begingroup - \lowercase{\ltxkeys@trimspaces{#1}\ltxkeys@tempa}% + \def#3{}\gdef\ltxkeys@charcount{0}% + \def\siso@do##1{% + \edef#3{#3##1}% + \xdef\ltxkeys@charcount{\the\numexpr\ltxkeys@charcount+1}% + \ifnum\ltxkeys@charcount>#1\relax\loopbreak\fi + }% + \cptexpandarg\siso@@loop + {\ifboolTF{cpt@st}\cptoxdetok\detokenize{#2}}% + \postgroupdef#3\endgroup +} +\robust@def*\ltxkeys@getorder{\cpt@teststopt\ltxkeys@g@torder,} +\robust@def*\ltxkeys@g@torder[#1]#2#3{% + \def\ltxkeys@order{-1}% + \begintoksgroup + \cpt@stchoose{cpt@st}{#3}\ltxkeys@tempa\ltxkeys@getorder + \lowercase{\ltxkeys@trimspaces{#2}\ltxkeys@tempb}% \@tempcnta\z@pt - \toks@{}% \def\ltxkeys@do##1{% - \oifstrcmpFT\ltxkeys@tempa{##1}{}{% + \oifstrcmpFT\ltxkeys@tempb{##1}{}{% \cptexpanded{% \toks@{\def\noexpand\ltxkeys@order{\the\@tempcnta}}% }% @@ -108,55 +354,202 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% \advance\@tempcnta\@ne }% - \ltxkeys@csvparse{#2}% - \expandafter\endgroup\the\toks@ + \ltxkeys@parse*1[;]\ltxkeys@tempa + \endtoksgroup +} +\robust@def*\ltxkeys@ifeltcountTF{\cpt@teststopt\ltxkeys@ifeltcount,} +\robust@def*\ltxkeys@ifeltcount[#1]{% + \cpt@testpnopt{\ltxkeys@ifeltc@unt{#1}}{=}% } -\robust@def*\ltxkeys@ifeltcountTF{\cpt@testopt\ltxkeys@ifeltcount{=}} -\robust@def*\ltxkeys@ifeltcount[#1]#2#3{% +\robust@def*\ltxkeys@ifeltc@unt#1(#2)#3#4{% \begingroup - \@tempcnta\z@pt + \edef\reserved@a{\ifcpt@st*\fi}% + \def\eltnum{0}% \def\ltxkeys@do##1{% - \advance\@tempcnta by1 + \pushnumber\eltnum }% - \ltxkeys@csvloop{#2}% - \aftercsname\endgroup{@\ifnum\@tempcnta#1\numexpr#3% + \expandafter\ltxkeys@parse\reserved@a1[#1]{#4}% + \aftercsname\endgroup{@\ifnum\eltnum#2\numexpr#3% first\else second\fi oftwo}% } -\robust@def*\ltxkeys@nomatcherr{% - \ltxkeys@error{User input '\reserved@e' not in list: - \MsgBrk '\reserved@f'}\@ehc +\robust@def*\ltxkeys@findmatch#1#2#3{% + \def\currmatch{}% + \ltxkeys@trimspaces{#1}\reserved@a + \ltxkeys@f@ndmatch#2,:,\ltxkeys@nil{#3}% +} +\robust@def*\ltxkeys@f@ndmatch#1:#2,#3\ltxkeys@nil#4{% + \ifblankTF{#3}{% + #4% + }{% + \ltxkeys@trimspaces{#1}\reserved@b + \ifx\reserved@a\reserved@b + \edef\currmatch{\unexpanded{#2}}% + \expandafter\@gobble + \else + \expandafter\@iden + \fi + {\ltxkeys@f@ndmatch#3\ltxkeys@nil{#4}}% + }% +} +\robust@def*\ltxkeys@ifcase#1#2{% + \def\currmatch{}% + \ltxkeys@trimspaces{#1}\reserved@a + \ltxkeys@ifc@se#2,:,\ltxkeys@nil +} +\robust@def*\ltxkeys@ifc@se#1:#2,#3\ltxkeys@nil{% + \ifblankTF{#3}{% + \@secondoftwo + }{% + \ltxkeys@trimspaces{#1}\reserved@b + \ltxkeys@ifxTF\reserved@a\reserved@b{% + \edef\currmatch{\unexpanded{#2}}% + \@firstoftwo + }{% + \ltxkeys@ifc@se#3\ltxkeys@nil + }% + }% +} +\robust@def*\ltxkeys@removeelements{\cpt@teststopt\ltxkeys@rem@veelements,} +\robust@def*\ltxkeys@rem@veelements[#1]{% + \cpt@testpnopt{\ltxkeys@rem@veelem@nts{#1}}\@ne +} +\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 + \fi + \iflacus#4\dolacus + \expandafter\cpt@gobbletorelax + \fi + \begingroup + \let\detk\detokenize + \let\if@remvst\ifcpt@st + \ifmacroTF{#3}{}{\cpt@notcserr{#3}}% + \csv@@normalize*[#1]#3% + \def\ltxkeys@remove@a##1{% + \def\ltxkeys@do####1{% + \@tempcnta\z@pt + \def\ltxkeys@remove@a########1##1####1##1########2&{% + \edef#3{\unexpanded{########1##1########2}}% + }% + \def\ltxkeys@remove@b########1{% + \xifinsetTF{##1\detk{####1}##1}{##1\detk{########1}##1}{% + \ltxkeys@remove@a##1########1##1&% + \ifboolTF{@remvst}{% + \s@expandarg\ltxkeys@remove@b#3% + }{% + \advance\@tempcnta\@ne + \ifnumcmpTF\@tempcnta<#2{% + \s@expandarg\ltxkeys@remove@b#3% + }{}% + }% + }{}% + }% + \s@expandarg\ltxkeys@remove@b#3% + }% + \ltxkeys@parse1[##1]{#4}% + \csv@@normalize*[##1]#3% + }% + \s@expandarg\ltxkeys@remove@a{\detk{#1}}% + \postgroupdef#3\endgroup + \cpt@relax + \ltxkeys@ifxFT#3\ltxkeys@tempa +} +\robust@def*\ltxkeys@replaceelements{% + \cpt@teststopt\ltxkeys@r@placeelements,% +} +\robust@def*\ltxkeys@r@placeelements[#1]{% + \cpt@testpnopt{\ltxkeys@r@pl@ceelements{#1}}\@ne +} +\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 + \fi + \iflacus#4\dolacus + \expandafter\cpt@gobbletorelax + \fi + \begingroup + \let\if@replst\ifcpt@st + \ifmacroTF{#3}{}{\cpt@notcserr{#3}}% + \edef\ltxkeys@sublist{\unexpanded{#4}}% + \ltxkeys@n@rmalizecsset[#1]{#3,\ltxkeys@sublist}% + \def\ltxkeys@replace@a##1{% + \def\ltxkeys@replace@a####1####2##1####3&{% + \ltxkeys@r@pl@ceelement[##1](#2)#3{####1}{####2}% + \ifblankTF{####3}{}{\ltxkeys@replace@a####3&}% + }% + \expandafter\ltxkeys@replace@a\ltxkeys@sublist##1&% + \csv@@normalize*[##1]#3% + }% + \s@expandarg\ltxkeys@replace@a{\detokenize{#1}}% + \postgroupdef#3\endgroup + \cpt@relax + \ltxkeys@ifxFT#3\ltxkeys@tempa +} +\robust@def\ltxkeys@r@pl@ceelement[#1](#2)#3#4#5{% + \begingroup + \@tempcnta\z@pt + \def\ltxkeys@replace@a##1#1#4#1##2&{% + \edef#3{\unexpanded{##1#1#5#1##2}}% + }% + \def\ltxkeys@replace@b##1{% + \xifinsetTF{#1\detokenize{#4}#1}{#1\detokenize{##1}#1}{% + \ltxkeys@replace@a#1##1#1&% + \ifboolTF{@replst}{% + \s@expandarg\ltxkeys@replace@b#3% + }{% + \advance\@tempcnta\@ne + \ifnumcmpTF\@tempcnta<#2{% + \s@expandarg\ltxkeys@remove@b#3% + }{}% + }% + }{}% + }% + \s@expandarg\ltxkeys@replace@b{#3}% + \postgroupdef#3\endgroup } \robust@def*\ltxkeys@checkchoice{% \cpt@teststpl{\cpt@testopt\ltxkeys@cc@a,}% } \robust@def*\ltxkeys@cc@a[#1]{% - \ifcpt@check\cpt@checklistparser{#1}{}\fi - \cpt@testopt{\ltxkeys@cc@b#1}{}% + \cpt@checklistparser{#1}{}% + \cpt@testpnopt{\ltxkeys@cc@b#1}{}% } \robust@def*\ltxkeys@commacheckchoice{% - \cpt@teststpl{\cpt@testopt{\ltxkeys@cc@b,}{}}% + \cpt@teststpl{\cpt@testpnopt{\ltxkeys@cc@b,}{}}% } -\robust@def*\CheckInput#1#2{% +\robust@def*\ltxkeys@checkinput#1#2{% \lowercase{\edef\nominations{\unexpanded{#2}}}% \cpt@sttrue\cpt@pltrue - \ltxkeys@cc@b,[\userinput\nr]{#1}{#2}{% + \ltxkeys@cc@b,(\userinput\order){#1}{#2}{% + \@firstoftwo + }{% + \@secondoftwo + }% +} +\robust@def*\CheckUserInput#1#2{% + \lowercase{\edef\nominations{\unexpanded{#2}}}% + \cpt@sttrue\cpt@pltrue + \ltxkeys@cc@b,(\userinput\order){#1}{#2}{% \inputvalidtrue }{% \inputvalidfalse }% } -\robust@def*\ltxkeys@cc@b#1[#2]#3#4{% +\robust@def*\ltxkeys@cc@b#1(#2)#3#4{% \begingroup \ifcpt@st\lowercase{\fi - \ltxkeys@trimspaces{#3}\us@rinput - \edef\nomin@tions{\unexpanded{#4}}% + \ltxkeys@trimspaces{#3}\ltxkeys@userinput + \edef\ltxkeys@nominations{\unexpanded{#4}}% \ifcpt@st}\fi \def\ltxkeys@ccparser{#1}% - \cpt@sttrue\cpt@csvnormalize[#1]\nomin@tions + \csv@@normalize*[#1]\ltxkeys@nominations \cptexpandsecond{% \ifblankTF{#2}\ltxkeys@cc@d{\ltxkeys@cc@c#2}\ltxkeys@nil }{% - {\expandcsonce\us@rinput}{\expandcsonce\nomin@tions}% + {\expandcsonce\ltxkeys@userinput}% + {\expandcsonce\ltxkeys@nominations}% }% } \robust@def*\ltxkeys@cc@c#1#2\ltxkeys@nil#3#4{% @@ -164,7 +557,7 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@cc@d#1#2#3{% \def\reserved@a{#1}% - \ifxTF\reserved@a\ltxkeys@nnil{% + \ltxkeys@ifxTF\reserved@a\ltxkeys@nnil{% \def\ltxkeys@tempa{}% }{% \def\ltxkeys@tempa{\def#1{#2}}% @@ -172,13 +565,13 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \edef\x{\cptoxdetok\ltxkeys@ccparser}% \edef\x{{\x\detokenize{#2}\x}{\x\detokenize{#3}\x}}% \expandafter\ifinsetTF\x{% - \if@boolTF{cpt@pl}{% + \ifboolTF{cpt@pl}{% \rightaddtocs\ltxkeys@tempa\@firstoftwo }{% \rightaddtocs\ltxkeys@tempa\@firstofone }% }{% - \if@boolTF{cpt@pl}{% + \ifboolTF{cpt@pl}{% \rightaddtocs\ltxkeys@tempa\@secondoftwo }{% \rightaddtocs\ltxkeys@tempa{% @@ -188,15 +581,15 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% \cptpassexpanded{% \endgroup - \def\noexpand\reserved@e{\expandcsonce\us@rinput}% - \def\noexpand\reserved@f{\expandcsonce\nomin@tions}% + \cpt@csexit\ltxkeys@userinput + \cpt@csexit\ltxkeys@nominations \expandcsonce\ltxkeys@tempa }% } \robust@def*\ltxkeys@cc@e#1#2#3#4{% \chardef#2\z@pt \cpt@choicefdfalse - \def\csv@do##1{% + \def\ltxkeys@do##1{% \def#1{##1}% \ifstrcmpTF{##1}{#3}{% \cpt@choicefdtrue\loopbreak @@ -204,9 +597,11 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \pushnumber#2% }% }% - \expandafter\csv@@loop\expandafter[\ltxkeys@ccparser]{#4}% + \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@ccparser]}{#4}% \cptpassexpanded{% \endgroup + \cpt@csexit\ltxkeys@userinput + \cpt@csexit\ltxkeys@nominations \ifcpt@choicefd \def\noexpand#1{\expandcsonce#1}% \def\noexpand#2{\the\numexpr#2}% @@ -217,13 +612,15 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ifcpt@pl \noexpand\@secondoftwo \else - \def\noexpand\reserved@e{\expandcsonce\us@rinput}% - \def\noexpand\reserved@f{\expandcsonce\nomin@tions}% \unexpanded{\expandafter\ltxkeys@nomatcherr\@gobble}% \fi \fi }% } +\robust@def*\ltxkeys@nomatcherr{% + \ltxkeys@error{User input '\ltxkeys@userinput' not in list + of nominations ||\ltxkeys@nominations||}\ltxkeys@ehc +} \robust@def*\ltxkeys@ifincsvlistTF{\cpt@teststopt\ltxkeys@ifincsvlist,} \robust@def*\ltxkeys@ifincsvlist[#1]{% \cpt@testpnopt{\ltxkeys@if@ncsvlist#1}{1}% @@ -236,21 +633,23 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \edef\ltxkeys@tempb{\unexpanded{#4}}% \ifcpt@st}\fi \cpt@sttrue\cpt@csvnormalize[#1]\ltxkeys@tempb - \cpt@cnta\z@pt\def\ltxkeys@itemspresent{}% - \def\csv@do##1{% + \cpt@cnta\z@pt + \def\ltxkeys@itemspresent{}% + \def\ltxkeys@do##1{% \xifinsetFT{\detokenize{#1##1#1}} {\parser\cptoxdetok\ltxkeys@tempb\parser}{}{% \edef\ltxkeys@itemspresent - {\cptliststack,\ltxkeys@itemspresent\unexpanded{##1}}% + {\csliststack,\ltxkeys@itemspresent\unexpanded{##1}}% \advance\cpt@cnta\@ne }% \ifnum\cpt@cnta>\numexpr#2-1\relax\loopbreak\fi }% - \csv@@parse*[#1]\ltxkeys@tempa + \ltxkeys@parse*1[#1]\ltxkeys@tempa \ifnum\cpt@cnta>\numexpr#2-1\relax \edef\ltxkeys@nritems{\the\cpt@cnta}% \else - \def\ltxkeys@itemspresent{}\def\ltxkeys@nritems{-1}% + \def\ltxkeys@itemspresent{}% + \def\ltxkeys@nritems{-1}% \fi \cptexpandsecond\endgroup{% \cpt@csexit\ltxkeys@itemspresent @@ -268,11 +667,12 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \edef\ltxkeys@tempa{\unexpanded{#2}}% \edef\ltxkeys@tempb{\unexpanded{#3}}% \ifcpt@st}\fi - \def\ltxkeys@itemspresent{}\cpt@cnta\z@pt + \def\ltxkeys@itemspresent{}% + \cpt@cnta\z@pt \def\tsv@do##1{% \xifinsetFT{\detokenize{##1}}{\cptoxdetok\ltxkeys@tempb}{}{% \edef\ltxkeys@itemspresent - {\cptliststack{}\ltxkeys@itemspresent\unexpanded{##1}}% + {\csliststack{}\ltxkeys@itemspresent\unexpanded{##1}}% \advance\cpt@cnta\@ne }% \ifnum\cpt@cnta>\numexpr#1-1\relax\loopbreak\fi @@ -281,7 +681,8 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ifnum\cpt@cnta>\numexpr#1-1\relax \edef\ltxkeys@nritems{\the\cpt@cnta}% \else - \def\ltxkeys@itemspresent{}\def\ltxkeys@nritems{-1}% + \def\ltxkeys@itemspresent{}% + \def\ltxkeys@nritems{-1}% \fi \cptexpandsecond\endgroup{% \cpt@csexit\ltxkeys@itemspresent @@ -299,15 +700,17 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \edef\ltxkeys@tempa{\unexpanded{#2}}% \edef\ltxkeys@tempb{\unexpanded{#3}}% \ifcpt@st}\fi - \def\ltxkeys@itemspresent{}\cpt@cnta\z@pt - \s@expandarg\docommalist\ltxkeys@tempa{% - \xifinsetFT{\detokenize{##1}}{\cptoxdetok\ltxkeys@tempb}{}{% + \def\ltxkeys@itemspresent{}% + \cpt@cnta\z@pt + \def\ltxkeys@do##1{% + \xifinsetTF{\detokenize{##1}}{\cptoxdetok\ltxkeys@tempb}{% \edef\ltxkeys@itemspresent - {\cptliststack,\ltxkeys@itemspresent\unexpanded{##1}}% + {\csliststack,\ltxkeys@itemspresent\unexpanded{##1}}% \advance\cpt@cnta\@ne - }% + }{}% \ifnum\cpt@cnta>\numexpr#1-1\relax\loopbreak\fi }% + \ltxkeys@parse*1\ltxkeys@tempa \ifnum\cpt@cnta>\numexpr#1-1\relax \edef\ltxkeys@nritems{\the\cpt@cnta}% \else @@ -316,73 +719,213 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \cptexpandsecond\endgroup{% \cpt@csexit\ltxkeys@itemspresent \cpt@csexit\ltxkeys@nritems - \ifcsemptyTF\ltxkeys@itemspresent{\noexpand\@secondoftwo} - {\noexpand\@firstoftwo}% + \ltxkeys@ifcsemptyTF\ltxkeys@itemspresent + {\noexpand\@secondoftwo}{\noexpand\@firstoftwo}% }% } \robust@def*\ltxkeys@notinpkgclserr#1{% \ifinstylefileTF{}{% - \ltxkeys@err{Command '\detokenize{#1}' issued outside - style file}{The command '\detokenize{#1}' is available + \ltxkeys@err{Command '\detokenize{#1}' issued + \MsgBrk outside style or class file} + {Command '\detokenize{#1}' is available only in style files.}% }% } -\robust@def*\ltxkeys@csvloop{% - \let\ltxkeys@nlz\cptfalse - \let\ltxkeys@inkv\cptfalse - \cpt@testst\ltxkeys@parse@a +\robust@def*\ltxkeys@commanormalize#1#2{% + \edef#2{\cptcommanormalize{#1}}% } -\robust@def*\ltxkeys@csvparse{% - \let\ltxkeys@nlz\cpttrue - \let\ltxkeys@inkv\cptfalse - \cpt@testst\ltxkeys@parse@a +\robust@def*\ltxkeys@commanormalizeset{% + \let\normelt\ltxkeys@commanormalize + \ltxkeys@normalizeset } -\robust@def*\ltxkeys@kvloop{% - \let\ltxkeys@nlz\cptfalse - \let\ltxkeys@inkv\cpttrue - \cpt@testst\ltxkeys@parse@a +\robust@def*\ltxkeys@kvnormalize#1#2{% + \edef#2{\unexpanded{#1}}% + \kv@@normalize*[,]#2% } -\robust@def*\ltxkeys@kvparse{% - \let\ltxkeys@nlz\cpttrue - \let\ltxkeys@inkv\cpttrue - \cpt@testst\ltxkeys@parse@a +\robust@def*\ltxkeys@kvnormalizeset{% + \let\normelt\ltxkeys@kvnormalize + \ltxkeys@normalizeset +} +\robust@def*\ltxkeys@normalizeset#1{% + \edef\reserved@a{\cptcommanormalize{#1}}% + \def\@do##1##2,{% + \ifnot@nil{##1}{\normelt{##1}##2\@do}% + }% + \expandafter\@do\reserved@a,\@nil,% + \undefcs\normelt +} +\robust@def*\ltxkeys@normalizecsset{% + \cpt@testopt\ltxkeys@n@rmalizecsset,% +} +\robust@def*\ltxkeys@n@rmalizecsset[#1]#2{% + \cptfor#2\dofor{\csv@@normalize[#1]##1}% +} +\new@def*\ltxkeys@parser@nil{\@gobble\ltxkeys@parser@nil} + +\begingroup +\catcode`\?=3 +\robust@gdef*\ltxkeys@declarelistparser#1#2{% + \ifcsdefinable{#1}\relax + \begingroup + \ltxkeys@letmanytocs{#1,\ifstrcmpTF,\cptexpandnext, + \ltxkeys@ifcseqTF,\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}% + {\unexpanded{####4}}}}% + \cptexpanded{\endgroup + \def#1####1{% + \ifstrcmpTF!{####1}{\elta{a}}{\eltb+}% + }% + \def\elta{a}####1{\eltb!}% + \def\elta{b}####1####2#2####3?####4####5{% + \ltxkeys@ifcseqTF\ltxkeys@parser@nil{####2}{\eltc}{% + \ifstrcmpTF{####2}{\listbreak}{\eltc}{% + \elta{b}{####1}####3?{####4####5{####2}}{####5}% + }% + }% + }% + }% } +\endgroup + +\robust@def*\ltxkeys@parse{\cpt@testst\ltxkeys@parse@a} \robust@def*\ltxkeys@parse@a#1{% - \cpt@stchoose{cpt@st}{#1}\ltxkeys@arg\ltxkeys@parse@a - \pushfunctions\ltxkeys@parse - {\ifloopbreak,\ltxkeys@doo}\ltxkeys@csvdepth + \begingroup + \def\reserved@a##1##2{\endgroup + \def\ltxkeys@nlz{##1}\def\ltxkeys@inkv{##2}% + }% + \cptexpandsecond\reserved@a{% + \ifcase#1{01}{01}\or{00}{01}\or{01}{00}\or{00}{00}\else{01}{01}\fi + }% + \cpt@testopt\ltxkeys@parse@b,% +} +\robust@def*\ltxkeys@parse@b[#1]#2{% + \cpt@stchoose{cpt@st}{#2}\ltxkeys@arg\ltxkeys@parse + \pushfunctions\ltxkeys@parse{\ifloopbreak,\ifltxkeys@useempty,% + \ltxkeys@doo,\ltxkeys@parse@c,\ltxkeys@parse@d,% + \ltxkeys@loopcbk}\cpt@csvdepth \ifdefTF\ltxkeys@do {\let\ltxkeys@doo\ltxkeys@do}{\cpt@notdeferr\ltxkeys@do}% - \def\ltxkeys@parse@b{% - \if@boolTF{loopbreak}{% - \gobble@to@sentinel\ltxkeys@nil,% - }{% - \ltxkeys@parse@c.% + \def\ltxkeys@parse@c{% + \ifboolTF{loopbreak} + {\gobble@to@sentinel\ltxkeys@nil#1}{\ltxkeys@parse@d.}% + }% + \def\ltxkeys@parse@d##1#1{% + \edef\ltxkeys@arg{\expandcsonce{\@gobble##1}}% + \ltxkeys@ifxTF\ltxkeys@arg\ltxkeys@nnil{}{% + \ltxkeys@ifcsemptyTF\ltxkeys@arg{% + \ifboolFT{ltxkeys@useempty}{}{\ltxkeys@doo{}}% + }{% + \s@expandarg\ltxkeys@doo\ltxkeys@arg + }% + \relax\ltxkeys@parse@c }% }% \ifswitchTF{ltxkeys@nlz}{% - \cpt@sttrue - \usename{cpt@\if\ltxkeys@inkv kv\else - csv\fi normalize}[,]\ltxkeys@arg + \usename{\if\ltxkeys@inkv kv\else + csv\fi @@normalize}*[#1]\ltxkeys@arg }{}% \loopbreakfalse - \expandafter\ltxkeys@parse@b\ltxkeys@arg,\ltxkeys@nil,% - \popfunctions\ltxkeys@parse\ltxkeys@csvdepth - \ifnum\ltxkeys@csvdepth=\z@pt\undefcs\ltxkeys@do\fi + \expandafter\ltxkeys@parse@c\ltxkeys@arg#1\ltxkeys@nil#1% + \popfunctions\ltxkeys@parse\cpt@csvdepth + \ifnum\cpt@csvdepth=\z@pt\undefcs\ltxkeys@do\fi } -\robust@def*\ltxkeys@parse@c#1,{% - \edef\ltxkeys@arg{\expandcsonce{\@gobble#1}}% - \ifxTF\ltxkeys@arg\ltxkeys@nnil{}{% - \ifxTF\@empty\ltxkeys@arg{}{% - \expandafter\ltxkeys@doo\expandafter{\ltxkeys@arg}\relax - }% - \ltxkeys@parse@b +\def\ltxkeys@keyprefixhook{} +\def\ltxkeys@macroprefixhook{} +\def\ltxkeys@keyfamilyhook{} +\robust@def*\ltxkeys@reservekeyprefix{% + \cpt@testst\ltxkeys@res@rvekeyprefix +} +\robust@def*\ltxkeys@res@rvekeyprefix#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfiltermergecsv[,]\unexpanded{% + \ltxkeys@keyprefixhook{#1}\nofilter + \globalize\ltxkeys@keyprefixhook + }% + \ifcpt@st}\fi + }% +} +\robust@def*\ltxkeys@reservekeyfamily{% + \cpt@testst\ltxkeys@res@rvekeyfamily +} +\robust@def*\ltxkeys@res@rvekeyfamily#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfiltermergecsv[,]\unexpanded{% + \ltxkeys@keyfamilyhook{#1}\nofilter + \globalize\ltxkeys@keyfamilyhook + }% + \ifcpt@st}\fi + }% +} +\robust@def*\ltxkeys@reservemacroprefix{% + \cpt@testst\ltxkeys@res@rvemacroprefix +} +\robust@def*\ltxkeys@res@rvemacroprefix#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfiltermergecsv[,]\unexpanded{% + \ltxkeys@macroprefixhook{#1}\nofilter + \globalize\ltxkeys@macroprefixhook + }% + \ifcpt@st}\fi + }% +} +\ltxkeys@reservekeyfamily*{ltxkeys} +\ltxkeys@reservemacroprefix*{ltxkeys@} + +\robust@def*\ltxkeys@unreservekeyprefix{% + \cpt@testst\ltxkeys@unres@rvekeyprefix +} +\robust@def*\ltxkeys@unres@rvekeyprefix#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfilterremovecsv[,]\unexpanded{% + \ltxkeys@keyprefixhook{#1}\nofilter + \globalize\ltxkeys@keyprefixhook + }% + \ifcpt@st}\fi + }% +} +\robust@def*\ltxkeys@unreservekeyfamily{% + \cpt@testst\ltxkeys@unres@rvekeyfamily +} +\robust@def*\ltxkeys@unres@rvekeyfamily#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfilterremovecsv[,]\unexpanded{% + \ltxkeys@keyfamilyhook{#1}\nofilter + \globalize\ltxkeys@keyfamilyhook + }% + \ifcpt@st}\fi + }% +} +\robust@def*\ltxkeys@unreservemacroprefix{% + \cpt@testst\ltxkeys@unres@rvemacroprefix +} +\robust@def*\ltxkeys@unres@rvemacroprefix#1{% + \cptexpanded{% + \ifcpt@st\AfterEndOfStyleFile{\fi + \cptfilterremovecsv[,]\unexpanded{% + \ltxkeys@macroprefixhook{#1}\nofilter + \globalize\ltxkeys@macroprefixhook + }% + \ifcpt@st}\fi }% } \robust@def*\ltxkeys@testopt@a#1{\cpt@testopt{\ltxkeys@testopt@b#1}{KV}} \robust@def*\ltxkeys@testopt@b#1[#2]#3{% + \ifltxkeys@useempty\else + \iflacus#3\dolacus + \ltxkeys@warn{Empty key family encountered\on@line}% + \fi + \fi \ltxkeys@makepf{#2}% - \ltxkeys@makehdr{#3}#1% + \ltxkeys@makehdr{#3}% + #1% } \robust@def*\ltxkeys@testopt@c#1{% \begingroup @@ -394,21 +937,18 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \def\temp@err##1{% \ltxkeys@err{Multiple ##1 in \noexpandcsn {ltxkeys@set\ifltxkeys@rm rm\fi keys}% - without '+' suffix}\@ehc + without '+' suffix}\ltxkeys@ehc }% - \ltxkeys@ifeltcountTF[>]{#2}\@ne{% + \ltxkeys@ifeltcountTF[,](>)\@ne{#2}{% \temp@err{prefixes}% }{% - \ltxkeys@ifeltcountTF[>]{#3}\@ne{% + \ltxkeys@ifeltcountTF[,](>)\@ne{#3}{% \temp@err{families}% }{}% }% \fi \endgroup - \def\ltxkeys@prefs{#2}% - \def\ltxkeys@fams{#3}% - \cpt@sttrue\cpt@csvnormalize[,]\ltxkeys@prefs - \cpt@sttrue\cpt@csvnormalize[,]\ltxkeys@fams + \ltxkeys@commanormalizeset{{#2}\ltxkeys@prefs,{#3}\ltxkeys@fams}% \cpt@testopt{#1}{}% } \robust@def*\ltxkeys@testopt@e#1#2{% @@ -417,7 +957,7 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@testopt@f#1[#2]#3{% - \if@boolTF{ltxkeys@sw}{% + \ifboolTF{ltxkeys@sw}{% \cpt@ifbrack{\ltxkeys@sttrue#1{#2}{#3}}{\ltxkeys@stfalse#1{#2}{#3}[]}% }{% \cpt@ifbrack{\ltxkeys@bracedefault{\ltxkeys@sttrue#1{#2}{#3}}}% @@ -427,9 +967,6 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@testopt@g#1#2{% \cptexpandarg\ltxkeys@testopt@a{\noexpandcsn{ltxkeys@#1}{#2}}% } -\robust@def*\ltxkeys@testopt@h#1{% - \cptexpandarg\ltxkeys@testopt@a{\noexpandcsn{ltxkeys@#1}}% -} \robust@def*\ltxkeys@bracedefault#1[{% \begingroup \toks@{#1}% @@ -441,24 +978,56 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@testopt@@a#1{\ltxkeys@testst{\ltxkeys@testopt@@b#1}} \robust@def*\ltxkeys@testopt@@b#1{\cpt@testopt{\ltxkeys@testopt@@c#1}{KV}} \robust@def*\ltxkeys@testopt@@c#1[#2]{% - \def\ltxkeys@prefs{#2}% + \ltxkeys@commanormalize{#2}\ltxkeys@prefs \cpt@testfam{\ltxkeys@testopt@@d#1}% } \robust@def*\ltxkeys@testopt@@d#1<#2>{% - \edef\ltxkeys@fams{#2}% + \expandafter\ltxkeys@commanormalize + \expandafter{\romannumeral-`\q#2}\ltxkeys@fams \cpt@testopt{#1}{}% } -\robust@def*\ltxkeys@findneedvalue#1{% - \ltxkeys@findpointer\needvalue{#1}\ltxkeys@tkey{% +\robust@def*\ltxkeys@findpointers#1{% + \ltxkeys@svfalse\ltxkeys@nvfalse + \let\infdpointers\cptswtrue + \let\infdp@inters\cptswfalse + \ltxkeys@findp@inters{\savevalue\needvalue}{#1}\ltxkeys@tkey{% + \ltxkeys@svtrue\ltxkeys@nvtrue + \ltxkeys@addtopointedkeys{savevalue}\ltxkeys@tkey \ltxkeys@addtopointedkeys{needvalue}\ltxkeys@tkey - }{}% + }{% + \ltxkeys@findp@inters{\needvalue\savevalue}{#1}\ltxkeys@tkey{% + \ltxkeys@svtrue\ltxkeys@nvtrue + \ltxkeys@addtopointedkeys{needvalue}\ltxkeys@tkey + \ltxkeys@addtopointedkeys{savevalue}\ltxkeys@tkey + }{% + \ltxkeys@findp@inters{\needvalue}{#1}\ltxkeys@tkey{% + \ltxkeys@svfalse\ltxkeys@nvtrue + \ltxkeys@addtopointedkeys{needvalue}\ltxkeys@tkey + }{% + \let\infdp@inters\cptswtrue + \ltxkeys@findp@inters{\savevalue}{#1}\ltxkeys@tkey{% + \ltxkeys@svtrue\ltxkeys@nvfalse + \ltxkeys@addtopointedkeys{savevalue}\ltxkeys@tkey + }{% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey' has no pointer}% + }% + }% + }% + }% + \let\infdpointers\cptswfalse } -\robust@def*\ltxkeys@findpointer#1#2#3{% +\robust@def*\ltxkeys@findp@inters#1#2#3{% \def\reserved@a##1#1##2##3\ltxkeys@nil{% \edef#3{\unexpanded{##2}}% - \ifxTF#3\ltxkeys@nnil{% + \ltxkeys@ifxTF#3\ltxkeys@nnil{% \edef#3{\unexpanded{##1}}% - \ltxkeys@trimspacesincs#3% + \if\infdpointers + \if\infdp@inters + \ltxkeys@trimspacesincs#3% + \fi + \else + \ltxkeys@trimspacesincs#3% + \fi \@secondoftwo }{% \ltxkeys@trimspacesincs#3% @@ -468,41 +1037,59 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \reserved@a#2#1{\ltxkeys@nil}\ltxkeys@nil } \robust@def*\ltxkeys@addtopointedkeys#1#2{% - \letcstocsn\reserved@a{\ltxkeys@hdr#1@keys}% - \ifdefTF\reserved@a{% - \xifinsetTF{,\cptoxdetok{#2},}{,\cptoxdetok\reserved@a,}{}{% - \csn@xdef{\ltxkeys@hdr#1@keys}% - {\cptliststack,\reserved@a\expandcsonce{#2}}% + \letcstocsn\reserved@e{\ltxkeys@hdr#1keys}% + \ifdefTF\reserved@e{% + \xifinsetTF{,\cptoxdetok{#2},}{,\cptoxdetok\reserved@e,}{}{% + \csn@xdef{\ltxkeys@hdr#1keys}% + {\csliststack,\reserved@e\expandcsonce{#2}}% + }% + }{% + \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}% + \ifdefTF\reserved@e{% + \xifinsetTF{,\cptoxdetok\ltxkeys@tempa,}{,\cptoxdetok\reserved@e,}% + {}{% + \csn@xdef{@\ltxkeys@hdr#1keys}% + {\csliststack,\reserved@e\expandcsonce\ltxkeys@tempa}% }% }{% - \csn@xdef{\ltxkeys@hdr#1@keys}{\expandcsonce{#2}}% + \csn@xdef{@\ltxkeys@hdr#1keys}{\expandcsonce\ltxkeys@tempa}% }% } -\new@def*\ltxkeys@currtriple{\ltxkeys@ttpref,\ltxkeys@tfam,\ltxkeys@tkey} +\new@def*\ltxkeys@currtriple{% + \ltxkeys@ifcsemptyTF\ltxkeys@ttpref{???}\ltxkeys@ttpref,% + \ltxkeys@ifcsemptyTF\ltxkeys@tfam{???}\ltxkeys@tfam,% + \ltxkeys@tkey +} \robust@def*\ltxkeys@makepf#1{% \s@expandarg\ltxkeys@trimspaces{#1}\ltxkeys@ttpref \edef\ltxkeys@tpref{% - \ifcsnullTF\ltxkeys@ttpref{}{\ltxkeys@ttpref @}% + \ltxkeys@ifcsemptyTF\ltxkeys@ttpref{}{\ltxkeys@ttpref @}% }% } \robust@def*\ltxkeys@makehdr#1{% \s@expandarg\ltxkeys@trimspaces{#1}\ltxkeys@tfam \edef\ltxkeys@hdr{% - \ltxkeys@tpref\ifcsnullTF\ltxkeys@tfam{}{\ltxkeys@tfam @}% + \ltxkeys@tpref\ltxkeys@ifcsemptyTF\ltxkeys@tfam{}{\ltxkeys@tfam @}% }% } \new@def*\ltxkeys@badkeynamelist{} \robust@def*\ltxkeys@badkeynames#1{% - \ifcsnullTF\ltxkeys@badkeynamelist{% - \edef\ltxkeys@badkeynamelist{\detokenize{#1}}% - \cpt@sttrue\cpt@csvnormalize[,]\ltxkeys@badkeynamelist + \ltxkeys@ifcsemptyTF\ltxkeys@badkeynamelist{% + \expandafter\ltxkeys@commanormalize\expandafter + {\detokenize{#1}}\ltxkeys@badkeynamelist }{% \cptexpandsecond{\cptfiltermergecsv[,]} {\noexpand\ltxkeys@badkeynamelist{\detokenize{#1}}}\nofilter }% } +\newletcs\ltxkeys@addbadkeynames\ltxkeys@badkeynames \robust@def*\ltxkeys@removebadkeynames#1{% - \ifcsnullTF\ltxkeys@badkeynamelist{% + \ltxkeys@ifcsemptyTF\ltxkeys@badkeynamelist{% \ltxkeys@info{Couldn't delete from empty \string\ltxkeys@badkeynamelist}% }{% @@ -511,61 +1098,141 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \ltxkeys@badkeynames{.code,ordkey,cmdkey,choicekey,boolkey,% - handledkeys,presetkeys,postsetkeys% + handledkeys,presetkeys,postsetkeys,rmkeys,executedkeys,bool,% + boolean,tog,toggle,switch,true,false,on,off,count,% + savevaluekeys,xfamilykeys,needvalue,savevalue,usevalue% } \robust@def*\ltxkeys@findbadkeyname#1{% \begingroup \edef\ltxkeys@tempa{\cpttrimspaces{#1}}% \oifinset@sp@TF,\ltxkeys@tempa\ltxkeys@badkeynamelist{% - \ltxkeys@err{Bad key name '\ltxkeys@tempb'}\@ehc + \ltxkeys@err{Bad key name '\ltxkeys@tempb'}\ltxkeys@ehc }{}% \endgroup } \robust@def*\ltxkeys@saveinitialkeyvals#1#2#3{% - \xifinsetTF{\detokenize{\savevalue}}{\cptoxdetok{#2}}{% - \ltxkeys@err{\noexpand\savevalue pointer not allowed - \MsgBrk when defining a key}\@ehc - }{% - \ifltxkeys@verbose + \ifltxkeys@disable\else + \ifltxkeys@tracingkeys \s@expandarg\ltxkeys@findbadkeyname{#2}% \fi - }% - \ifltxkeys@twk\else - \ifltxkeys@sv - \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr initial@keyvals}% - \csn@xdef{\ltxkeys@hdr initial@keyvals}{% - \cptliststack,\ltxkeys@tempa\expandcsonce{#2}=% - \ifstrcmpTF{#1}{bool}{false}{\unexpanded{#3}}% + \ifltxkeys@twk\else + \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr initialkeyvals}% + \csn@xdef{\ltxkeys@hdr initialkeyvals}{% + \csliststack,\ltxkeys@tempa\expandcsonce{#2}=% + \ifstrcmpTF{#1}{bool}{false}{% + \ifstrcmpTF{#1}{switch}{false}{\unexpanded{#3}}% + }% }% \fi + \ifboolTF{ltxkeys@tracingkeys}{% + \ltxkeys@getbasechars[20]{#3}\ltxkeys@tempa + \ltxkeys@debug{==}{Definition done: + \ltxkeys@currtriple,\ltxkeys@tempa}% + }{}% \fi - \ltxkeys@vinfo{Key defined: \ltxkeys@currtriple}% +} +\robust@def*\ltxkeys@checkdefkey{% + \ifcsndefTF{\ltxkeys@hdr\ltxkeys@tkey}{% + \ifltxkeys@disable\else + \ifltxkeys@chdef + \ltxkeys@error{Key already exists: \ltxkeys@currtriple} + {Defining only new keys: key '\ltxkeys@currtriple' + already exists.}% + \else + \ltxkeys@debug{!!}{Key already exists: \ltxkeys@currtriple}% + \fi + \fi + }{% + \ltxkeys@debug{==}{This is a new key: \ltxkeys@currtriple}% + }% + \ltxkeys@chdeffalse + \ifltxkeys@reservenopath\else + \ltxkeys@checkreserved + \fi +} +\robust@def*\ltxkeys@checkreserved{% + \ltxkeys@debug{==}{Checking reserved key paths}% + \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 + \else + \oifinset@sp@FT,##2##3{}{% + \ltxkeys@error{##1 '##2' is reserved} + {You have used a reserved ##1: '##2'.}% + }% + \fi + \@do + }% + }% + \@do key prefix,\ltxkeys@ttpref,\ltxkeys@keyprefixhook;% + key family,\ltxkeys@tfam,\ltxkeys@keyfamilyhook;% + macro prefix,\ltxkeys@macpref,\ltxkeys@macroprefixhook;\@nil,,;% + \ltxkeys@debug{==}{No clash with reserved key paths}% } \robust@def*\ltxkeys@ordkey{% - \ltxkeys@svtrue\ltxkeys@swfalse + \ltxkeys@swfalse + \def\ltxkeys@macpref{}% \ltxkeys@testopt@a\ltxkeys@ordkey@a } +\newletcs\ltxkeys@ordkeys\ltxkeys@ordkey +\robust@def*\ltxkeys@newordkey{\ltxkeys@chdeftrue\ltxkeys@ordkey} +\newletcs\ltxkeys@newordkeys\ltxkeys@newordkey \robust@def*\ltxkeys@ordkey@a#1{% - \ltxkeys@findneedvalue{#1}% + \ltxkeys@debug{==}{Ordinary key '\ltxkeys@tkey' is being defined}% \cpt@ifbrack{% - \ltxkeys@bracedefault - {\ltxkeys@sttrue\s@expandarg\ltxkeys@ordkey@b\ltxkeys@tkey}% + \ltxkeys@bracedefault{\ltxkeys@sttrue\ltxkeys@ordkey@b{#1}}% }{% - \ltxkeys@stfalse\s@expandarg\ltxkeys@ordkey@b\ltxkeys@tkey[]% + \ltxkeys@stfalse\ltxkeys@ordkey@b{#1}[]% }% } \robust@def*\ltxkeys@ordkey@b#1[#2]#3{% - \if@boolFT{ltxkeys@st}{}{\ltxkeys@definedefault{#1}{#2}}% - \ltxkeys@saveinitialkeyvals{}{#1}{#2}% - \csn@def{\ltxkeys@hdr#1}##1{#3}% + \let\ifltxkeys@keyst\ifltxkeys@st + \edef\ltxkeys@loopcbk##1{{##1}\unexpanded{{#2}{#3}}}% + \ifinsetTF,{#1}{% + \def\ltxkeys@do##1{% + \expandafter\ltxkeys@ordkey@c\ltxkeys@loopcbk{##1}% + }% + \ltxkeys@parse1{#1}% + }{% + \ltxkeys@ordkey@c{#1}{#2}{#3}% + }% +} +\robust@def*\ltxkeys@ordkey@c#1#2#3{% + \ltxkeys@findpointers{#1}% + \ltxkeys@checkdefkey + \ifdefboolFT{ltxkeys@keyst}{}{% + \ltxkeys@definedefault\ltxkeys@tkey{#2}% + }% + \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#2}% + \@namedef{\ltxkeys@hdr\ltxkeys@tkey}##1{#3}% } \robust@def*\ltxkeys@cmdkey{% - \ltxkeys@svtrue\ltxkeys@swfalse + \ltxkeys@swfalse \ltxkeys@testopt@e\ltxkeys@cmdkey@a{cmd}% } +\newletcs\ltxkeys@cmdkeys\ltxkeys@cmdkey +\robust@def*\ltxkeys@newcmdkey{\ltxkeys@chdeftrue\ltxkeys@cmdkey} +\newletcs\ltxkeys@newcmdkeys\ltxkeys@newcmdkey \robust@def*\ltxkeys@cmdkey@a#1#2[#3]#4{% - \ltxkeys@findneedvalue{#2}% - \if@boolFT{ltxkeys@st}{}{\ltxkeys@definedefault\ltxkeys@tkey{#3}}% + \let\ifltxkeys@keyst\ifltxkeys@st + \edef\ltxkeys@loopcbk##1{% + \ltxkeys@cmdkey@b{#1}{##1}\unexpanded{{#3}{#4}}% + }% + \ifinsetTF,{#2}{% + \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@cmdkey@b{#1}{#2}{#3}{#4}% + }% +} +\robust@def*\ltxkeys@cmdkey@b#1#2#3#4{% + \def\ltxkeys@macpref{#1}% + \ltxkeys@findpointers{#2}% + \ltxkeys@debug{==}{Command key '\ltxkeys@tkey' is being defined}% + \ltxkeys@checkdefkey + \ifdefboolFT{ltxkeys@keyst}{}{\ltxkeys@definedefault\ltxkeys@tkey{#3}}% \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#3}% \begingroup \edef\ltxkeys@tempa{\endgroup\csn@def{\ltxkeys@hdr\ltxkeys@tkey}####1}% @@ -575,39 +1242,87 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \expandafter\ltxkeys@tempa\ltxkeys@tempb{#4}% } \robust@def*\ltxkeys@boolkey{% - \ltxkeys@svtrue\ltxkeys@swtrue + \ltxkeys@swtrue \ltxkeys@testpl{\ltxkeys@testopt@e\ltxkeys@boolkey@a{bool}}% } +\newletcs\ltxkeys@boolkeys\ltxkeys@boolkey +\robust@def*\ltxkeys@newboolkey{\ltxkeys@chdeftrue\ltxkeys@boolkey} +\newletcs\ltxkeys@newboolkeys\ltxkeys@newboolkey \robust@def*\ltxkeys@boolkey@a#1#2[#3]{% - \ltxkeys@findneedvalue{#2}% - \ltxkeys@saveinitialkeyvals{bool}\ltxkeys@tkey{#3}% - \aftercsname{\if@boolTF{ltxkeys@pl}\ltxkeys@boolkey@c\ltxkeys@boolkey@b}% - {\ltxkeys@hdr\ltxkeys@tkey}{\ltxkeys@tkey}{#1\ltxkeys@tkey}{#3}% -} -\robust@def*\ltxkeys@boolkey@b#1#2#3#4#5{% - \ltxkeys@boolkey@d#1{#2}{#3}{#4}% - {{\ltxkeys@setbool\ltxkeys@resa\usename{#3\ltxkeys@resa}#5}}% + \let\ifltxkeys@keyst\ifltxkeys@st + \ifblankTF{#3}{}{% + \xifstrcmpTF{#3}{true}{}{% + \xifstrcmpTF{#3}{false}{}{% + \ltxkeys@err{Bad boolean value '#3'}\ltxkeys@ehc + }% + }% + }% + \ltxkeys@commanormalize{#2}\ltxkeys@tempa + \cptexpanded{% + \ifboolTF{ltxkeys@pl}\ltxkeys@boolkey@d + \ltxkeys@boolkey@c{#1}{\expandcsonce\ltxkeys@tempa}{#3}% + }% } -\robust@def*\ltxkeys@boolkey@c#1#2#3#4#5#6{% - \ltxkeys@boolkey@d#1{#2}{#3}{#4}% - {{\ltxkeys@setbool\ltxkeys@resa\usename{#3\ltxkeys@resa}#5}{#6}}% +\robust@def*\ltxkeys@boolkey@b#1#2#3{% + \ltxkeys@findpointers{#2}% + \ltxkeys@debug{==}{Boolean key '\ltxkeys@tkey' is being defined}% + \ltxkeys@saveinitialkeyvals{bool}\ltxkeys@tkey{#3}% + \edef\ltxkeys@resa##1##2{% + \ltxkeys@boolkey@e\cptmakecs{\ltxkeys@hdr\ltxkeys@tkey}% + {\ltxkeys@tkey}{#1\ltxkeys@tkey}\unexpanded{{#3}}% + {{\ltxkeys@setbool\noexpand\ltxkeys@resa\noexpand + \usename{#1\ltxkeys@tkey\noexpand\ltxkeys@resa}##1}% + \gobble@or@empty{##2}}% + }% +} +\robust@def*\ltxkeys@boolkey@c#1#2#3#4{% + \let\gobble@or@empty\@gobble + \edef\ltxkeys@loopcbk##1{% + \ltxkeys@boolkey@b{#1}{##1}\unexpanded{{#3}}% + \noexpand\ltxkeys@resa\unexpanded{{#4}}{}% + }% + \ifinsetTF,{#2}{% + \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@loopcbk{#2}% + }% } \robust@def*\ltxkeys@boolkey@d#1#2#3#4#5{% - \csn@newif{#3}% - \if@boolFT{ltxkeys@st}{}{\ltxkeys@definedefault{#2}{#4}}% + \let\gobble@or@empty\@empty + \edef\ltxkeys@loopcbk##1{% + \ltxkeys@boolkey@b{#1}{##1}\unexpanded{{#3}}% + \noexpand\ltxkeys@resa\unexpanded{{#4}{#5}}% + }% + \ifinsetTF,{#2}{% + \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@loopcbk{#2}% + }% +} +\robust@def*\ltxkeys@boolkey@e#1#2#3#4#5{% + \def\reserved@a##1#2\ltxkeys@nil{% + \def\ltxkeys@macpref{##1}% + }% + \reserved@a#3\ltxkeys@nil + \ltxkeys@checkdefkey + \csnnewif{#3}% + \ifboolFT{ltxkeys@keyst}{}{\ltxkeys@definedefault{#2}{#4}}% \cptexpandarg{\def#1##1}{% \csn@def{#3}{####1}% \noexpandcsn{cpt@pl\ifltxkeys@pl true\else false\fi}% - \unexpanded - {\cpt@sttrue\ltxkeys@cc@b,[\ltxkeys@resa]{##1}{true,false}#5}% + \unexpanded{\cpt@sttrue\ltxkeys@cc@b,(\ltxkeys@resa)% + {##1}{true,false}#5}% }% } \robust@def*\ltxkeys@biboolkeys{% - \ltxkeys@svtrue\ltxkeys@swtrue + \ltxkeys@swtrue \ltxkeys@testpl{\ltxkeys@testopt@e\ltxkeys@biboolkeys@a{}}% } +\robust@def*\ltxkeys@newbiboolkeys{\ltxkeys@chdeftrue\ltxkeys@biboolkeys} \robust@def*\ltxkeys@biboolkeys@a#1#2[#3]{% - \if@boolTF{ltxkeys@pl}\ltxkeys@biboolkeys@c\ltxkeys@biboolkeys@b + \ifboolTF{ltxkeys@pl}\ltxkeys@biboolkeys@c\ltxkeys@biboolkeys@b {#1}{#2}{#3}% } \robust@def*\ltxkeys@biboolkeys@b#1#2#3#4#5{% @@ -621,16 +1336,18 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@tempb{#5}{#6}% } \robust@def*\ltxkeys@biboolkeys@d#1#2#3{% - \ltxkeys@ifeltcountTF[=]{#2}\tw@{}{% - \ltxkeys@error{Biboolean keys '#2' not equal to 2}\@ehc + \ltxkeys@ifeltcountTF[,](=)\tw@{#2}{}{% + \ltxkeys@error{Biboolean keys '#2' not equal to 2}\ltxkeys@ehc }% - \def\ltxkeys@keys{#2}% - \cpt@sttrue\cpt@csvnormalize[,]\ltxkeys@keys + \ltxkeys@commanormalize{#2}\ltxkeys@keys \def\ltxkeys@tempa##1,##2\ltxkeys@nil##3##4{% - \ltxkeys@findneedvalue{##1}% + \ltxkeys@findpointers{##1}% + \ltxkeys@debug{==}{Boolean key '\ltxkeys@tkey' is being defined}% \let\ltxkeys@tkeya\ltxkeys@tkey - \ltxkeys@findneedvalue{##2}% - \cpt@newv@riables{tog}{\ltxkeys@hdr}{##1,##2}[false]% + \ltxkeys@findpointers{##2}% + \ltxkeys@debug{==}{Boolean key '\ltxkeys@tkey' is being defined}% + \cptexpandarg{\cpt@newv@riables{tog}\ltxkeys@hdr} + {\ltxkeys@tkeya,\ltxkeys@tkey}[false]% \cptexpandsecond\ltxkeys@biboolkeys@e {{\ltxkeys@tkeya}{\ltxkeys@tkey}}{#1}{#3}{##3}{##4}% }% @@ -641,14 +1358,14 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def\ltxkeys@biboolkeys@e#1#2#3#4#5#6{% \ifltxkeys@pl \long\def\ltxkeys@tempa##1##2{% - \aftercsname\ltxkeys@boolkey@d{\ltxkeys@hdr#1}{#1}{#3#1}{#4}{{% + \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}}% }% \long\def\ltxkeys@tempb##1##2{% - \aftercsname\ltxkeys@boolkey@d{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{{% + \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#2\ltxkeys@resa}% ##1\relax \ltxkeys@biboolkeys@f{#2}{#1}{#3#2}{#5}{#6}% @@ -656,14 +1373,14 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% \else \long\def\ltxkeys@tempa##1{% - \aftercsname\ltxkeys@boolkey@d{\ltxkeys@hdr#1}{#1}{#3#1}{#4}{% + \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}% }% }% \long\def\ltxkeys@tempb##1{% - \aftercsname\ltxkeys@boolkey@d{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{% + \aftercsname\ltxkeys@boolkey@e{\ltxkeys@hdr#2}{#2}{#3#2}{#4}{% \ltxkeys@setbool\ltxkeys@resa\usename{#3#2\ltxkeys@resa}% ##1\relax \ltxkeys@biboolkeys@f{#2}{#1}{#3#2}{#5}{#6}% @@ -679,31 +1396,49 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@stylekey{% - \ltxkeys@svtrue\ltxkeys@swfalse + \ltxkeys@swfalse \ltxkeys@testst{% \cpt@cnta\ifltxkeys@st1\else0\fi\relax \ltxkeys@testopt@e\ltxkeys@stylekey@a{style}% }% } +\newletcs\ltxkeys@stylekeys\ltxkeys@stylekey +\robust@def*\ltxkeys@newstylekey{\ltxkeys@chdeftrue\ltxkeys@stylekey} +\newletcs\ltxkeys@newstylekeys\ltxkeys@newstylekey \robust@def*\ltxkeys@stylekey@a#1#2[#3]{% + \def\ltxkeys@macpref{#1}% \cpt@testpnopt{\ltxkeys@stylekey@b{#1}{#2}{#3}}{}% } \robust@def*\ltxkeys@stylekey@b#1#2#3(#4)#5{% - \ltxkeys@findneedvalue{#2}% + \let\ifltxkeys@keyst\ifltxkeys@st + \edef\ltxkeys@loopcbk##1{% + \ltxkeys@stylekey@c{#1}{##1}\unexpanded{{#3}{#4}{#5}}% + }% + \ifinsetTF,{#2}{% + \def\ltxkeys@do##1{\ltxkeys@loopcbk{##1}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@stylekey@c{#1}{#2}{#3}{#4}{#5}% + }% +} +\robust@def*\ltxkeys@stylekey@c#1#2#3#4#5{% + \ltxkeys@debug{==}{Style key '\ltxkeys@tkey' is being defined}% + \ltxkeys@findpointers{#2}% + \ltxkeys@checkdefkey \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#3}% - \ifltxkeys@st + \ifltxkeys@keyst \s@expandarg\ltxkeys@definedefault\ltxkeys@tkey{#3}% \fi - \cptexpandtwoargs\cpt@in + \cptexpandtwoargs\ltxkeys@in {\detokenize\expandafter{\unexpanded\expandafter {\csname\ltxkeys@hdr\ltxkeys@tkey @value\endcsname}}} {\detokenize{#4}}% \csn@edef{\ltxkeys@hdr\ltxkeys@tkey @dependants}{\unexpanded{#4}}% \cptpassexpanded{% - \long\csn@def{\ltxkeys@hdr\ltxkeys@tkey}####1{% + \csn@def{\ltxkeys@hdr\ltxkeys@tkey}####1{% \csn@edef{#1\ltxkeys@tkey}{\noexpand\unexpanded{####1}}% \edef\noexpand\parentval{\noexpand\unexpanded{####1}}% - \ifcpt@in + \ifin@ \csn@xdef{\ltxkeys@hdr\ltxkeys@tkey @value}% {\noexpand\unexpanded{####1}}% \fi @@ -714,11 +1449,11 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@setdependants#1#2{% \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr\ltxkeys@tkey @dependants}% - \ifcsemptyTF\ltxkeys@tempa{}{% + \ltxkeys@ifcsemptyTF\ltxkeys@tempa{}{% \cpt@sttrue \expandafter\cpt@csvnormalize \expandafter[\ltxkeys@keyparser]\ltxkeys@tempa - \if@boolTF{ltxkeys@dec}{}{% + \ifboolTF{ltxkeys@dec}{}{% \cptexpandargonce{\ltxkeys@s@tdependants{#1}{#2}}\ltxkeys@tempa }% }% @@ -726,11 +1461,11 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@s@tdependants#1#2#3{% \begingroup \toks0{}\toks1{}\toks2{}% - \def\csv@do##1{% + \def\ltxkeys@do##1{% \ltxkeys@s@td@pendants{##1}% \ltxkeys@s@td@p@ndants{#1}% }% - \expandafter\csv@@loop\expandafter[\ltxkeys@keyparser]{#3}% + \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@keyparser]}{#3}% \let\ifblankTF\relax \cptpassexpanded{% \endgroup @@ -739,10 +1474,11 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ {\ltxkeys@setkeys[\expandcsonce\ltxkeys@ttpref]% {\expandcsonce\ltxkeys@tfam}{\the\toks0}}% \ifblankTF{\the\toks1}{}% - {\ltxkeys@declarekeys[\ltxkeys@ttpref]<\ltxkeys@tfam>[#2]{\the\toks1}}% + {\ltxkeys@declarekeys[\ltxkeys@ttpref]% + {\ltxkeys@tfam}[#2]{\the\toks1}}% \ifblankTF{\the\toks2}{}{% - \ltxkeys@err{Undefined dependant keys:^^J||\the\toks2||}{% - I have come across undefined dependant keys. You can + \ltxkeys@err{Undefined dependant keys: ||\the\toks2||} + {I have come across undefined dependant keys. You can \MsgBrk use the star (*) form of '\string\ltxkeys@stylekey' \MsgBrk to define and set dependant keys on the fly. }% @@ -750,34 +1486,44 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% \ltxkeys@depfalse } +\robust@def*\ltxkeys@striplaststar#1*\@empty#2\ltxkeys@nil#3{% + \edef#3{#1}% +} +\robust@def*\ltxkeys@ifrejname#1{% + \ifcase0\ifx\key@type\ltxkeys@rej1\else + \ifx\key@name\ltxkeys@rej1\fi\fi\relax\else#1\fi +} \robust@def*\ltxkeys@s@td@pendants#1{% \begingroup - \emptifycsset{\key@name,\key@default,\key@macro}% + \def\key@name{}\def\key@default{}\def\key@macro{}% \@temptokena{#1}% \def\ltxkeys@splita##1/##2/{% \ifblankTF{##1##2}{% - \ltxkeys@warn{Something wrong with dependant keys}\@ehc + \ltxkeys@err{Something is wrong with dependant keys}\ltxkeys@ehc \expandafter\gobble@to@sentinel\expandafter \ltxkeys@nil\ltxkeys@keyparser }{% \ltxkeys@trimspaces{##1}\key@type - \def\striplaststar####1*\@empty####2\@nil{\edef\key@type{####1}}% - \expandafter\striplaststar\key@type\@empty*\@empty\@nil + \expandafter\ltxkeys@striplaststar + \key@type\@empty*\@empty\ltxkeys@nil\key@type \xifstrcmpFT\key@type{sty}{}{% \ltxkeys@err{A dependant key can't have dependants: - \MsgBrk ||\the\@temptokena||}\@ehc + ||\the\@temptokena||}\ltxkeys@ehc }% \xifinsetTF\key@type{,ord,cmd,bool,choice,}{}{% \ltxkeys@err{Invalid key type '\key@type' in dependant key(s) - \MsgBrk ||\the\@temptokena||}\@ehc + ||\the\@temptokena||}\ltxkeys@ehc }% \ifblankTF{##2}{% - \ltxkeys@err{Empty key name in dependant key(s)\MsgBrk - ||\the\@temptokena||}\@ehc + \ltxkeys@err{Empty key name in dependant key(s) + ||\the\@temptokena||}\ltxkeys@ehc }{% - \ltxkeys@findneedvalue{##2}% + \ltxkeys@findpointers{##2}% \let\key@name\ltxkeys@tkey }% + \ltxkeys@ifrejname{% + \ltxkeys@err{Wrong syntax for dependant keys}\ltxkeys@ehc + }% \ltxkeys@splitb.% }% }% @@ -788,12 +1534,13 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \edef\key@default{\expandcstwice\key@default}% }{}% \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 - \cpt@csexit\key@type\cpt@csexit\key@name - \cpt@csexit\key@default\cpt@csexit\key@macro + \do\key@type\do\key@name\do\key@default\do\key@macro }% } \robust@def*\ltxkeys@s@td@p@ndants#1{% @@ -807,9 +1554,9 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ifnum\numexpr#1=\@ne \toks1{% \the\toks1\oifblankTF{\the\toks1}{}{\ltxkeys@keyparser}% - \key@type/\key@name - \ifcsnullTF\key@default{}{/\expandcsonce\key@default}% - \ifcsnullTF\key@macro{}{/\expandcsonce\key@macro}% + \key@type/\expandcsonce\key@name + \ifx\key@default\ltxkeys@rej\else/\expandcsonce\key@default\fi + \ifx\key@macro\ltxkeys@rej\else/\expandcsonce\key@macro\fi }% \else \toks2{\the\toks2\oifblankTF{\the\toks2}{}{,}% @@ -819,43 +1566,78 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@choicekey{% - \ltxkeys@svtrue\ltxkeys@swfalse - \ltxkeys@teststpl{\cpt@testcl{% - \ltxkeys@testopt@a{\cpt@testopt\ltxkeys@choicekey@a{chc\ltxkeys@hdr}}% - }}% -} + \ltxkeys@swfalse + \ltxkeys@suffixcheck{\ltxkeys@teststpl{\ltxkeys@testcl + {\ltxkeys@testopt@a{\cpt@testopt\ltxkeys@choicekey@a + {chc\ltxkeys@hdr}}}}}% +} +\newletcs\ltxkeys@choicekeys\ltxkeys@choicekey +\robust@def*\ltxkeys@newchoicekey{\ltxkeys@chdeftrue\ltxkeys@choicekey} +\newletcs\ltxkeys@newchoicekeys\ltxkeys@newchoicekey \robust@def*\ltxkeys@choicekey@a[#1]#2{% + \edef\ltxkeys@macpref{#1}% \begingroup - \def\siso@do##1{\catcode`##1\string=12\relax}% - \siso@@loop{=,.}% + \catcode`\=\string=12\catcode`\,=12 + \catcode`\;=12\catcode`\.=12 \cpt@testopt{\expandafter\endgroup\ltxkeys@choicekey@b{#1}{#2}}{}% } \robust@def*\ltxkeys@choicekey@b#1#2[#3]#4{% + \ifblankTF{#4}{% + \ltxkeys@err{Choice key can't have empty nominations}\ltxkeys@ehc + }{}% \ltxkeys@makechclist{#4}{0}% \cpt@ifbrack{% \ltxkeys@sttrue\ltxkeys@bracedefault - {\ltxkeys@choicekey@c{#2}{#1#2}{#3}{#4}}% + {\ltxkeys@choicekey@c{#1}{#2}{#3}{#4}}% }{% - \ltxkeys@stfalse\ltxkeys@choicekey@c{#2}{#1#2}{#3}{#4}[]% + \ltxkeys@stfalse\ltxkeys@choicekey@c{#1}{#2}{#3}{#4}[]% }% } \robust@def*\ltxkeys@choicekey@c#1#2#3#4[#5]{% - \ltxkeys@findneedvalue{#1}% - \ifltxkeys@st\ltxkeys@definedefault\ltxkeys@tkey{#5}\fi - \ltxkeys@saveinitialkeyvals{}\ltxkeys@tkey{#5}% + \ltxkeys@commanormalize{#2}\ltxkeys@tempa + \edef\ltxkeys@tempa{\unexpanded{{#1}}{\expandcsonce\ltxkeys@tempa}}% \cptexpanded{% - \ifltxkeys@pl\ltxkeys@choicekey@e\else\ltxkeys@choicekey@d\fi - \cptmakecs{\ltxkeys@hdr\ltxkeys@tkey}% + \noexpand\expandafter + \ifltxkeys@pl\ltxkeys@choicekey@f\else\ltxkeys@choicekey@e\fi }% - {#2}{#3}{#4}% + \ltxkeys@tempa{#3}{#4}{#5}% } -\robust@def*\ltxkeys@choicekey@d#1#2#3#4#5{% - \ltxkeys@choicekey@f{#1}{#2}{#3}{#4}{{#5\relax}}% +\robust@def*\ltxkeys@choicekey@d#1#2#3{% + \ltxkeys@findpointers{#2}% + \ltxkeys@debug{==}{Choice key '\ltxkeys@tkey' is being defined}% + \ltxkeys@checkdefkey + \ifltxkeys@st\ltxkeys@definedefault\ltxkeys@tkey{#3}\fi + \ltxkeys@saveinitialkeyvals{choice}\ltxkeys@tkey{#3}% + \edef\ltxkeys@resa##1##2##3{% + \ltxkeys@choicekey@g\cptmakecs{\ltxkeys@hdr\ltxkeys@tkey}% + {#1\ltxkeys@tkey}{##1}{##2}{##3}% + }% } \robust@def*\ltxkeys@choicekey@e#1#2#3#4#5#6{% - \ltxkeys@choicekey@f{#1}{#2}{#3}{#4}{{#5\relax}{#6\relax}}% + \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}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@loopcbk{#2}% + }% +} +\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}}% + \ltxkeys@parse1{#2}% + }{% + \ltxkeys@loopcbk{#2}% + }% } -\robust@def*\ltxkeys@choicekey@f#1#2#3#4#5{% +\robust@def*\ltxkeys@choicekey@g#1#2#3#4#5{% \ifinsetTF{/.code=}{#4}{% \def\ltxkeys@tempa{\ltxkeys@executechclist}% }{% @@ -869,15 +1651,15 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \csn@edef{#2}{\noexpand\unexpanded{####1}}% \cptmakecs{cpt@st\ifltxkeys@st true\else false\fi}% \cptmakecs{cpt@pl\ifltxkeys@pl true\else false\fi}% - \ifcpt@cl + \ifltxkeys@cl \edef\noexpand\reserved@a{####1}% \else \edef\noexpand\reserved@a{\noexpand\unexpanded{####1}}% \fi - \def\noexpand\reserved@b{\unexpanded{\ltxkeys@cc@b,[#3]}}% + \def\noexpand\reserved@b{\unexpanded{\ltxkeys@cc@b,(#3)}}% \unexpanded{\expandafter\reserved@b\expandafter{\reserved@a}}% - {\expandcsonce\ltxkeys@chclist}% - \unexpanded{#5}\expandcsonce\ltxkeys@tempa{\unexpanded{#4}}% + {\expandcsonce\ltxkeys@chclist}\unexpanded{#5}% + \expandcsonce\ltxkeys@tempa{\unexpanded{#4}}% }% \def\ltxkeys@tempa{\def#1####1}% \expandafter\ltxkeys@tempa\expandafter{#1}% @@ -907,10 +1689,10 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }{}% \else \ltxkeys@err{Invalid number '#2' while - in \string\ltxkeys@makechclist}\@ehc + in \string\ltxkeys@makechclist}\ltxkeys@ehc \fi }% - \def\csv@do##1{% + \def\ltxkeys@do##1{% \ifinsetTF{/.code=}{##1}{% \ltxkeys@tempb.##1\ltxkeys@nil }{% @@ -918,12 +1700,12 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% }% \expandafter\ifinsetTF\expandafter{\ltxkeys@keyparser}{#1}{% - \expandafter\csv@@parse\expandafter[\ltxkeys@keyparser]{#1}% + \cptexpandsecond{\ltxkeys@parse1}{[\ltxkeys@keyparser]}{#1}% }{% \ifinsetTF{,}{#1}{% - \csv@@parse[,]{#1}% + \ltxkeys@parse1[,]{#1}% }{% - \csv@@parse[,]{#1,}% + \ltxkeys@parse1[,]{#1,}% }% }% \postgroupdef\ltxkeys@chclist\endgroup @@ -944,25 +1726,19 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@getkeyname#1=#2\ltxkeys@nil#3{% - \ltxkeys@findpointer\savevalue{#1}#3\ltxkeys@svtrue\ltxkeys@svfalse - \ltxkeys@findpointer\needvalue{#1}#3\ltxkeys@nvtrue\ltxkeys@nvfalse - \ifdefTF\ltxkeys@fromgetkeynames{% - \def#3{#1}% - }{% - \ltxkeys@trimspaces{#1}#3% - }% + \ltxkeys@findpointers{#1}% + \let#3\ltxkeys@tkey } \robust@def*\ltxkeys@getkeynames#1{% \begingroup - \def\ltxkeys@fromgetkeynames{}% \def\ltxkeys@keynames{}% \def\ltxkeys@do##1{% \ltxkeys@getkeyname##1=\ltxkeys@nil\ltxkeys@tempa \edef\ltxkeys@keynames{% - \cptliststack,\ltxkeys@keynames\expandcsonce\ltxkeys@tempa + \csliststack,\ltxkeys@keynames\expandcsonce\ltxkeys@tempa }% }% - \ifblankTF{#1}{}{\ltxkeys@kvparse{#1}}% + \ifblankTF{#1}{}{\ltxkeys@parse3{#1}}% \postgroupdef\ltxkeys@keynames\endgroup } \robust@def*\ltxkeys@getkeyvalue#1=#2\ltxkeys@nil#3{% @@ -982,178 +1758,217 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@getkeyname#1=\ltxkeys@nil#2% \ltxkeys@getkeyvalue#1=\ltxkeys@nil#3% } -\robust@def*\option@keys{% - \ltxkeys@notinpkgclserr\option@keys - \cpt@testst\ltxkeys@optionk@ys +\robust@def*\ltxkeys@optionkeys{% + \ltxkeys@notinpkgclserr\ltxkeys@optionkeys + \cpt@testst\ltxkeys@opti@nkeys } -\robust@def*\ltxkeys@optionk@ys{% - \if@boolTF{cpt@st}{% - \ltxkeys@testopt@g{optionkeys}{not}% +\robust@def*\ltxkeys@opti@nkeys{% + \ifboolTF{cpt@st}{% + \ltxkeys@testopt@g{opti@nk@ys}{non}% }{% - \ltxkeys@testopt@g{optionkeys}{}% + \ltxkeys@testopt@g{opti@nk@ys}{}% }% } -\robust@def*\notoption@keys{% - \ltxkeys@notinpkgclserr\notoption@keys - \ltxkeys@testopt@g{optionkeys}{not}% +\robust@def*\ltxkeys@nonoptionkeys#1{% + \ltxkeys@notinpkgclserr\ltxkeys@nonoptionkeys + \ifstrcmpTF{#1}{*}{% + \ltxkeys@warn{No star form of \string\ltxkeys@nonoptionkeys: + \MsgBrk star (*) ignored}% + \ltxkeys@testopt@g{opti@nk@ys}{non}% + }{% + \ifsingletokenTF{#1}{% + \ltxkeys@testopt@g{opti@nk@ys}{non}#1% + }{% + \ltxkeys@testopt@g{opti@nk@ys}{non}{#1}% + }% + }% } -\robust@def*\ltxkeys@optionkeys#1#2{% +\robust@def*\ltxkeys@opti@nk@ys#1#2{% \def\ltxkeys@do##1{% \ifcsndefTF{\ltxkeys@hdr##1}{% - \ifcsndefTF{\ltxkeys@hdr#1option@keys}{% + \ifcsndefTF{\ltxkeys@hdr#1optionkeys}{% \xifinsetTF{,\detokenize{##1},} - {,\cptsxdetok{\usename{\ltxkeys@hdr#1option@keys}},}{}{% - \csn@edef{\ltxkeys@hdr#1option@keys}{% - \expandcsnonce{\ltxkeys@hdr#1option@keys},% + {,\cptsxdetok{\usename{\ltxkeys@hdr#1optionkeys}},}{}{% + \csn@edef{\ltxkeys@hdr#1optionkeys}{% + \expandcsnonce{\ltxkeys@hdr#1optionkeys},% \unexpanded{##1}% }% }% }{% - \csn@def{\ltxkeys@hdr#1option@keys}{##1}% + \csn@def{\ltxkeys@hdr#1optionkeys}{##1}% }% }{% - \ltxkeys@err{Key '##1' is undefined in family '\ltxkeys@tfam' - \MsgBrk Only defined keys can be made '#1option' keys.}\@ehc + \ltxkeys@err{Key '##1' is undefined in family '\ltxkeys@tfam'} + {Only defined keys can be made '#1option' keys.}% }% }% - \ltxkeys@csvparse{#2}% + \ltxkeys@parse1{#2}% } -\robust@def*\makeoption@keys{\cpt@teststopt\ltxkeys@makeoptionkeys{KV}} -\robust@def*\ltxkeys@makeoptionkeys[#1]#2{% - \let\ifmakeoptst\ifcpt@st - \ifcsndefTF{#1@#2@initial@keyvals}{% - \edef\ltxkeys@tempa{\expandcsnonce{#1@#2@initial@keyvals}}% +\robust@def*\ltxkeys@makeoptionkeys{% + \cpt@teststopt\ltxkeys@m@keoptionkeys{KV}% +} +\robust@def*\ltxkeys@m@keoptionkeys[#1]#2{% + \let\ifltxkeys@keyst\ifcpt@st + \ifcsndefTF{#1@#2@initialkeyvals}{% + \letcstocsn\ltxkeys@tempa{#1@#2@initialkeyvals}% }{% - \ltxkeys@err{No initial key-values for family '#2'}\@ehc + \ltxkeys@err{No initial key-values for family '#2'}\ltxkeys@ehc }% \s@expandarg\ltxkeys@getkeynames\ltxkeys@tempa - \ifcsnullTF\ltxkeys@keynames{}{% - \cptexpandarg{\usename{\ifmakeoptst not\fi option@keys}[#1]{#2}}{% - \expandcsonce\ltxkeys@keynames - }% + \ltxkeys@ifcsemptyTF\ltxkeys@keynames{}{% + \cptexpandargonce + {\usename{ltxkeys@\ifltxkeys@keyst non\fi optionkeys}[#1]{#2}} + \ltxkeys@keynames }% - \undefcs\ifmakeoptst } -\robust@def*\makenotoption@keys{% - \cpt@sttrue\cpt@testopt\ltxkeys@makeoptionkeys{KV}% +\robust@def*\ltxkeys@makenonoptionkeys{% + \cpt@sttrue\cpt@testopt\ltxkeys@m@keoptionkeys{KV}% } \robust@def*\ltxkeys@handledkeys{% - \ltxkeys@testopt@h{h@ndledkeys}% + \ltxkeys@testopt@g{h@ndledkeys}{handled}% } +\newletcs\ltxkeys@addhandledkeys\ltxkeys@handledkeys \robust@def*\ltxkeys@removehandledkeys{% - \ltxkeys@testopt@h{rem@vehandledkeys}% + \ltxkeys@testopt@g{rem@vehandledkeys}{handled}% } \robust@def*\ltxkeys@undefhandledkeys{% - \cpt@testcl{\ltxkeys@testopt@h{undefh@ndledkeys}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{undefh@ndledkeys}{handled}}% } \robust@def*\ltxkeys@emptifyhandledkeys{% - \cpt@testcl{\ltxkeys@testopt@h{emptifyh@ndledkeys}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{emptifyh@ndledkeys}{handled}}% +} +\robust@def*\ltxkeys@savevaluekeys{% + \ltxkeys@testopt@g{h@ndledkeys}{savevalue}% +} +\newletcs\ltxkeys@addsavevaluekeys\ltxkeys@savevaluekeys +\robust@def*\ltxkeys@removesavevaluekeys{% + \ltxkeys@testopt@g{rem@vehandledkeys}{savevalue}% +} +\robust@def*\ltxkeys@undefsavevaluekeys{% + \ltxkeys@testcl{\ltxkeys@testopt@g{undefh@ndledkeys}{savevalue}}% } -\robust@def*\ltxkeys@h@ndledkeys#1{% - \letcstocsn\ltxkeys@rsvda{\ltxkeys@hdr handledkeys}% +\robust@def*\ltxkeys@emptifysavevaluekeys{% + \ltxkeys@testcl{\ltxkeys@testopt@g{emptifyh@ndledkeys}{savevalue}}% +} +\robust@def*\ltxkeys@h@ndledkeys#1#2{% + \letcstocsn\ltxkeys@rsvda{\ltxkeys@hdr#1keys}% \def\ltxkeys@do##1{% \ifcsndefTF{\ltxkeys@hdr##1}{% \def\ltxkeys@tempb{##1}% \ifdefTF\ltxkeys@rsvda{% \oifinset@sp@TF,\ltxkeys@tempb\ltxkeys@rsvda{}{% \edef\ltxkeys@rsvda{% - \cptliststack,\ltxkeys@rsvda\unexpanded{##1}% + \csliststack,\ltxkeys@rsvda\unexpanded{##1}% }% }% }{% \let\ltxkeys@rsvda\ltxkeys@tempb }% }{% - \ltxkeys@err{Key '##1' is undefined in family '\ltxkeys@tfam' - \MsgBrk Only defined keys can be made handled keys.}\@ehc + \ltxkeys@err{Key '##1' is undefined in family + '\ltxkeys@tfam'} + {Only defined keys can be made #1-keys.}% }% }% - \ltxkeys@csvparse{#1}% - \letcsntocs{\ltxkeys@hdr handledkeys}\ltxkeys@rsvda + \ltxkeys@parse1{#2}% + \letcsntocs{\ltxkeys@hdr#1keys}\ltxkeys@rsvda } -\robust@def*\ltxkeys@rem@vehandledkeys#1{% - \letcstocsn\ltxkeys@rsvda{\ltxkeys@hdr handledkeys}% +\robust@def*\ltxkeys@rem@vehandledkeys#1#2{% + \letcstocsn\ltxkeys@rsvda{\ltxkeys@hdr#1keys}% \ifdefTF\ltxkeys@rsvda{% \def\ltxkeys@do##1{% \ifcsndefTF{\ltxkeys@hdr##1}{% \def\ltxkeys@tempb{##1}% \oifinset@sp@TF,\ltxkeys@tempb\ltxkeys@rsvda{% - \let\cpt@fromrem\cpttrue\cpt@sttrue + \let\cpt@fromrem\cptswtrue\cpt@sttrue \cpt@removeoneelement[,]\ltxkeys@rsvda{##1}% }{% - \ltxkeys@warn{Key '##1' with prefix '\ltxkeys@ttpref' in family - \MsgBrk '\ltxkeys@tfam' is not a handled key: - \MsgBrk It couldn't be deleted from handled keys list.}% + \ltxkeys@warn{Key '##1' with prefix '\ltxkeys@ttpref' + in family\MsgBrk '\ltxkeys@tfam' is not a #1 key: + \MsgBrk It couldn't be deleted from #1-keys list.}% }% }{% - \ltxkeys@err{Key '##1' is undefined in family '\ltxkeys@tfam'}% - {Key '##1' with prefix '\ltxkeys@ttpref' in family - \MsgBrk '\ltxkeys@tfam' is not defined:\MsgBrk - Can't be deleted from handled keys list.}% + \ltxkeys@err{Key '##1' with prefix '\ltxkeys@ttpref' in + family\MsgBrk '\ltxkeys@tfam' is not defined.} + {I couldn't delete #1-keys.}% }% }% - \ltxkeys@csvparse{#1}% + \ltxkeys@parse1{#2}% }{% - \ltxkeys@err{No handled keys for family '\ltxkeys@tfam'}% - {No handled keys exist for prefix '\ltxkeys@ttpref' and + \ltxkeys@err{No #1 keys for family '\ltxkeys@tfam'}% + {No #1 keys exist for prefix '\ltxkeys@ttpref' and \MsgBrk family '\ltxkeys@tfam'.}% }% - \letcsntocs{\ltxkeys@hdr handledkeys}\ltxkeys@rsvda + \letcsntocs{\ltxkeys@hdr#1keys}\ltxkeys@rsvda } -\robust@def*\ltxkeys@undefh@ndledkeys{% - \ifcsndefTF{\ltxkeys@hdr handledkeys}{% - \usename{\ifcpt@cl g\fi undefcsn}{\ltxkeys@hdr handledkeys}% +\robust@def*\ltxkeys@undefh@ndledkeys#1{% + \ifcsndefTF{\ltxkeys@hdr#1keys}{% + \usename{\ifltxkeys@cl g\fi undefcsn}{\ltxkeys@hdr#1keys}% }{% - \ltxkeys@err{No handled keys for prefix '\ltxkeys@ttpref' - \MsgBrk and family '\ltxkeys@tfam': couldn't undefine}\@ehc + \ltxkeys@err{No #1 keys for prefix '\ltxkeys@ttpref' + \MsgBrk and family '\ltxkeys@tfam'} + {I couldn't undefine #1-keys.}% }% } -\robust@def*\ltxkeys@emptifyh@ndledkeys{% - \ifcsndefTF{\ltxkeys@hdr handledkeys}{% - \usename{\ifcpt@cl g\fi emptifycsn}{\ltxkeys@hdr handledkeys}% +\robust@def*\ltxkeys@emptifyh@ndledkeys#1{% + \ifcsndefTF{\ltxkeys@hdr#1keys}{% + \usename{\ifltxkeys@cl g\fi emptifycsn}{\ltxkeys@hdr#1keys}% }{% - \ltxkeys@err{No handled keys for prefix '\ltxkeys@ttpref' - \MsgBrk and family '\ltxkeys@tfam': couldn't emptify}\@ehc + \ltxkeys@err{No #1 keys for prefix '\ltxkeys@ttpref' + \MsgBrk and family '\ltxkeys@tfam'} + {I couldn't emptify #1-keys.}% }% } -\robust@def*\ltxkeys@testoptionkey#1{% - \ifcsndefFT{\ltxkeys@hdr#1option@keys}{}{% - \cpt@choicefdfalse - \def\ltxkeys@do##1{% - \s@expandarg\ifstrcmpTF\ltxkeys@tkey{##1}{% - \cpt@choicefdtrue\loopbreak - }{}% - }% - \aftercsname{\ltxkeys@csvloop*}{\ltxkeys@hdr#1option@keys}% - \if@boolFT{cpt@choicefd}{}{% - \ltxkeys@err{The following key should - \ifnullTF{#1}\@gobblespace{#1} appear in - \MsgBrk\noexpand\usepackage or \string\RequirePackage: - ^^J||\ltxkeys@ttpref, \ltxkeys@tfam, \ltxkeys@tkey||% - }\@ehc - }% +\robust@def*\ltxkeys@iftkeyinlist#1{% + \ifcsndefTF{\ltxkeys@hdr#1}{% + \letcstocsn\ltxkeys@tempa{\ltxkeys@hdr#1}% + \oifinset@sp@TF,\ltxkeys@tkey\ltxkeys@tempa + }{% + \@secondoftwo + }% +} +\robust@def*\ltxkeys@testsavevaluekey{% + \ltxkeys@debug{==}{Testing if '\ltxkeys@tkey' is a + savevalue key}% + \ltxkeys@iftkeyinlist{savevaluekeys}{% + \ltxkeys@svtrue + }{% + \ltxkeys@svfalse + \ltxkeys@debug{==}{'\ltxkeys@tkey' is not a savevalue key}% }% } -\robust@def*\ltxkeys@testneedvalkey{% +\robust@def*\ltxkeys@testoptionkey#1{% \begingroup - \cpt@choicefdfalse - \def\ltxkeys@do##1{% - \s@expandarg\ifstrcmpTF\ltxkeys@tkey{##1}{% - \cpt@choicefdtrue\loopbreak - }{}% + \def\ltxkeys@tempc{\ifstrcmpTF{#1}{non}{not }{}}% + \def\ltxkeys@tempd{\ifstrcmpTF{#1}{non}{}{not }}% + \ltxkeys@debug{==}{Testing if '\ltxkeys@tkey' is + \ltxkeys@tempc option key}% + \ltxkeys@iftkeyinlist{#1optionkeys}{% + \ltxkeys@err + {The following key should \ltxkeys@tempc + appear in \noexpand\usepackage or \string\RequirePackage: + ||\ltxkeys@ttpref, \ltxkeys@tfam, \ltxkeys@tkey||}% + {\ltxkeys@tempc option key error.}% + }{% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey' is + \ltxkeys@tempd option key}% }% - \aftercsname{\ltxkeys@csvloop*}{\ltxkeys@hdr needvalue@keys}% - \ifcpt@choicefd + \endgroup +} +\robust@def*\ltxkeys@testneedvaluekey{% + \ltxkeys@debug{==}{Testing if '\ltxkeys@tkey' is a needvalue key}% + \ltxkeys@iftkeyinlist{needvaluekeys}{% \ltxkeys@err{You're required to supply a value for - \MsgBrk key '\ltxkeys@tkey' in family '\ltxkeys@tfam'}{% - Please supply a value for key '\ltxkeys@tkey' of families + \MsgBrk key '\ltxkeys@tkey' in family '\ltxkeys@tfam'} + {Please supply a value for key '\ltxkeys@tkey' of families \MsgBrk'\ltxkeys@fams' and rerun. The author of this key - \MsgBrk meant it to require a user value. - }% - \fi - \endgroup + \MsgBrk meant it to require a user value.}% + }{% + \ltxkeys@debug{==}{'\ltxkeys@tkey' is not a + needvalue key}% + }% } -\new@def*\ltxkeys@setbool#1{% +\robust@def*\ltxkeys@setbool#1{% \xifstrcmpTF{#1}{on}{% \def#1{true}% }{% @@ -1164,19 +1979,28 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% }% } -\robust@def*\ltxkeys@accumkeyvals#1{% - \ltxkeys@ifinlistTF(1)% - {\ltxkeys@setmnkey,\setmnkey,\setaliaskey}{#1}% - \ltxkeys@twktrue\ltxkeys@twkfalse +\robust@def*\ltxkeys@accumkeyvals#1#2{% + \ifblankTF{#1}{% + \ltxkeys@twkfalse + }{% + \ltxkeys@ifinlistTF(1){% + \ltxkeys@setaliaskey,\setaliaskey + }{% + #2% + }{% + \ltxkeys@twktrue + }{% + \ltxkeys@twkfalse + }% + }% \begingroup + \edef\elt{\ifblankTF{#1}{}{\unexpanded{#1}}}% \edef\key@vals{% - \cptliststack,\key@vals\expandcsonce\key@name=% + \csliststack,\key@vals\expandcsonce\key@name=% \ifltxkeys@dep - \expandcsonce\key@default + \expandcsonce\elt \else - \oifstrcmpTF\key@default{true}{false}{% - \expandcsonce\key@default - }% + \ifstrcmpTF{#1}{true}{false}{\expandcsonce\elt}% \fi }% \ifltxkeys@ssk @@ -1193,47 +2017,36 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \endlinechar\m@one \cpt@teststopt\ltxkeys@definekeys@a{KV}% } -\robust@def*\ltxkeys@definekeys@a[#1]{% - \gletcs\ifdefkeyst\ifcpt@st - \cpt@testfam{\ltxkeys@definekeys@b#1}% +\robust@def*\ltxkeys@definekeys@a[#1]#2{% + \gletcs\ifltxkeys@keyst\ifcpt@st + \cpt@testopt{\expandafter\endgroup\ltxkeys@definekeys@b{#1}{#2}}{}% } -\robust@def*\ltxkeys@definekeys@b#1<#2>{% - \cpt@testopt - {\expandafter\endgroup\ltxkeys@definekeys@c{#1}{#2}}{}% -} -\robust@def*\ltxkeys@definekeys@c#1#2[#3]#4{% +\robust@def*\ltxkeys@definekeys@b#1#2[#3]#4{% + \ltxkeys@makepf{#1}% + \ltxkeys@makehdr{#2}% + \ltxkeys@dectrue \begingroup - \ltxkeys@trimspaces{#1}\key@prefix - \ltxkeys@trimspaces{#2}\key@family - \ltxkeys@trimspaces{#3}\macro@prefix - \toks@{\undefcs\ifdefkeyst}% - \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@tempa##1\ltxkeys@nil{% - \expandafter\ltxkeys@splitc\reserved@a/##1//\ltxkeys@nil - }% - \def\ltxkeys@splita##1={% - \def\reserved@a{##1}\ltxkeys@tempa.% - }% - \def\ltxkeys@splitb##1/{% - \def\reserved@a{##1}\ltxkeys@tempa.% + \ltxkeys@trimspacesset{% + {#1}\key@pref,{#2}\key@fam,{#3}\macro@pref }% + \toks@{}% + \def\key@vals{}% + \def\ltxkeys@splita##1={\ltxkeys@splitc##1/.}% + \def\ltxkeys@splitb##1/{\ltxkeys@splitc##1/.}% \def\ltxkeys@splitc##1/##2/##3/##4\ltxkeys@nil{% \ifblankTF{##1}{% - \ifblankTF{##2##3}{}{% - \ltxkeys@err{Empty key name while in - \string\ltxkeys@definekeys}\@ehc - }% + \ltxkeys@err{Empty key name while in + \string\ltxkeys@definekeys}\ltxkeys@ehc }{% - \ltxkeys@findneedvalue{##1}% + \ltxkeys@findpointers{##1}% \let\key@name\ltxkeys@tkey - \ifdefkeyst - \ifcsndefFT{\key@prefix @\key@family @\key@name}{}{% + \ifltxkeys@keyst + \ifcsndefFT{\ltxkeys@iffirstnull\key@pref @% + \ltxkeys@iffirstnull\key@fam @\key@name + }{}{% \ltxkeys@err{Key '\key@name' already defined in family - \MsgBrk '#2' with prefix '#1'}\@ehc + \MsgBrk '\iflacus#2\dolacus???\else#2\fi' with prefix + '\iflacus#1\dolacus???\else#1\fi'}\ltxkeys@ehc }% \fi \oifblankTF{\@gobble##2}{% @@ -1241,7 +2054,12 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }{% \s@expandarg\ltxkeys@trimspaces{\@gobble##2}\key@default }% - \ltxkeys@accumkeyvals{##3}% + \edef\key@macro{\unexpanded{##3}}% + \ltxkeys@stripdotcode\key@macro + \cptexpandsecond\ltxkeys@accumkeyvals{% + {\ifx\key@default\ltxkeys@rej\else\expandcsonce\key@default\fi}% + {\ifx\key@macro\ltxkeys@rej\else\expandcsonce\key@macro\fi}% + }% \def\defwith{\ltxkeys@boolkey}% \oifstrcmpTF\key@default{true}{}{% \oifstrcmpTF\key@default{false}{}{% @@ -1251,128 +2069,180 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \cptexpanded{% \toks@{\the\toks@ \cptmakecs{ltxkeys@twk\ifltxkeys@twk true\else false\fi}% - \defwith[\key@prefix]{\key@family}% - \ifx\macro@prefix\@empty\else[\macro@prefix]\fi - {\key@name}[\expandcsonce\key@default]{\unexpanded{##3}}% + \defwith[\key@pref]{\key@fam}% + \ifx\macro@pref\@empty\else[\macro@pref]\fi + {\expandcsonce\key@name}% + \ifx\key@default\ltxkeys@rej\else[\expandcsonce\key@default]\fi + \ifx\key@macro\ltxkeys@rej{}\else{\expandcsonce\key@macro}\fi }% }% }% }% - \long\def\csv@do##1{% - \cpt@checkeq##1\cpt@nil{% - \ltxkeys@splita##1\ltxkeys@nil + \def\ltxkeys@do##1{% + \ltxkeys@removedotcode{##1}\ltxkeys@tempa + \expandafter\ltxkeys@in\expandafter*\expandafter + =\expandafter{\ltxkeys@tempa}{% + \expandafter\ltxkeys@splita\ltxkeys@tempa/^?/^?/\ltxkeys@nil }{% - \ltxkeys@splitb##1///\ltxkeys@nil + \expandafter\ltxkeys@splitb\ltxkeys@tempa/^?/^?/\ltxkeys@nil }% }% - \expandafter\csv@@parse\expandafter[\ltxkeys@keyparser]{#4}% + \cptexpandsecond{\ltxkeys@parse1}{[\ltxkeys@keyparser]}{#4}% \cptexpandsecond\endgroup{% \the\toks@ \noexpand\ltxkeys@twkfalse - \ifcsnullTF\key@vals{}{\noexpand\ltxkeys@setkeys - [\key@prefix]{\key@family}{\expandcsonce\key@vals}% + \ltxkeys@ifcsemptyTF\key@vals{}{% + \noexpand\ltxkeys@setkeys[\key@pref]% + {\key@fam}{\expandcsonce\key@vals}% }% }% + \ltxkeys@decfalse } \new@def*\ltxkeys@badkeytypes{} -\robust@def*\ltxkeys@keytypeerr#1{% - \edef\ltxkeys@badkeytypes{\cptliststack,\ltxkeys@badkeytypes#1}% -} \robust@def*\ltxkeys@declarekeys{% \begingroup \endlinechar\m@one - \cpt@teststopt\ltxkeys@declarekeys@a{KV}% + \cpt@testst{\cpt@testpnopt\ltxkeys@declarekeys@a{}}% } -\robust@def*\ltxkeys@declarekeys@a[#1]{% - \gletcs\ifdefkeyst\ifcpt@st - \cpt@testfam{\ltxkeys@declarekeys@b{#1}}% +\robust@def*\ltxkeys@declarekeys@a(#1){% + \cpt@testopt{\ltxkeys@declarekeys@b{#1}}{KV}% } -\robust@def*\ltxkeys@declarekeys@b#1<#2>{% - \cpt@testopt{\expandafter\endgroup\ltxkeys@declarekeys@c{#1}#2}{}% +\robust@def*\ltxkeys@declarekeys@b#1[#2]#3{% + \gletcs\ifltxkeys@keyst\ifcpt@st + \cpt@testopt{\expandafter\endgroup + \ltxkeys@declarekeys@c{#1}{#2}{#3}}{}% } -\robust@def*\ltxkeys@declarekeys@c#1#2[#3]#4{% +\robust@def*\ltxkeys@declarekeys@c#1#2#3[#4]#5{% + \ltxkeys@makepf{#2}% + \ltxkeys@makehdr{#3}% \ltxkeys@dectrue \begingroup - \ltxkeys@trimspaces{#1}\key@prefix - \ltxkeys@trimspaces{#2}\key@family - \ltxkeys@trimspaces{#3}\macro@prefix + \ltxkeys@trimspacesset{% + {#2}\key@pref,{#3}\key@fam,{#4}\macro@pref + }% \def\key@vals{}% - \toks@{\undefcs\ifdefkeyst}% + \toks@{}% \def\ltxkeys@splita##1/##2/{% - \ifblankTF{##1##2}{% - \ltxkeys@warn{Something wrong in using \string\ltxkeys@declarekeys}\@ehc - \expandafter\gobble@to@sentinel\expandafter\ltxkeys@nil\ltxkeys@keyparser - }{% - \ifblankTF{##2}{% - \ltxkeys@err{Empty key name in \string\ltxkeys@declarekeys}\@ehc - }{% - \ltxkeys@trimspaces{##1}\key@type - \ltxkeys@findneedvalue{##2}% - \let\key@name\ltxkeys@tkey - \ifdefkeyst - \ifcsndefFT{\key@prefix @\key@family @\key@name}{}{% - \ltxkeys@err{Key '\key@name' already defined in family - \MsgBrk '#2' with prefix '#1'}\@ehc - }% - \fi - \oifstrcmpFT\key@type{choice}{}{% - \s@expandarg\ltxkeys@splitchoice\key@name - }% - \ltxkeys@splitb.% - }% + \ifescapedTF{##1}{% + \ltxkeys@err{Key type can't be a macro: '\detokenize{##1}'} + \ltxkeys@ehc + }{}% + \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@name}% + \xifstrcmpTF\key@type{choice}{% + \expandafter\ltxkeys@splitchoice\expandafter{\key@name}% + }{}% + \xifinsetTF{=}{\cptoxdetok\key@type}{% + \ltxkeys@err{The syntax of \noexpand\ltxkeys@definekeys may + \MsgBrk have been used for \string\ltxkeys@declarekeys. + \MsgBrk This may have come from \noexpand\ltxkeyscmd or + \MsgBrk \string\ltxkeysenv}\ltxkeys@ehc + }{}% + \ifx\key@type\@empty + \ltxkeys@err{Empty key type in \string\ltxkeys@declarekeys} + \ltxkeys@ehc + \fi + \ifx\key@name\@empty + \ltxkeys@err{Empty key name in \string\ltxkeys@declarekeys} + \ltxkeys@ehc + \fi + \ltxkeys@ifrejname{% + \ltxkeys@err{Wrong syntax for \string\ltxkeys@declarekeys} + \ltxkeys@ehc }% + \ifltxkeys@inkeycmd + \xifstrcmpFT\key@type{ord}{}{\def\key@type{cmd}}% + \fi + \expandafter\ltxkeys@findpointers\expandafter{\key@name}% + \let\key@name\ltxkeys@tkey + \ifx\key@type\key@name + \ltxkeys@err{Key type '\key@type' and key name '\key@name' + are identical}{Maybe you gave key type both in parenthesis + and in key list.}% + \fi + \ifltxkeys@keyst + \ifcsndefFT{\ltxkeys@hdr\key@name}{}{% + \ltxkeys@err{Key '\key@name' already defined in family + \MsgBrk '\iflacus#3\dolacus???\else#3\fi' with prefix + '\iflacus#2\dolacus???\else#2\fi'}\ltxkeys@ehc + }% + \fi + \ltxkeys@splitb.% }% \def\ltxkeys@splitb##1/##2/##3/##4\ltxkeys@nil{% \edef\key@default{\expandcsonce{\@gobble##1}}% - \ifcsnullTF\key@default{% - \oifstrcmpFT\key@type{bool}{}{\def\key@default{true}}% + \ltxkeys@ifcsemptyTF\key@default{% + \xifstrcmpTF\key@type{bool}{\def\key@default{true}}{}% }{% \ltxkeys@trimspacesincs\key@default }% - \oifinsetFT{sty}\key@type{}{\ltxkeys@declarekeys@d{##3}}% - \ltxkeys@accumkeyvals{##2}% - \def\ltxkeys@tempa{ord}% + \xifstrcmpTF\key@type{bool}{% + \ifx\key@default\ltxkeys@rej + \def\key@default{true}% + \ltxkeys@debug{!!}{Boolean key '\key@name' + has no default; 'true' used}% + \else + \begingroup + \def\ltxkeys@true{true}\def\ltxkeys@false{false}% + \ifcase0\ifx\key@default\ltxkeys@true\else\ifx\key@default + \ltxkeys@false\else1\fi\fi\relax\else + \ltxkeys@err{Invalid default value for boolean key + '\key@name'}\ltxkeys@ehc + \fi + \endgroup + \fi + }{}% + \edef\key@macro{\unexpanded{##2}}% + \ltxkeys@stripdotcode\key@macro + \expandafter\ltxkeys@striplaststar\key@type + \@empty*\@empty\ltxkeys@nil\key@@type + \xifinsetFT{,sty,}{,\key@@type,}{}{% + \ltxkeys@trimspaces{##3}\key@dependants + \ltxkeys@ifxTF\key@dependants\ltxkeys@rej{% + \def\key@dependants{}% + }{% + \expandafter\ltxkeys@declarekeys@e\expandafter{\key@dependants}% + }% + }% + \cptexpandsecond\ltxkeys@accumkeyvals{% + {\ifx\key@default\ltxkeys@rej\else\expandcsonce\key@default\fi}% + {\ifx\key@macro\ltxkeys@rej\else\expandcsonce\key@macro\fi}% + }% + \def\dkey@macro{% + \ifx\key@macro\ltxkeys@rej{}\else{\expandcsonce\key@macro}\fi + }% + \def\dkey@default{% + \ifx\key@default\ltxkeys@rej\else[\expandcsonce\key@default]\fi + }% + \s@expandarg\ltxkeys@declarekeys@d\key@type + \def\reserved@a{ord}% \edef\ltxkeys@tempa{% - [\key@prefix]{\key@family}% - \ifx\key@type\ltxkeys@tempa\else\ifx\macro@prefix\@empty\else - [\macro@prefix]\fi\fi - {\key@name}% + [\key@pref]{\key@fam}% + \ifx\key@type\reserved@a\else\ifx\macro@pref\@empty\else + [\macro@pref]\fi\fi{\expandcsonce\key@name}% }% \cptpassexpanded{% \toks@{\the\toks@ \cptmakecs{ltxkeys@twk\ifltxkeys@twk true\else false\fi}% - \IfStrEqCase[\ltxkeys@keytypeerr{\expandcsonce\key@type}]% - {\key@type}{% - {sty}{% - \ltxkeys@stylekey\ltxkeys@tempa - [\expandcsonce\key@default](\expandcsonce\ltxkeys@dependant)% - {\unexpanded{##2}}% - }% - {sty*}{% - \ltxkeys@stylekey*\ltxkeys@tempa - [\expandcsonce\key@default](\expandcsonce\ltxkeys@dependant)% - {\unexpanded{##2}}% - }% - {cmd}{% - \ltxkeys@cmdkey\ltxkeys@tempa - [\expandcsonce\key@default]{\unexpanded{##2}}% - }% - {bool}{% - \ltxkeys@boolkey+\ltxkeys@tempa - [\expandcsonce\key@default]{\unexpanded{##2}}% - {\ltxkeys@keyvalerr}% - }% - {choice}{% - \ltxkeys@choicekey*+\ltxkeys@tempa - [\unexpanded{\userinput\nr}]{\expandcsonce\ltxkeys@alt}% - [\expandcsonce\key@default]{\unexpanded{##2}}% - {\ltxkeys@keyvalerr}% - }% - {ord}{% - \ltxkeys@ordkey\ltxkeys@tempa - [\expandcsonce\key@default]{\unexpanded{##2}}% - }% - }% + \ifcase\currmatch\relax + \ltxkeys@cmdkey\ltxkeys@tempa\dkey@default\dkey@macro + \or + \ltxkeys@boolkey+\ltxkeys@tempa\dkey@default + \dkey@macro{\ltxkeys@keyvalerr}% + \or + \ltxkeys@ordkey\ltxkeys@tempa\dkey@default\dkey@macro + \or + \ltxkeys@choicekey*+\ltxkeys@tempa + [\unexpanded{\userinput\order}]{\expandcsonce\ltxkeys@alt}% + \dkey@default\dkey@macro{\ltxkeys@keyvalerr}% + \or + \ltxkeys@stylekey\ltxkeys@tempa\dkey@default + (\expandcsonce\key@dependants)\dkey@macro + \or + \ltxkeys@stylekey*\ltxkeys@tempa\dkey@default + (\expandcsonce\key@dependants)\dkey@macro + \else + \cptgaddtolist\noexpand\ltxkeys@badkeytypes{\key@type}% + \fi }% }% }% @@ -1381,84 +2251,217 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }{% \def\ltxkeys@keyparser{;}% }% - \def\csv@do##1{% - \ltxkeys@splita##1/////\ltxkeys@nil + \ifblankTF{#1}{% + \edef\ltxkeys@tempa{\unexpanded{#5}}% + }{% + \def\ltxkeys@tempa{}% + \def\ltxkeys@do##1{% + \edef\ltxkeys@tempa{% + \expandafter\csliststack\ltxkeys@keyparser + \ltxkeys@tempa#1/\unexpanded{##1}% + }% + }% + \cptexpandsecond{\ltxkeys@parse0}{[\ltxkeys@keyparser]}{#5}% }% - \expandafter\csv@@loop\expandafter[\ltxkeys@keyparser]{#4}% + \def\ltxkeys@do##1{% + \ifblankTF{##1}{}{% + \ltxkeys@splita##1/^?/^?/^?/^?/\ltxkeys@nil + }% + }% + \cptexpandsecond{\ltxkeys@parse0} + {[\ltxkeys@keyparser]{\expandcsonce\ltxkeys@tempa}}% \cptexpandsecond\endgroup{% \the\toks@ \noexpand\ltxkeys@twkfalse \edef\noexpand\key@vals{\ox@unexpanded\key@vals}% }% \ifx\ltxkeys@badkeytypes\@empty\else - \cpt@err{Invalid key types '\ltxkeys@badkeytypes'}\@ehc + \cpt@err{Invalid key types '\ltxkeys@badkeytypes'}\ltxkeys@ehc \fi - \ifcsnullTF\key@vals{}{% - \cptexpandargonce{\ltxkeys@setkeys[#1]{#2}}\key@vals + \ltxkeys@ifcsemptyTF\key@vals{}{% + \cptexpandargonce{\ltxkeys@setkeys[#2]{#3}}\key@vals }% \ltxkeys@decfalse } \robust@def\ltxkeys@declarekeys@d#1{% + \ltxkeys@findmatch + {#1}{cmd:0,bool:1,ord:2,choice:3,sty:4,syt*:5}% + {\def\currmatch{-1}}% +} +\robust@def\ltxkeys@declarekeys@e#1{% + \ifblankTF{#1}{% + \def\key@dependants{}\cpt@gobbletorelax + }{}% \begingroup + \ifinsetTF{>}{#1}{}{% + \ltxkeys@warn{Missing '>' in dependants of key '\ltxkeys@tkey'}% + }% + \def\ltxkeys@splita##1>##2>{% + \def\key@type{##1}% + \edef\key@name{\unexpanded{##2}}% + \ltxkeys@splitb.% + }% + \def\ltxkeys@splitb##1>##2>##3\ltxkeys@nil{% + \edef\key@default{\expandcsonce{\@gobble##1}}% + \edef\key@macro{\unexpanded{##2}}% + \ltxkeys@stripdotcode\key@macro + \ltxkeys@ifrejname{% + \ltxkeys@err{Wrong syntax for dependants keys in + \MsgBrk\string\ltxkeys@declarekeys}\ltxkeys@ehc + }% + \edef\key@dependants{% + \expandafter\csliststack\ltxkeys@keyparser\key@dependants + \key@type/\expandcsonce\key@name + \ifx\key@default\ltxkeys@rej\else/\expandcsonce\key@default\fi + \ifx\key@macro\ltxkeys@rej\else/\expandcsonce\key@macro\fi + }% + }% + \def\key@dependants{}% + \def\ltxkeys@do##1{% + \ltxkeys@splita##1>^?>^?>^?>\ltxkeys@nil + }% + \ltxkeys@parse1[,]{#1}% + \postgroupdef\key@dependants\endgroup + \cpt@relax +} +\robust@def*\ltxkeys@savexfamilykeys{% + \begingroup + \endlinechar\m@one + \cpt@testst{\cpt@testltopt\ltxkeys@savexf@milykeys{}}% +} +\robust@def*\ltxkeys@savexf@milykeys<#1>{% + \cpt@testpnopt{\ltxkeys@savexf@milyk@ys{#1}}{}% +} +\robust@def*\ltxkeys@savexf@milyk@ys#1(#2)#3{% \ifblankTF{#1}{% - \def\ltxkeys@dependant{}% + \ltxkeys@err{Empty set-identifier for \string\xfamilykeys: + ||\detokenize{#3}||}\ltxkeys@ehc + }{}% + \ltxkeys@trimspaces{#1}\ltxkeys@tempb + \ifcsndefTF{xfamilykeys@id@\ltxkeys@tempb}{% + \ltxkeys@err{xfamilykeys identifier '\ltxkeys@tempb' + already in use}\ltxkeys@ehc + }{}% + \cpt@stchoose{cpt@st}{#3}\ltxkeys@tempa\ltxkeys@savexfamilykeys + \ifblankTF{#2}{}{% + \def\ltxkeys@do##1{% + \edef\ltxkeys@tempa{% + \expandafter\csliststack\ltxkeys@keyparser + \ltxkeys@tempa#2/\unexpanded{##1}% + }% + }% + \cptexpandsecond{\def\ltxkeys@tempa{}\ltxkeys@parse1} + {[\ltxkeys@keyparser]{\expandcsonce\ltxkeys@tempa}}% + }% + \cptexpandsecond{\endgroup\csn@edef} + {{xfamilykeys@id@\ltxkeys@tempb}{\ox@unexpanded\ltxkeys@tempa}}% +} + +\robust@def*\ltxkeys@definexfamilykeys{% + \begingroup + \cpt@testst{\cpt@testltopt\ltxkeys@d@finexfamilykeys{}}% +} +\robust@def*\ltxkeys@d@finexfamilykeys<#1>{% + \edef\defwith{\ltxkeys@declarekeys\ifcpt@st*\fi}% + \ifblankTF{#1}{% + \ltxkeys@err{Invalid empty xfamilykeys identifier + \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehc + }{}% + \ltxkeys@trimspaces{#1}\ltxkeys@tempa + \ifcsndefTF{xfamilykeys@id@\ltxkeys@tempa}{% + \expandafter\cpt@testopt\expandafter{\expandafter + \ltxkeys@d@fin@xfamilykeys\expandafter{\ltxkeys@tempa}}{KV}% }{% - \ifinsetFT{>}{#1}{% - \ltxkeys@err{Missing key type and name in dependant key - ^^J\detokenize{#1}'}{No '>' in dependant key.}% - \def\ltxkeys@dependant{}% + \ltxkeys@err{Unknown xfamilykeys identifier '\ltxkeys@tempa' + \MsgBrk in \string\ltxkeys@definexfamilykeys}\ltxkeys@ehc + }% +} +\robust@def*\ltxkeys@d@fin@xfamilykeys#1[#2]#3{% + \cpt@testopt{\ltxkeys@d@fin@xf@milykeys{#1}{#2}{#3}}{}% +} +\robust@def*\ltxkeys@d@fin@xf@milykeys#1#2#3[#4]#5{% + \def\ltxkeys@na{#5}% + \def\ltxkeys@splita##1/##2/{% + \ltxkeys@trimspacesset{{##1}\key@type,{##2}\key@n@me}% + \xifstrcmpTF\key@type{choice}{% + \expandafter\ltxkeys@splitchoice\expandafter{\key@n@me}% }{% - \def\ltxkeys@tempa##1>##2>##3>##4>##5\ltxkeys@nil{% - \edef\ltxkeys@dependant{\unexpanded{##1/##2/##3/##4}}% + \let\key@name\key@n@me + }% + \ltxkeys@splitb.% + }% + \def\ltxkeys@splitb##1/##2/##3/##4\ltxkeys@nil{% + \edef\key@default{\expandcsonce{\@gobble##1}}% + \edef\key@macro{\unexpanded{##2}}% + \edef\key@dependants{\unexpanded{##3}}% + \oifinset@sp@TF,\key@name\ltxkeys@na{}{% + \let\do\expandcsonce + \edef\ltxkeys@tempa{% + \expandafter\csliststack\ltxkeys@keyparser + \ltxkeys@tempa\key@type/\do\key@n@me + \ifx\key@default\ltxkeys@rej\else/\do\key@default\fi + \ifx\key@macro\ltxkeys@rej\else/\do\key@macro\fi + \ifx\key@dependants\ltxkeys@rej\else/\do\key@dependants\fi }% - \ltxkeys@tempa#1>>>>\ltxkeys@nil }% }% - \postgroupdef\ltxkeys@dependant\endgroup + \def\ltxkeys@tempa{}% + \def\ltxkeys@do##1{% + \ltxkeys@splita##1/^?/^?/^?/^?/\ltxkeys@nil + }% + \cptexpandsecond{\ltxkeys@parse1} + {[\ltxkeys@keyparser]{\expandcsnonce{xfamilykeys@id@#1}}}% + \cptexpandsecond\endgroup + {\defwith[#2]{#3}[#4]{\expandcsonce\ltxkeys@tempa}}% } + \robust@def*\ltxkeys@presetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{ppsetkeys}{pre}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{ppsetkeys}{pre}}% } +\newletcs\ltxkeys@addpresetkeys\ltxkeys@presetkeys \robust@def*\ltxkeys@removepresetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{removeppsetkeys}{pre}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{removeppsetkeys}{pre}}% } \robust@def*\ltxkeys@undefpresetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{undefppsetkeys}{pre}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{undefppsetkeys}{pre}}% } \robust@def*\ltxkeys@postsetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{ppsetkeys}{post}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{ppsetkeys}{post}}% } +\newletcs\ltxkeys@addpostsetkeys\ltxkeys@postsetkeys \robust@def*\ltxkeys@removepostsetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{removeppsetkeys}{post}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{removeppsetkeys}{post}}% } \robust@def*\ltxkeys@undefpostsetkeys{% - \cpt@testcl{\ltxkeys@testopt@g{undefppsetkeys}{post}}% + \ltxkeys@testcl{\ltxkeys@testopt@g{undefppsetkeys}{post}}% } \robust@def*\ltxkeys@ppsetkeys#1#2{% - \def\ltxkeys@rsvda{}\def\ltxkeys@rsvdb{}% + \def\ltxkeys@rsvda{}% + \def\ltxkeys@rsvdb{}% \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.}\@ehc + \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined.} + \ltxkeys@ehc }{% \ifcsndefTF{@\ltxkeys@hdr#1setkeys}{}{% - \emptifycsn{@\ltxkeys@hdr#1setkeys}% + \cptemptifycsn{@\ltxkeys@hdr#1setkeys}% }% \xifinsetTF{,\cptoxdetok\ltxkeys@tkey,} {,\cptsxdetok{\usename{@\ltxkeys@hdr#1setkeys},}}{% \ltxkeys@err{Double entry for key '\ltxkeys@currtriple' in\MsgBrk - #1set key list}\@ehc + #1set key list}\ltxkeys@ehc }{% - \edef\ltxkeys@rsvda{\cptliststack,\ltxkeys@rsvda - \ltxkeys@tkey\ifcsemptyTF\ltxkeys@tval{} + \edef\ltxkeys@rsvda{\csliststack,\ltxkeys@rsvda + \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{} {=\expandcsonce\ltxkeys@tval}}% - \edef\ltxkeys@rsvdb{\cptliststack,\ltxkeys@rsvdb + \edef\ltxkeys@rsvdb{\csliststack,\ltxkeys@rsvdb \expandcsonce\ltxkeys@tkey}% }% }% }% - \ltxkeys@kvparse{#2}% - \ifcsemptyTF\ltxkeys@rsvda{}{% + \ltxkeys@parse3{#2}% + \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% \ifcsndefTF{\ltxkeys@hdr#1setkeys}{% \cptpassexpanded{% \cptfiltermergekv\noexpandcsn{\ltxkeys@hdr#1setkeys}% @@ -1470,7 +2473,7 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \csn@edef{\ltxkeys@hdr#1setkeys}{\expandcsonce\ltxkeys@rsvda}% \csn@edef{@\ltxkeys@hdr#1setkeys}{\expandcsonce\ltxkeys@rsvdb}% }% - \ifcpt@cl + \ifltxkeys@cl \globalizecsn{\ltxkeys@hdr#1setkeys}% \globalizecsn{@\ltxkeys@hdr#1setkeys}% \fi @@ -1479,35 +2482,37 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@removeppsetkeys#1#2{% \ifcsndefFT{\ltxkeys@hdr#1setkeys}{% \ltxkeys@err{No #1set keys defined for prefix '\ltxkeys@ttpref' - and family '\ltxkeys@tfam'}\@ehc + and family '\ltxkeys@tfam'}\ltxkeys@ehc }{% \def\ltxkeys@rsvda{}\def\ltxkeys@rsvdb{}% \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}\@ehc + \ltxkeys@err{Key '\ltxkeys@currtriple' is undefined} + \ltxkeys@ehc }{% \xifinsetTF{,\cptoxdetok\ltxkeys@tkey=\cptoxdetok\ltxkeys@tval,}% {,\cptsxdetok{\usename{\ltxkeys@hdr#1setkeys}},}{% - \edef\ltxkeys@rsvda{\cptliststack,\ltxkeys@rsvda - \ltxkeys@tkey\ifcsemptyTF\ltxkeys@tval{} + \edef\ltxkeys@rsvda{\csliststack,\ltxkeys@rsvda + \ltxkeys@tkey\ltxkeys@ifcsemptyTF\ltxkeys@tval{} {=\expandcsonce\ltxkeys@tval}}% - \edef\ltxkeys@rsvdb{\cptliststack,\ltxkeys@rsvdb + \edef\ltxkeys@rsvdb{\csliststack,\ltxkeys@rsvdb \expandcsonce\ltxkeys@tkey}% }{% - \ltxkeys@err{Key '\ltxkeys@currtriple' not a #1set key}\@ehc + \ltxkeys@err{Key '\ltxkeys@currtriple' not a #1set key} + \ltxkeys@ehc }% }% }% - \ltxkeys@kvparse{#2}% - \ifcsemptyTF\ltxkeys@rsvda{}{% + \ltxkeys@parse3{#2}% + \ltxkeys@ifcsemptyTF\ltxkeys@rsvda{}{% \cptpassexpanded{% \cptfilterremovekv\noexpandcsn{\ltxkeys@hdr#1setkeys} {\expandcsonce\ltxkeys@rsvda}\noexpand\nofilter \cptfilterremovecsv\noexpandcsn{@\ltxkeys@hdr#1setkeys} {\ltxkeys@rsvdb}\noexpand\nofilter }% - \ifcpt@cl + \ifltxkeys@cl \globalizecsn{\ltxkeys@hdr#1setkeys}% \globalizecsn{@\ltxkeys@hdr#1setkeys}% \fi @@ -1517,29 +2522,32 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \robust@def*\ltxkeys@undefppsetkeys#1{% \ifcsndefFT{\ltxkeys@hdr#1setkeys}{% \ltxkeys@err{No #1set keys defined for prefix '\ltxkeys@ttpref' - and family '\ltxkeys@tfam'}\@ehc + and family '\ltxkeys@tfam'}\ltxkeys@ehc }{% - \usename{\ifcpt@cl g\fi undefcsn}{\ltxkeys@hdr#1setkeys}% - \usename{\ifcpt@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}% }% } -\robust@def*\ltxkeys@setmnkey#1{% - \xifinsetTF{,}{\detokenize{#1}}{% - \ltxkeys@err{\noexpand\ltxkeys@setmnkey doesn't accept key list}\@ehc +\robust@def*\ltxkeys@setaliaskey#1{% + \ltxkeys@commanormalize{#1}\ltxkeys@tempa + \xifinsetTF{,}{\cptoxdetok\ltxkeys@tempa}{% + \ltxkeys@err{\noexpand\ltxkeys@setaliaskey doesn't + accept key list}\ltxkeys@ehc }{% - \cpt@testopt{\ltxkeys@s@tmnkey#1}{}% + \cptexpandarg\cpt@testopt{\ltxkeys@s@taliaskey\ltxkeys@tempa}{}% }% } -\robust@def*\ltxkeys@s@tmnkey#1[#2]{% +\newletcs\setaliaskey\ltxkeys@setaliaskey +\robust@def*\ltxkeys@s@taliaskey#1[#2]{% \begingroup - \let\x\ltxkeys@tkey\let\y\noexpand - \edef\z{\expandcstwice{\csname\ltxkeys@hdr#1\endcsname{}}}% + \let\x\ltxkeys@tkey + \edef\y{\expandcstwice{\csname\ltxkeys@hdr#1\endcsname{}}}% \cptexpandsecond{\endgroup\ltxkeys@ifinlistTF(1)}{% - {\y\ltxkeys@setmnkey{\x},\y\setmnkey{\x},\y\setaliaskey{\x}}% - {\expandcsonce\z}% + {\ltxkeys@setaliaskey{\x},\setaliaskey{\x}}% + {\expandcsonce\y}% }{% - \ltxkeys@err{\noexpand\ltxkeys@setmnkey or \noexpand\setmnkey - or \noexpand\setaliaskey nested}\@ehc + \ltxkeys@err{\noexpand\ltxkeys@setaliaskey + or \noexpand\setaliaskey nested}\ltxkeys@ehc }{}% \cptexpandsecond\ltxkeys@setkeys{% [\ltxkeys@ttpref]{\ltxkeys@tfam}{% @@ -1547,34 +2555,35 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% }% } -\newletcs\setmnkey\ltxkeys@setmnkey -\newletcs\setaliaskey\ltxkeys@setmnkey \robust@def*\ltxkeys@splitchoice#1{% \begingroup \def\ltxkeys@tempa##1.##2##3\ltxkeys@nil{\endgroup \ltxkeys@trimspaces{##1}\key@name \ifstrcmpTF{##2}{.}{% - \ltxkeys@err{Invalid alternate value list for key '#1'}\@ehc + \ltxkeys@err{Invalid alternate value list for key '#1'} + \ltxkeys@ehc }{% \ifmacroTF{##2}{% \edef\ltxkeys@alt{\expandcsonce{##2}}% }{% \edef\ltxkeys@alt{\unexpanded{##2}}% }% - \despacecontent\ltxkeys@alt + \ltxkeys@trimspacesincs\ltxkeys@alt }% }% \ltxkeys@tempa#1..\ltxkeys@nil } \robust@def*\ltxkeys@setinitialkeyvals#1#2{% - \ifcsndefFT{#1@#2@initial@keyvals}{}{% - \ifcsnnullTF{#1@#2@initial@keyvals}{}{% + \ltxkeys@initrue + \ifcsndefFT{#1@#2@initialkeyvals}{}{% + \ifcsnnullTF{#1@#2@initialkeyvals}{}{% \cptpassexpanded{% \noexpand\ltxkeys@setkeys[#1]{#2}% - {\expandcsnonce{#1@#2@initial@keyvals}}% + {\expandcsnonce{#1@#2@initialkeyvals}}% }% }% }% + \ltxkeys@inifalse } \robust@def*\ltxkeys@initializekeys{% \cpt@testopt\ltxkeys@in@tializekeys{KV}% @@ -1583,40 +2592,135 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \cpt@testopt{\ltxkeys@in@ti@lizekeys{#1}{#2}}{}% } \robust@def*\ltxkeys@in@ti@lizekeys#1#2[#3]{% + \ltxkeys@initrue \begingroup \def\ltxkeys@resa{}% \def\ltxkeys@do##1{% + \ltxkeys@makepf{##1}% \def\ltxkeys@do####1{% - \edef\ltxkeys@resa{% - \cptliststack,\ltxkeys@resa - \ifcsndefFT{##1@####1@initial@keyvals}{}{% - \expandcsnonce{##1@####1@initial@keyvals}% - }% - }% + \ltxkeys@makehdr{####1}% + \letcstocsn\ltxkeys@tempc{\ltxkeys@hdr initialkeyvals}% + \ifdefTF\ltxkeys@tempc{% + \ltxkeys@remdispox\ltxkeys@tempc + \cptexpandargonce{\cptfiltermergecsv[,]\ltxkeys@resa} + \ltxkeys@tempc\nofilter + }{}% }% - \ltxkeys@csvparse{#2}% + \ltxkeys@parse1{#2}% }% - \ltxkeys@csvparse{#1}% + \ltxkeys@parse1{#1}% \ltxkeys@getkeynames{#3}% \cptexpandsecond{\endgroup\ltxkeys@setkeys*+[#1]{#2}}% - {[\ltxkeys@keynames]{\ltxkeys@resa}}% + {[\ltxkeys@keynames]{\expandcsonce\ltxkeys@resa}}% + \ltxkeys@inifalse +} +\robust@def*\ltxkeys@remdispox#1{% + \begingroup + \letcstocsn\ltxkeys@tempd{\ltxkeys@hdr disabledkeys}% + \ifdefTF\ltxkeys@tempd{}{\def\ltxkeys@tempd{}}% + \letcstocsn\ltxkeys@tempe{\ltxkeys@hdr poxkeys}% + \ifdefTF\ltxkeys@tempe{}{\def\ltxkeys@tempe{}}% + \ltxkeys@ifcsemptyTF\ltxkeys@tempd{% + \ltxkeys@ifcsemptyTF\ltxkeys@tempe\cpt@gobbletorelax\relax + }{}% + \edef\ltxkeys@tempd + {\expandcsonce\ltxkeys@tempd,\expandcsonce\ltxkeys@tempe}% + \def\ltxkeys@do##1{% + \ltxkeys@getkeyname##1=\ltxkeys@nil\ltxkeys@tkey + \xifinsetTF{,\ltxkeys@tkey,}{,\expandcsonce\ltxkeys@tempd,}{}{% + \edef#1{\csliststack,#1\unexpanded{##1}}% + }% + }% + \cptexpandargonce{\def#1{}\ltxkeys@parse3}{#1}% + \cpt@relax + \postgroupdef#1\endgroup +} +\robust@def*\ltxkeys@launchkeys{% + \ltxkeys@teststpl{\cpt@testopt\ltxkeys@l@unchkeys{KV}}% } -\robust@def*\ltxkeys@launchkeys{\cpt@testopt\ltxkeys@l@unchkeys{KV}} \robust@def*\ltxkeys@l@unchkeys[#1]#2#3{% - \ltxkeys@in@ti@lizekeys{#1}{#2}[#3]% - % Don't use the star/plus forms of \ltxkeys@setkeys here, - % otherwise we won't be able to catch undefined keys: - \ifblankTF{#3}{}{\ltxkeys@setkeys[#1]{#2}{#3}}% + \edef\ltxkeys@cmdpf{\ifltxkeys@st*\fi\ifltxkeys@pl+\fi}% + \ltxkeys@commanormalizeset{{#1}\ltxkeys@prefs,{#2}\ltxkeys@fams}% + \xifinsetTF{,}\ltxkeys@fams{% + \ifltxkeys@pl\else + \ltxkeys@err{Multiple key families: you need + prefix + \MsgBrk for command \string\ltxkeys@launchkeys}\ltxkeys@ehc + \fi + }{}% + \cptexpandsecond\ltxkeys@in@ti@lizekeys + {{\ltxkeys@prefs}{\ltxkeys@fams}}[#3]% + \ifblankTF{#3}\cpt@gobbletorelax\relax + \begingroup + \def\ltxkeys@resa{}% + \def\ltxkeys@do##1{% + \ltxkeys@makepf{##1}% + \def\ltxkeys@do####1{% + \ltxkeys@makehdr{####1}% + \edef\ltxkeys@tempc{\unexpanded{#3}}% + \ltxkeys@remdispox\ltxkeys@tempc + \cptexpandargonce{\cptfiltermergecsv[,]\ltxkeys@resa} + \ltxkeys@tempc\nofilter + }% + \ltxkeys@parse*0\ltxkeys@fams + }% + \ltxkeys@parse*0\ltxkeys@prefs + \cptexpandargonce{\endgroup\expandafter\undefcs\expandafter + \ltxkeys@cmdpf\expandafter\ltxkeys@setkeys + \ltxkeys@cmdpf[#1]{#2}}\ltxkeys@resa + \cpt@relax +} +\robust@def*\ltxkeys@nonlaunchkeys{% + \cpt@teststopt{\ltxkeys@nonl@unchkeys}{KV}% +} +\newletcs\ltxkeys@noninitializekeys\ltxkeys@nonlaunchkeys +\robust@def*\ltxkeys@nonl@unchkeys[#1]#2#3{% + \ifboolTF{cpt@st}{% + \AtBeginDocument{\ltxkeys@nonl@un@hkeys{#1}{#2}{#3}}% + }{% + \ltxkeys@nonl@un@hkeys{#1}{#2}{#3}% + }% +} +\robust@def*\ltxkeys@nonl@un@hkeys#1#2#3{% + \ltxkeys@commanormalizeset + {{#1}\ltxkeys@prefs,{#2}\ltxkeys@fams,{#3}\ltxkeys@keys}% + \def\ltxkeys@do##1{% + \ltxkeys@makepf{##1}% + \def\ltxkeys@do####1{% + \ltxkeys@makehdr{####1}% + \ltxkeys@nonl@un@hk@ys + }% + \ltxkeys@parse*0\ltxkeys@fams + }% + \ltxkeys@parse*0\ltxkeys@prefs +} +\robust@def*\ltxkeys@nonl@un@hk@ys{% + \ifcsndefTF{\ltxkeys@hdr poxkeys}{}{% + \csn@def{\ltxkeys@hdr poxkeys}{}% + }% + \letcstocsn\ltxkeys@tempc{\ltxkeys@hdr poxkeys}% + \def\ltxkeys@do##1{% + \ifcsndefTF{\ltxkeys@hdr##1}{% + \xifinsetTF{,##1,}{,\expandcsonce\ltxkeys@tempc,}{}{% + \edef\ltxkeys@tempc{% + \csliststack,\ltxkeys@tempc\unexpanded{##1}% + }% + }% + }{}% + }% + \ltxkeys@parse*0\ltxkeys@keys + \letcsntocs{\ltxkeys@hdr poxkeys}\ltxkeys@tempc } \robust@def*\ltxkeys@setkeys{% \ltxkeys@rmfalse \ltxkeys@teststpl{\ltxkeys@testopt@c\ltxkeys@setkeys@a}% } +\newletcs\ltxkeys@setkey\ltxkeys@setkeys \robust@def*\ltxkeys@setrmkeys{% \ltxkeys@rmtrue \ltxkeys@teststpl{\ltxkeys@testopt@c\ltxkeys@setrmkeys@a}% } \robust@def*\ltxkeys@setrmkeys@a[#1]{% + \ltxkeys@debug{==}{Setting 'remaining' keys now}% \cptexpandarg{\ltxkeys@setkeys@a[#1]} {\expandcsnonce{\ltxkeys@hdr rmkeys}}% } @@ -1625,9 +2729,13 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \def\x{\ltxkeys@nil}% \xifinsetTF{\x\detokenize{#2}\x} {\x.\x,\x;\x:\x+\x-\x=\x*\x^\x_\x/\x|\x[\x(\x)\x]\x}{% - \ltxkeys@err{Invalid key list '#2': Something is wrong}\@ehc + \ltxkeys@err{Invalid key list '#2': Something is wrong} + \ltxkeys@ehc }{}% \endgroup + \ifcsndefTF{\ltxkeys@hdr executedkeys}{}{% + \csn@def{\ltxkeys@hdr executedkeys}{}% + }% \ifnum\ltxkeys@keydepth=\z@pt \csn@def{\ltxkeys@hdr rmkeys}{}% \def\ltxkeys@undefinedkeys{}% @@ -1635,27 +2743,37 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@getkeynames{#2}% \let\ltxkeys@naa\ltxkeys@keynames \ifblankTF{#1}{}{% - \edef\ltxkeys@naa{\cptliststack,\ltxkeys@naa\unexpanded{#1}}% + \edef\ltxkeys@naa{\csliststack,\ltxkeys@naa\unexpanded{#1}}% }% + \ifboolTF{ltxkeys@tracingkeys}{% + \ltxkeys@getbasechars*[30]\ltxkeys@keynames\ltxkeys@tempa + \edef\ltxkeys@tempb{\ifnum\ltxkeys@charcount>30\string\ETC\fi}% + \wlog{\@spaces(on level \the\ltxkeys@keydepth)}% + \ltxkeys@debug{==}{Setting keys: '\ltxkeys@tempa\ltxkeys@tempb'}% + }{}% \ltxkeys@usepresetkeys{pre}% \ltxkeys@setkeys@b{#1}{#2}% \ltxkeys@usepresetkeys{post}% - \ltxkeys@exopfalse\ltxkeys@pxopfalse \ifnumcmpTF\ltxkeys@keydepth=\z@pt{% - \emptifycsset{% - \ltxkeys@keys,\ltxkeys@prefs,\ltxkeys@fams,\ltxkeys@nakeys,% - \ltxkeys@naa,\ltxkeys@tpref,\ltxkeys@ttpref,\ltxkeys@tfam,% - \ltxkeys@tkey,\ltxkeys@tval,\CurrentPref,\CurrentFam,% - \CurrentKeyval,\CurrentKey,\CurrentVal,\ltxkeys@naa + \ltxkeys@debug{==}{Setting keys, returned to level 0}% + \ltxkeys@ifcsemptyTF\ltxkeys@undefinedkeys{% + \ltxkeys@debug{==}{No undefined keys in this run}% + }{% + \ltxkeys@debug{==}{There're undefined keys; logging them}% + \ltxkeys@logunknownkeys }% - \ifcsemptyTF\ltxkeys@undefinedkeys{}\ltxkeys@logunknownkeys }{}% + \ifltxkeys@exop + \ltxkeys@exopfalse + \ltxkeys@debug{==}{Ended executing options}% + \fi + \ltxkeys@pxopfalse } \robust@def*\ltxkeys@usepresetkeys#1{% - \ltxkeys@inpresettrue + \ltxkeys@presettrue \begingroup \toks@{}% - \ltxkeys@vinfo{Looking for #1-set keys}% + \ltxkeys@debug{==}{Looking for #1-set keys}% \def\ltxkeys@do##1{% \ltxkeys@makepf{##1}% \def\ltxkeys@do####1{% @@ -1666,45 +2784,48 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ {\expandcsnonce{\ltxkeys@hdr#1setkeys}}}}% }% }% - \ltxkeys@csvloop*\ltxkeys@fams + \ltxkeys@parse*0\ltxkeys@fams }% - \ltxkeys@csvloop*\ltxkeys@prefs + \ltxkeys@parse*0\ltxkeys@prefs \oifblankTF{\the\toks@}{% \endgroup - \ltxkeys@vinfo{No #1-set keys found}% + \ltxkeys@debug{==}{No #1-set keys found}% }{% - \ltxkeys@vinfo{P\@gobble#1-set keys found. Setting them now}% + \ltxkeys@debug{==}{P\@gobble#1-set keys found. Setting them now}% \expandafter\endgroup\the\toks@ - \ltxkeys@vinfo{Finished setting #1-set keys}% + \ltxkeys@debug{++}{Finished setting #1-set keys}% }% - \ltxkeys@inpresetfalse + \ltxkeys@presetfalse } \robust@def*\ltxkeys@setkeys@b#1#2{% \ifblankTF{#1}{% \def\ltxkeys@nakeys{}% }{% - \edef\ltxkeys@nakeys{\cptcommanormalize{#1}}% + \ltxkeys@commanormalize{#1}\ltxkeys@nakeys }% \def\ltxkeys@do##1{% \edef\CurrentKeyval{\unexpanded{##1}}% \ltxkeys@getkeyvalue##1=\ltxkeys@nil\ltxkeys@tval \ltxkeys@setkeys@c##1=\ltxkeys@nil }% - \ltxkeys@kvparse{#2}% + \ltxkeys@parse3{#2}% } \robust@def*\ltxkeys@setkeys@c#1=#2\ltxkeys@nil{% \ifinsetTF{\needvalue}{#1}{% \ltxkeys@err{\noexpand\needvalue pointer not allowed - \MsgBrk when setting keys}\@ehc + \MsgBrk when setting keys}\ltxkeys@ehc }{}% - \ltxkeys@findpointer\savevalue{#1}\ltxkeys@tkey - \ltxkeys@svtrue\ltxkeys@svfalse + \ltxkeys@findp@inters\savevalue{#1}\ltxkeys@tkey{% + \ltxkeys@svtrue + }{% + \ltxkeys@svfalse + }% \let\CurrentKey\ltxkeys@tkey - \ifcsemptyTF\ltxkeys@tkey{% + \ltxkeys@ifcsemptyTF\ltxkeys@tkey{% \ifltxkeys@noval\else \ltxkeys@err{No key specified for value '\expandcsonce\ltxkeys@tval' - \MsgBrk in families '\ltxkeys@fams'}\@ehc + \MsgBrk in families '\ltxkeys@fams'}\ltxkeys@ehc \fi }{% \xifinsetTF{,\ltxkeys@tkey,}{,\ltxkeys@nakeys,}{}{% @@ -1714,10 +2835,10 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@setkeys@d{% \ltxkeys@kffalse - \if@boolTF{ltxkeys@inpreset}{% + \ifboolTF{ltxkeys@preset}{% \ltxkeys@setkeys@e }{% - \if@boolTF{ltxkeys@pl}{% + \ifboolTF{ltxkeys@pl}{% \def\ltxkeys@do##1{% \def\CurrentPref{##1}% \ltxkeys@makepf{##1}% @@ -1727,9 +2848,9 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@makehdr\ltxkeys@tfam \ltxkeys@setkeys@e }% - \ltxkeys@csvloop*\ltxkeys@fams + \ltxkeys@parse*0\ltxkeys@fams }% - \ltxkeys@csvloop*\ltxkeys@prefs + \ltxkeys@parse*0\ltxkeys@prefs }{% \def\ltxkeys@do##1{% \def\CurrentPref{##1}% @@ -1741,36 +2862,56 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@setkeys@e \ifltxkeys@kf\loopbreak\fi }% - \ltxkeys@csvloop*\ltxkeys@fams + \ltxkeys@parse*0\ltxkeys@fams \ifltxkeys@kf\loopbreak\fi }% - \ltxkeys@csvloop*\ltxkeys@prefs + \ltxkeys@parse*0\ltxkeys@prefs }% }% - \if@boolTF{ltxkeys@kf}{% - \if@boolFT{ltxkeys@pxop}{}{% - \ifx\ltxkeys@testname\cpt@documentclass + \ifboolTF{ltxkeys@kf}{% + \ifdefboolTF{ltxkeys@pxop}{% + \ltxkeys@ifxTF\ltxkeys@testname\ltxkeys@documentclass{% \cpt@removecurroption\CurrentKeyval - \fi - }% + \ltxkeys@debug{==}{Key \ltxkeys@currtriple, removed from + \string\@unusedoptionlist}% + }{}% + }{}% }{% - \ifcsndefTF{\ltxkeys@hdr default@ds}{% - \begingroup - \let\xp\expandcsonce - \cptexpandsecond{% - \endgroup\usename{\ltxkeys@hdr default@ds}% + \ifdefboolTF{ltxkeys@pxop}{% + \ifcsndefTF{\ltxkeys@hdr default@ds@opt}{% + \begingroup + \let\xp\expandcsonce + \cptexpandsecond{% + \endgroup\usename{\ltxkeys@hdr default@ds@opt}% + }{% + {\xp\ltxkeys@ttpref}{\xp\ltxkeys@tfam}% + {\xp\ltxkeys@tkey}{\xp\ltxkeys@tval}% + }% }{% - {\xp\ltxkeys@ttpref}{\xp\ltxkeys@tfam}% - {\xp\ltxkeys@tkey}{\xp\ltxkeys@tval}% + \ltxkeys@ifxTF\@currext\@clsextension + \relax\ltxkeys@unknownoptionerror }% }{% - \if@boolTF{ltxkeys@pxop}{% - \ifxTF\@currext\@clsextension{}\ltxkeys@unknownoptionerror + \ifboolTF{ltxkeys@st}{% + \ifltxkeys@tracingkeys + \ltxkeys@getinnoval + \ltxkeys@debug{==}{Undefined key \ltxkeys@currtriple, + \InnocentVal, saved in \cptmakes{\ltxkeys@hdr rmkeys}}% + \fi + \cptexpandargonce{\aftercsname{\cptfiltermergekv[,]}% + {\ltxkeys@hdr rmkeys}}\CurrentKeyval\nofilter }{% - \if@boolTF{ltxkeys@st}{% - \cptexpandargonce{\aftercsname{\cptfiltermergekv[,]} - {\ltxkeys@hdr rmkeys}}\CurrentKeyval\nofilter + \ifcsndefTF{\ltxkeys@hdr default@ds@key}{% + \begingroup + \let\xp\expandcsonce + \cptexpandsecond{% + \endgroup\usename{\ltxkeys@hdr default@ds@key}% + }{% + {\xp\ltxkeys@ttpref}{\xp\ltxkeys@tfam}% + {\xp\ltxkeys@tkey}{\xp\ltxkeys@tval}% + }% }{% + \ltxkeys@debug{==}{Key \ltxkeys@currtriple, saved as undefined}% \ltxkeys@getinnoval \cptexpandarg{\cptfiltermergecsv[;]\ltxkeys@undefinedkeys}{% \ltxkeys@ttpref,\ltxkeys@tfam,\ltxkeys@tkey,\InnocentVal @@ -1781,81 +2922,128 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@setkeys@e{% + \ifboolTF{ltxkeys@tracingkeys}{% + \ltxkeys@getinnovalnopad + \ltxkeys@debug{==}{Setting\@space\ifltxkeys@preset + preset\@space\fi key: \ltxkeys@currtriple,\InnocentVal}% + }{}% \ifcsndefFT{\ltxkeys@hdr\ltxkeys@tkey}{% \relax + \ltxkeys@debug{!!}{% + \ifltxkeys@preset Preset key\else Key\fi\@space + is not defined: \ltxkeys@currtriple,\InnocentVal + }% }{% \ltxkeys@kftrue - \if@boolTF{ltxkeys@pxop}{% - \ltxkeys@testoptionkey{not}% + \ifltxkeys@tracingkeys + \ltxkeys@debug{++}{\ifltxkeys@preset Preset key\else Key\fi + \@space'\ltxkeys@tkey' is defined}% + \ifltxkeys@dec\else\ifltxkeys@ini\else + \edef\reserved@e{\ltxkeys@currtriple,\InnocentVal}% + \@onelevel@sanitize\reserved@e + \letcstocsn\reserved@f{\ltxkeys@hdr executedkeys}% + \xifinsetTF{*\reserved@e*}{*\reserved@f*}{% + \ltxkeys@debug{!!}{Key '\ltxkeys@currtriple' multiply + set with same value}% + }{% + \csn@edef{\ltxkeys@hdr executedkeys}{% + \csliststack*\reserved@f\reserved@e + }% + }% + \fi\fi + \fi + \ifboolTF{ltxkeys@pxop}{% + \ltxkeys@testoptionkey{non}% }{% - \if@boolTF{ltxkeys@exop}{}{\ltxkeys@testoptionkey{}}% + \ifboolTF{ltxkeys@exop}{}{\ltxkeys@testoptionkey{}}% + }% + \ifboolTF{ltxkeys@sv}{}{% + \ifcsndefTF{\ltxkeys@hdr savevaluekeys}{\ltxkeys@testsavevaluekey}{}% }% - \if@boolTF{ltxkeys@sv}{% - \edef\ltxkeys@tempa{\ltxkeys@tkey{\expandcsonce\ltxkeys@tval}}% - \ltxkeys@addtopointedkeys{savevalue}\ltxkeys@tempa + \ifboolTF{ltxkeys@sv}{% + \ltxkeys@addtop@intedkeys{savevalue}\ltxkeys@tkey\ltxkeys@tval }{}% - \if@boolTF{ltxkeys@noval}{% - \ifcsndefTF{\ltxkeys@hdr needvalue@keys}{\ltxkeys@testneedvalkey}{}% + \ifboolTF{ltxkeys@noval}{% + \ifcsndefTF{\ltxkeys@hdr needvaluekeys}{\ltxkeys@testneedvaluekey}{}% \ifcsndefTF{\ltxkeys@hdr\ltxkeys@tkey @default}{% + \ltxkeys@debug{==}{\ifltxkeys@preset Preset key\else Key\fi\@space + '\ltxkeys@tkey', no user-value, default found}% \cptsevenxp\ltxkeys@usedefault \usename{\ltxkeys@hdr\ltxkeys@tkey @default}\ltxkeys@nil }{% - \ltxkeys@err{No value specified for key '\ltxkeys@tkey'}\@ehc + \ltxkeys@err{No value specified for key '\ltxkeys@tkey'} + \ltxkeys@ehc }% }{% \s@expandarg\ltxkeys@replacepointers\ltxkeys@tval - \if@boolTF{ltxkeys@verbose}{% - \ltxkeys@getinnovalnopad - \ltxkeys@vinfo{% - \ifltxkeys@inpreset Preset key\else Key\fi\@space - executed: \ltxkeys@currtriple,\InnocentVal; - on level '\the\ltxkeys@keydepth'}% - }{}% + \ltxkeys@debug{==}{% + \ifltxkeys@preset Preset key\else Key\fi\@space + '\ltxkeys@tkey', macro being executed now% + }% \cpt@pushstate\ltxkeys@setkeys\ltxkeys@state\ltxkeys@keydepth \csname\ltxkeys@hdr\ltxkeys@tkey\expandafter \endcsname\expandafter{\ltxkeys@tval}\relax \cpt@popstate\ltxkeys@setkeys\ltxkeys@keydepth + \ltxkeys@debug{++}{% + \ifltxkeys@preset Preset key\else Key\fi\@space + '\ltxkeys@tkey', macro executed% + }% }% }% } \robust@def*\ltxkeys@usedefault#1#2\ltxkeys@nil{% - \begingroup - \csn@def{\ltxkeys@hdr\ltxkeys@tkey}##1{% - \toks@{\def\ltxkeys@tval{##1}}% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey', extracting default value}% + \def\reserved@a##1##2\ltxkeys@nil{% + \edef\reserved@a{\cptgobblescape{##1}}% + \edef\reserved@b{% + \detokenize\expandafter\expandafter\expandafter + {\expandafter\ltxkeys@hdr\ltxkeys@tkey}% + }% + \ltxkeys@ifxTF\reserved@a\reserved@b{% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey' has standard macro}% + \begintoksgroup + \csn@def{\ltxkeys@hdr\ltxkeys@tkey}####1{% + \toks@{\edef\ltxkeys@tval{\unexpanded{####1}}}% + }% + \usename{\ltxkeys@hdr\ltxkeys@tkey @default}% + \endtoksgroup + \s@expandarg\ltxkeys@replacepointers\ltxkeys@tval + }{% + \ltxkeys@debug{!!}{Key '\ltxkeys@tkey' has nonstandard macro}% + }% }% - \usename{\ltxkeys@hdr\ltxkeys@tkey @default}% - \expandafter\endgroup\the\toks@ - \s@expandarg\ltxkeys@replacepointers\ltxkeys@tval - \if@boolTF{ltxkeys@verbose}{% + \xaftercsname\reserved@a{\ltxkeys@hdr\ltxkeys@tkey @default}\ltxkeys@nil + \ifboolTF{ltxkeys@tracingkeys}{% \ltxkeys@getinnovalnopad - \ltxkeys@vinfo{% - \ifltxkeys@inpreset Preset key\else Key\fi\@space - executed: \ltxkeys@currtriple,\InnocentVal(default); - on level '\the\ltxkeys@keydepth' + \ltxkeys@debug{==}{% + \ifltxkeys@preset Preset key\else Key\fi\@space + '\ltxkeys@tkey', macro being executed now% }% }{}% \cpt@pushstate\ltxkeys@setkeys\ltxkeys@state\ltxkeys@keydepth \ifmacroTF{#1}{% \expandafter#1\expandafter{\ltxkeys@tval}\relax }{% - \ltxkeys@err{Faulty key macro '\detokenize{#1}'}\@ehc + \ltxkeys@err{Faulty key macro '\detokenize{#1}'}\ltxkeys@ehc }% \cpt@popstate\ltxkeys@setkeys\ltxkeys@keydepth + \ltxkeys@debug{++}{% + \ifltxkeys@preset Preset key\else Key\fi\@space + '\ltxkeys@tkey', macro executed% + }% } - -\robust@def*\ltxkeys@getsavedval#1{% +\robust@def*\ltxkeys@getsavedvalue#1{% \def\reserved@a##1#1##2##3\ltxkeys@nil{% - \ifblankTF{##3}\@firstoftwo{% - \def\reserved@a{##2}\@secondoftwo - }% + \edef\ltxkeys@tempc{\unexpanded{##2}}% + \ltxkeys@ifxTF\ltxkeys@tempc\ltxkeys@nnil\@secondoftwo\@firstoftwo }% - \cptsevenxp\reserved@a\@nameuse - {\ltxkeys@hdr savevalue@keys}#1{\ltxkeys@nil}\ltxkeys@nil + \cptsevenxp\reserved@a\usename{@\ltxkeys@hdr savevaluekeys}% + #1{\ltxkeys@nil}\ltxkeys@nil } \robust@def*\ltxkeys@replacepointers#1{% - \ltxkeys@vinfo{Replacing pointers of key '\ltxkeys@tkey'}% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey', replacing pointers}% \def\ltxkeys@resa{}% - \@tempswafalse + \ltxkeys@swafalse \ifbracedTF{#1}{% \ltxkeys@r@placepointers{#1}\usevalue\ltxkeys@nil }{% @@ -1865,36 +3053,36 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@r@placepointers#1\usevalue#2{% \def\reserved@a{#2}% - \ifxTF\reserved@a\ltxkeys@nnil{% + \ltxkeys@ifxTF\reserved@a\ltxkeys@nnil{% \edef\ltxkeys@tval{\unexpanded{#1}}% - \if@tempswa - \ifltxkeys@verbose + \ifltxkeys@swa + \ifltxkeys@tracingkeys \ltxkeys@getinnovalnopad - \ltxkeys@vinfo{Value '\InnocentVal' of key '\ltxkeys@tkey' - inherited from key '\ltxkeys@tempb'}% + \ltxkeys@debug{++}{Key '\ltxkeys@tkey', value + inherited from '\ltxkeys@tempb'}% \fi \else - \ltxkeys@vinfo{No pointers found on key '\ltxkeys@tkey'}% + \ltxkeys@debug{==}{Key '\ltxkeys@tkey', no pointers found}% \fi }{% - \ltxkeys@getsavedval{#2}{% - \ltxkeys@err{No value recorded for key '#2'}\@ehc - \ltxkeys@r@placepointers - }{% - \@tempswatrue + \ltxkeys@getsavedvalue{#2}{% + \ltxkeys@swatrue \def\ltxkeys@tempb{#2}% - \oifinset@sp@TF,{#2}\ltxkeys@resa{% - \ltxkeys@error{Dangerous back linking of pointers}{% - Key pointer replacement terminated due + \oifinset@sp@TF,\ltxkeys@tempb\ltxkeys@resa{% + \ltxkeys@error{Dangerous back linking of pointers} + {Key pointer replacement terminated due \MsgBrk to possible back linking.}% }{% - \edef\ltxkeys@resa{\cptliststack,\ltxkeys@resa#2}% - \s@expandarg\ifbracedTF\reserved@a{% - \s@expandarg\ltxkeys@r@placepointers\reserved@a + \edef\ltxkeys@resa{\csliststack,\ltxkeys@resa#2}% + \s@expandarg\ifbracedTF\ltxkeys@tempc{% + \s@expandarg\ltxkeys@r@placepointers\ltxkeys@tempc }{% - \expandafter\ltxkeys@r@placepointers\reserved@a + \expandafter\ltxkeys@r@placepointers\ltxkeys@tempc }% }% + }{% + \ltxkeys@err{No value recorded for key '#2'}\ltxkeys@ehc + \ltxkeys@r@placepointers }% }% } @@ -1903,11 +3091,11 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ } \robust@def*\ltxkeys@st@revalue#1#2{% \ifinsetFT{,}{#1}{}{% - \ltxkeys@err{Illegal multiple keys for \string\ltxkeys@storevalue}% - \@ehc + \ltxkeys@err{Illegal multiple keys for + \string\ltxkeys@storevalue}\ltxkeys@ehc }% \ifescapedTF{#2}{}{\cpt@notescapederr{#2}}% - \ltxkeys@getsavedval{#1}{% + \ltxkeys@getsavedvalue{#1}{% \ifltxkeys@pl \expandafter\@firstofone \else @@ -1927,75 +3115,84 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \let#2=\reserved@a }% } -\robust@def*\ltxkeys@getinnoval{\@tempswatrue\ltxkeys@g@tinnoval} -\robust@def*\ltxkeys@getinnovalnopad{\@tempswafalse\ltxkeys@g@tinnoval} +\robust@def*\ltxkeys@getinnoval{\ltxkeys@swatrue\ltxkeys@g@tinnoval} +\robust@def*\ltxkeys@getinnovalnopad{\ltxkeys@swafalse\ltxkeys@g@tinnoval} \robust@def*\ltxkeys@g@tinnoval{% - \ifxTF\ltxkeys@tval\@empty{% + \begingroup + \ltxkeys@ifxTF\ltxkeys@tval\@empty{% \def\InnocentVal{???}% }{% \def\InnocentVal{}% \def\ltxkeys@tempa{\\}% - \def\do##1##2##3##4##5##6##7##8##9\@@{% + \def\@do##1##2##3##4##5##6##7##8##9\@@{% \def\siso@do####1{% - \edef\InnocentVal{\InnocentVal\ifx\siso@arg\ltxkeys@tempa - \if@tempswa\@space\fi\else\if\siso@arg\cpt@leftbracechar[\else - \if\siso@arg\cpt@rightbracechar]\else####1\fi\fi\fi}% + \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 + \fi + \fi + }% }% \siso@@loop{##1##2##3##4##5##6##7##8}% }% - \expandafter\do\detokenize\expandafter + \expandafter\@do\detokenize\expandafter {\ltxkeys@tval}\\\\\\\\\\\\\\\\\\\@@ - }% + \postgroupdef\InnocentVal\endgroup } \robust@def*\ltxkeys@keyvalerr{% \ltxkeys@getinnovalnopad \ltxkeys@err{Erroneous value '\InnocentVal' for key or option - \MsgBrk'\ltxkeys@tkey'}\@ehc + \MsgBrk'\ltxkeys@tkey'}{Invalid key value encountered.}% } \robust@def*\ltxkeys@unknownkeyhandler{% + \def\ltxkeys@default@ds{default@ds@key}% \cpt@testopt\ltxkeys@unkn@wnkeyhandler{KV}% } \robust@def*\ltxkeys@unkn@wnkeyhandler[#1]#2#3{% - \begingroup - \toks@{}% - \toks1{##1##2##3##4}% - \toks2{\ltxkeys@getinnovalnopad#3}% + \begintoksgroup + \toks1{##1##2##3##4{\ltxkeys@getinnovalnopad#3}}% \def\ltxkeys@do##1{% \ltxkeys@makepf{##1}% \def\ltxkeys@do####1{% \ltxkeys@makehdr{####1}% - \toks@\expandafter{\the\expandafter\toks@\expandafter - \csn@def\expandafter{\ltxkeys@hdr default@ds}% - \the\toks1{\the\toks2}}% + \cptexpanded{% + \toks@{\the\toks@ + \csn@def{\ltxkeys@hdr\ltxkeys@default@ds}\the\toks1% + }% + }% }% - \ltxkeys@csvparse{#2}% + \ltxkeys@parse1{#2}% }% - \ltxkeys@csvparse{#1}% - \edef\reserved@a{\s@expandarg\@iden{\the\toks@}}% - \expandafter\endgroup\reserved@a + \ltxkeys@parse1{#1}% + \endtoksgroup } - \robust@def*\ltxkeys@logunknownkeys{% \ltxkeys@l@gunknownkeys - \ltxkeys@err{The above keys are undefined and % - couldn't be set}\@ehc + \ltxkeys@err{The above keys are undefined and couldn't be set} + {There are undefined keys; see above.}% } \robust@def*\ltxkeys@l@gunknownkeys{% - \gletcs\ltxkeys@l@gunknownkeys\relax + \ltxkeys@debug{==}{Now logging undefined keys}% \begingroup \cpt@cnta\z@pt \edef\ltxkeys@skipa{}% \cptwhilenum\cpt@cnta<20\do{% - \edef\ltxkeys@skipa{\expandcsonce\ltxkeys@skipa\@space}% + \edef\ltxkeys@skipa{\ltxkeys@skipa\@space}% \advance\cpt@cnta\@ne }% - \typeout{^^J\ltxkeys@skipa*** Unknown keys ***^^J}% + \typeout{\ltxkeys@skipa*** Unknown keys ***}% \def\ltxkeys@tempb{\\}% \def\align@do##1##2##3##4##5##6##7##8##9\@@{% \def\ltxkeys@tempc{##9}% \def\siso@do####1{% - \ifx\siso@arg\ltxkeys@tempb + \def\reserved@a{####1}% + \ifx\reserved@a\ltxkeys@tempb \edef\ltxkeys@skipb{\@space\ltxkeys@skipb}% \fi }% @@ -2012,138 +3209,216 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \expandafter\align@do\ltxkeys@tempc\\\\\\\\\\\\\\\\\\\@@ \edef\ltxkeys@msg{\expandcsonce\ltxkeys@msg####1\ltxkeys@skipb}% }% - \ltxkeys@csvparse{##1,##2,##3,##4}% + \ltxkeys@parse1{##1,##2,##3,##4}% \typeout{\ltxkeys@msg}% }% - \def\csv@do##1{% + \def\ltxkeys@do##1{% \ltxkeys@splita##1\ltxkeys@nil }% - \csv@@loop*[;]\ltxkeys@tempa - \typeout{^^J\ltxkeys@skipa*******************^^J}% + \ltxkeys@parse*0[;]\ltxkeys@tempa + \typeout{\ltxkeys@skipa*******************}% \endgroup } -\robust@def*\ltxkeys@disablekeys{\ltxkeys@testst\ltxkeys@dis@blekeys} -\robust@def*\ltxkeys@dis@blekeys{% - \let\ifdisablest\ifltxkeys@st - \begingroup - \catcode`\,=12\relax - \cpt@testopt{\ltxkeys@dis@bl@keys}{KV}% +\robust@def*\ltxkeys@disablekeys{% + \cpt@teststopt{\ltxkeys@dis@blekeys}{KV}% } -\robust@def*\ltxkeys@dis@bl@keys[#1]#2#3{% - \endgroup - \edef\ltxkeys@prefs{\cptcommanormalize{#1}}% - \edef\ltxkeys@fams{\cptcommanormalize{#2}}% - \edef\ltxkeys@keys{\cptcommanormalize{#3}}% +\robust@def*\ltxkeys@dis@blekeys[#1]#2#3{% + \ltxkeys@debug{==}{Now disabling keys}% + \ifboolTF{cpt@st}{% + \AtBeginDocument{% + \ltxkeys@dis@bl@keys{#1}{#2}{#3}% + }% + }{% + \ltxkeys@dis@bl@keys{#1}{#2}{#3}% + }% +} +\robust@def*\ltxkeys@dis@bl@keys#1#2#3{% + \ltxkeys@commanormalizeset + {{#1}\ltxkeys@prefs,{#2}\ltxkeys@fams,{#3}\ltxkeys@keys}% \def\ltxkeys@do##1{% \ltxkeys@makepf{##1}% \def\ltxkeys@do####1{% - \def\ltxkeys@tfam{####1}% \ltxkeys@makehdr{####1}% \ltxkeys@dis@bl@k@ys }% - \s@expandarg\ltxkeys@csvloop\ltxkeys@fams + \ltxkeys@parse*0\ltxkeys@fams }% - \s@expandarg\ltxkeys@csvloop\ltxkeys@prefs + \ltxkeys@parse*0\ltxkeys@prefs } -\robust@def\ltxkeys@dis@bl@k@ys{% +\robust@def*\ltxkeys@dis@bl@k@ys{% + \begingroup + \toks@{}% + \ifcsndefTF{\ltxkeys@hdr disabledkeys}{}{% + \@namedef{\ltxkeys@hdr disabledkeys}{}% + }% + \letcstocsn\ltxkeys@dkeys{\ltxkeys@hdr disabledkeys}% + \edef\ltxkeys@tempb##1{% + \ltxkeys@err + {Key '##1' of family '\ltxkeys@tfam' has been disabled}% + {Key '##1' has been disabled.\MsgBrk + You can't set or reset it at this late stage.\MsgBrk + Perhaps you should have set it earlier in\MsgBrk + '\string\documentclass' or '\string\usepackage'.}% + }% \def\ltxkeys@do##1{% - \ifcsndefFT{\ltxkeys@hdr##1}{% - \ltxkeys@vwarn{Key '##1' undefined in families '\ltxkeys@tfam': - \MsgBrk couldn't be disabled}% - }{% - \edef\ltxkeys@tempa{% - \noexpand\ltxkeys@err{% - Key '##1' of family '\ltxkeys@tfam' has been disabled - }{% - Key '##1' has been disabled.\MsgBrk - You can't set or reset it at this late stage.\MsgBrk - Perhaps you should have set it earlier in\MsgBrk - \noexpand\documentclass or \string\usepackage. - }% - }% - \cptpassexpanded{% - \ifdisablest\noexpand\AtBeginDocument{\fi - \ifcsndefTF{\ltxkeys@hdr##1@default}{% - \noexpand\ltxkeys@ordkey[\ltxkeys@ttpref]% - {\ltxkeys@tfam}{##1}[]{\expandcsonce\ltxkeys@tempa}% - }{% - \noexpand\ltxkeys@ordkey[\ltxkeys@ttpref]% - {\ltxkeys@tfam}{##1}{\expandcsonce\ltxkeys@tempa}% + \ifcsndefTF{\ltxkeys@hdr##1}{% + \xifinsetTF{,##1,}{,\expandcsonce\ltxkeys@dkeys,}{}{% + \cptpassexpanded{% + \toks@{\the\toks@ + \ltxkeys@ordkey[\ltxkeys@ttpref]{\ltxkeys@tfam}{##1}% + \ifcsndefTF{\ltxkeys@hdr##1@default}{[]}{}% + {\expandcsonce{\ltxkeys@tempb{##1}}}% }% - \ifdisablest}\fi + }% + \edef\ltxkeys@dkeys{% + \csliststack,\ltxkeys@dkeys\unexpanded{##1}% + }% }% + }{% + \ltxkeys@debug{!!}{Key '##1' is undefined in + family '\ltxkeys@tfam'}% }% }% - \s@expandarg\ltxkeys@csvloop\ltxkeys@keys - \undefcs\ifdisablest + \ltxkeys@parse*0\ltxkeys@keys + \cptpassexpanded{\endgroup + \csn@def{\ltxkeys@hdr disabledkeys}{\ltxkeys@dkeys}% + \noexpand\ltxkeys@disabletrue + \the\toks@ + \noexpand\ltxkeys@disablefalse + }% } \robust@def*\ltxkeys@nostarform#1#2{% \if\detokenize{#1*.}% - \ltxkeys@err{No star (*) form of command \string#2}\@ehc + \ltxkeys@err{No star (*) form of command \string#2}\ltxkeys@ehc \fi } \robust@def*\ltxkeys@declareoption{% - \let\ltxkeys@tempa\ltxkeys@ordkey \let\@fileswith@pti@ns\@badrequireerror - \cpt@ifstar\ltxkeys@unknownoptionhandler\ltxkeys@d@cl@reoption + \cpt@ifstar{% + \ltxkeys@unknownoptionhandler + }{% + \let\ltxkeys@tempa\ltxkeys@ordkey + \ltxkeys@d@cl@reoption + }% } \robust@def\ltxkeys@unknownoptionhandler{% \cpt@testopt\ltxkeys@unkn@wnoptionhandler{KV}% } \robust@def*\ltxkeys@unkn@wnoptionhandler[#1]{% - \cpt@testfam{\ltxkeys@unkn@wnopti@nhandler#1}% + \cpt@testfam{\ltxkeys@unkn@wnopti@nhandler{#1}}% } \robust@def*\ltxkeys@unkn@wnopti@nhandler#1<#2>#3{% + \def\ltxkeys@default@ds{default@ds@opt}% \ltxkeys@unkn@wnkeyhandler[#1]{#2}{#3}% } +\robust@def*\ltxkeys@declareordoption#1{% + \let\@fileswith@pti@ns\@badrequireerror + \ltxkeys@d@clareoption{#1}{ord}% +} +\newletcs\ltxkeys@declareordoptions\ltxkeys@declareordoption +\newletcs\ltxkeys@declareoptions\ltxkeys@declareordoption \robust@def*\ltxkeys@declarecmdoption#1{% \let\@fileswith@pti@ns\@badrequireerror \ltxkeys@d@clareoption{#1}{cmd}% } +\newletcs\ltxkeys@declarecmdoptions\ltxkeys@declarecmdoption \robust@def*\ltxkeys@declarebooloption#1{% \let\@fileswith@pti@ns\@badrequireerror \ltxkeys@d@clareoption{#1}{bool}% } +\newletcs\ltxkeys@declarebooloptions\ltxkeys@declarebooloption \robust@def*\ltxkeys@declarechoiceoption#1{% \let\@fileswith@pti@ns\@badrequireerror \ltxkeys@d@clareoption{#1}{choice}% } +\newletcs\ltxkeys@declarechoiceoptions\ltxkeys@declarechoiceoption \robust@def*\ltxkeys@d@clareoption#1#2{% - \aftercsname - {\ltxkeys@nostarform{#1}}{ltxkeys@declare#2option}% + \aftercsname{\ltxkeys@nostarform{#1}}{ltxkeys@declare#2option}% \edef\ltxkeys@tempa{\noexpandcsn{ltxkeys@#2key}}% \let\@fileswith@pti@ns\@badrequireerror - \ltxkeys@d@cl@reoption#1% + \ifsingletokenTF{#1}{% + \ltxkeys@d@cl@reoption#1% + }{% + \ltxkeys@d@cl@reoption{#1}% + }% } \robust@def*\ltxkeys@d@cl@reoption{% \cpt@testopt\ltxkeys@d@cl@r@option{KV}% } \robust@def*\ltxkeys@d@cl@r@option[#1]{% - \cpt@testfam{\ltxkeys@d@cl@r@opti@n#1}% + \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}% +} +\newletcs\declaremultitypeoptions\ltxkeys@declaremultitypeoptions +\robust@def*\ltxkeys@d@claremultitypeoptions[#1]{% + \cpt@testfam{\ltxkeys@d@cl@remultitypeoptions{#1}}% } -\robust@def*\ltxkeys@d@cl@r@opti@n#1<#2>{% - \ltxkeys@tempa[#1]{#2}% +\robust@def*\ltxkeys@d@cl@remultitypeoptions#1<#2>{% + \cptsafeactivesedef\reserved@b{#2}% + \cptexpanded{\ltxkeys@declarekeys\ifcpt@st*\fi[#1]{\reserved@b}}% } \robust@def*\ltxkeys@executeoptions#1{% \ltxkeys@nostarform{#1}\ltxkeys@executeoptions + \ltxkeys@debug{==}{Executing options}% \ltxkeys@exoptrue\ltxkeys@stfalse\ltxkeys@pltrue \ltxkeys@rmfalse - \ltxkeys@testopt@@b\ltxkeys@setkeys@a#1% + \ifsingletokenTF{#1}{% + \ltxkeys@testopt@@b\ltxkeys@setkeys@a#1% + }{% + \ltxkeys@testopt@@b\ltxkeys@setkeys@a{#1}% + }% +} +\robust@def*\ltxkeys@beforeprocessoptions{% + \ifcsndefTF{\@currname @\@currext @ltxkeys@beginprocessopt}{% + \ltxkeys@warn{Command \noexpand\ltxkeys@beforeprocessoptions + is wrongly located}% + \@gobble + }{% + \grightaddtocsn{\@currname @\@currext + @ltxkeys@beforeprocessopt@hook}% + }% } -\emptify\ltxkeys@processedoptions +\robust@def*\ltxkeys@afterprocessoptions{% + \ifcsndefTF{\@currname @\@currext @ltxkeys@endprocessopt}{% + \@firstofone + }{% + \grightaddtocsn{\@currname @\@currext + @ltxkeys@afterprocessopt@hook}% + }% +} +\robust@def*\ltxkeys@useandrelaxcsn#1{% + \ifcsndefFT{#1}{}{% + \letcstocsn\reserved@a{#1}% + \letcsntocs{#1}\relax + \reserved@a + }% +} +\def\ltxkeys@processedoptions{} \robust@def*\ltxkeys@processoptions{% + \ifcsndefTF{\@currname @\@currext @ltxkeys@beginprocessopt}{% + \ltxkeys@err{\noexpand\ltxkeys@processoptions issued twice + in same \@cls@pkg '\@currname'}\ltxkeys@ehc + }{% + \csn@def{\@currname @\@currext @ltxkeys@beginprocessopt}{}% + }% + \ltxkeys@useandrelaxcsn + {\@currname @\@currext @ltxkeys@beforeprocessopt@hook}% + \ltxkeys@debug{==}{Processing options}% \ltxkeys@pltrue\ltxkeys@rmfalse \ltxkeys@testopt@@a\ltxkeys@pr@cessoptions } \robust@def*\ltxkeys@pr@cessoptions[#1]{% - \def\ltxkeys@poxlist{}% \ltxkeys@pxoptrue + \def\ltxkeys@poxlist{}% \let\@fileswith@pti@ns\@badrequireerror \edef\ltxkeys@testname{\@currname.\@currext}% - \ifxTF\ltxkeys@testname\cpt@documentclass{% - \let\@unusedoptionlist\cpt@classoptionslist + \ltxkeys@ifxTF\ltxkeys@testname\ltxkeys@documentclass{% + \let\@unusedoptionlist\ltxkeys@classoptionslist }{% - \if@boolFT{ltxkeys@st}{}{% + \ifdefboolFT{ltxkeys@st}{}{% \def\ltxkeys@do##1{% \edef\CurrentKeyval{\unexpanded{##1}}% \ltxkeys@getkeyname##1=\ltxkeys@nil\ltxkeys@tkey @@ -2151,53 +3426,85 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \let\xp\expandcsonce \edef\x{[\xp\ltxkeys@prefs]{\xp\ltxkeys@fams}{\xp\ltxkeys@tkey}}% \expandafter\endgroup\expandafter\ltxkeys@ifkeydefFT\x{}{% - \ifcsnullTF\@unusedoptionlist{% + \ltxkeys@ifcsemptyTF\@unusedoptionlist{% \cptgaddtolist\ltxkeys@processedoptions{##1}% }{% \cpt@removecurroption{##1}% + \ltxkeys@debug{==}{Key \ltxkeys@currtriple, removed from + \string\@unusedoptionlist}% }% \cptaddtolist\ltxkeys@poxlist{##1}% }% }% - \ifcsnullTF\cpt@classoptionslist{}% - {\ltxkeys@csvloop*\cpt@classoptionslist}% + \ltxkeys@ifcsemptyTF\ltxkeys@classoptionslist{} + {\ltxkeys@parse*0\ltxkeys@classoptionslist}% }% }% - \begingroup \edef\ltxkeys@tempa{\cpt@optionlist{\@currname.\@currext}}% - \cptexpanded{\endgroup - \ifcsnullTF\ltxkeys@tempa{}{% - \cptaddtolist\noexpand\ltxkeys@poxlist{\expandcsonce\ltxkeys@tempa}% - }% - }% - \ifcsnullTF\ltxkeys@poxlist{}{% + \edef\ltxkeys@poxlist + {\csliststack,\ltxkeys@tempa\expandcsonce\ltxkeys@poxlist}% + \ltxkeys@ifcsemptyTF\ltxkeys@poxlist{}{% \cptexpandargonce{\ltxkeys@setkeys@a[#1]}\ltxkeys@poxlist }% - \gundefcs\ltxkeys@poxlist - \csn@def{\ltxkeys@hdr @rmkeys}{}% + \s@expandarg\ltxkeys@getkeynames\ltxkeys@poxlist + \def\ltxkeys@do##1{% + \ltxkeys@makepf{##1}% + \def\ltxkeys@do####1{% + \ltxkeys@makehdr{####1}% + \def\ltxkeys@do########1{% + \ifcsndefTF{\ltxkeys@hdr########1}{% + \csn@xdef{\ltxkeys@hdr poxkeys}{% + \csnliststack,{\ltxkeys@hdr poxkeys}% + \unexpanded{########1}% + }% + }% + }% + \ltxkeys@parse*0\ltxkeys@keynames + \ifcsndefFT{\ltxkeys@hdr optionkeys}{}{% + \letcstocsn\ltxkeys@tempb{\ltxkeys@hdr poxkeys}% + \ifdefTF\ltxkeys@tempb{}{\def\ltxkeys@tempb{}}% + \def\ltxkeys@do########1{% + \xifinsetTF{,########1,}{,\expandcsonce\ltxkeys@tempb,}{}{% + \edef\ltxkeys@tempb{% + \csliststack,\ltxkeys@tempb\unexpanded{########1}% + }% + }% + }% + \aftercsname{\ltxkeys@parse*0}{\ltxkeys@hdr optionkeys}% + \gletcsntocs{\ltxkeys@hdr poxkeys}\ltxkeys@tempb + }% + }% + \ltxkeys@parse*0\ltxkeys@fams + }% + \ltxkeys@parse*0\ltxkeys@prefs + \undefcs\ltxkeys@poxlist + \csn@def{\ltxkeys@hdr rmkeys}{}% \ltxkeys@pxopfalse \let\@fileswith@pti@ns\@@fileswith@pti@ns \AtEndOfPackage{\let\@unprocessedoptions\relax}% + \ltxkeys@debug{==}{Ended processing options}% + \ltxkeys@debug{==}{Now doing <afterprocessoptions>}% + \ltxkeys@useandrelaxcsn + {\@currname @\@currext @ltxkeys@afterprocessopt@hook}% + \csn@def{\@currname @\@currext @ltxkeys@endprocessopt}{}% } \robust@def*\ltxkeys@ifkeydefTF{\begingroup\ltxkeys@ifkeydef0} \robust@def*\ltxkeys@ifkeydefFT{\begingroup\ltxkeys@ifkeydef1} \robust@def*\ltxkeys@ifkeydef#1{\cpt@testopt{\ltxkeys@ifk@ydef#1}{KV}} \robust@def*\ltxkeys@ifk@ydef#1[#2]#3#4{% - \def\ltxkeys@prefs{#2}% - \def\ltxkeys@fams{#3}% - \cpt@sttrue\cpt@csvnormalize[,]\ltxkeys@fams + \ltxkeys@commanormalizeset{{#2}\ltxkeys@prefs,{#3}\ltxkeys@fams}% \ltxkeys@trimspaces{#4}\ltxkeys@tkey \cpt@choicefdfalse \def\ltxkeys@do##1{% - \if@boolTF{cpt@choicefd}{% + \ifboolTF{cpt@choicefd}{% \loopbreak }{% \ltxkeys@makepf{##1}% \ltxkeys@ifk@yd@f }% }% - \ltxkeys@csvparse*\ltxkeys@prefs - \ltxkeys@oneoftwo#1\endgroup + \ltxkeys@parse*0\ltxkeys@prefs + \ltxkeys@ifchcfd#1\endgroup } \robust@def*\ltxkeys@ifk@yd@f{% \def\ltxkeys@do##1{% @@ -2206,8 +3513,331 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \cpt@choicefdtrue\loopbreak }{}% }% - \ltxkeys@csvloop*\ltxkeys@fams + \ltxkeys@parse*0\ltxkeys@fams } +\robust@def*\ltxkeysglobal{\ltxkeys@globaltrue} +\robust@def*\ltxkeysprotected{\ltxkeys@protectedtrue} +\newletcs\ltxkeysrobust\ltxkeysprotected +\robust@def*\ltxkeys@global@protected{% + \ifltxkeys@global + \ltxkeys@globalfalse + \let\ltxkeys@tempa\global + \else + \let\ltxkeys@tempa\@empty + \fi + \ifltxkeys@protected + \ltxkeys@protectedfalse\protected + \fi + \ltxkeys@tempa +} +\robust@def*\ltxkeyscmd{% + \let\ltxkeys@inenv\cptswfalse + \cpt@starorlong\ltxkeys@keycommand +} +\robust@def*\ltxkeys@keycommand#1{% + \cpt@testopt{\ltxkeys@keycommand@a#1}0% +} +\robust@def*\ltxkeys@keycommand@a#1[#2]{% + \ltxkeys@inkeycmdtrue + \cpt@ifbrack + {\ltxkeys@keycommand@e#1{#2}}{\ltxkeys@keycommand@b#1{#2}}% +} +\robust@def*\ltxkeys@keycommand@b#1#2{% + \cpt@testltopt{\ltxkeys@keycommand@c{#1}{#2}}{}% +} +\robust@def*\ltxkeys@keycommand@c#1#2<#3>{% + \cpt@testpnopt{\ltxkeys@keycommand@d{#1}{#2}{#3}}{}% +} +\robust@def\ltxkeys@keycommand@d#1#2#3(#4)#5{% + \ifcsdefinable#1\relax + \edef\reserved@a{\cptgobblescape#1}% + \cptexpandsecond{\ltxkeys@declarekeys*[CMDKEY]} + {{ltxkeys@\reserved@a}[\reserved@a @]}{#4}% + \def\reserved@a{\ltxkeys@keycommand@h#1\@ne{#2}{#3}}% + \expandafter\reserved@a\expandafter{% + \expandafter\long\expandafter\edef\expandafter + \ltxkeys@cmdbody\expandafter{\expandafter + {\ltxkeys@inenv}{\unexpanded{#5}}}% + \cptexpandarg\cpt@testpnopt{\ltxkeys@keycommand@j + {\cptgobblescape#1}}{}% + }% +} +\robust@def*\ltxkeys@keycommand@e#1#2[#3]{% + \cpt@testltopt{\ltxkeys@keycommand@f{#1}{#2}{#3}}{}% +} +\robust@def*\ltxkeys@keycommand@f#1#2#3<#4>{% + \cpt@testpnopt{\ltxkeys@keycommand@g{#1}{#2}{#3}{#4}}{}% +} +\robust@def\ltxkeys@keycommand@g#1#2#3#4(#5)#6{% + \ifcsdefinable#1\relax + \edef\reserved@a{\cptgobblescape#1}% + \cptexpandsecond{\ltxkeys@declarekeys*[CMDKEY]} + {{ltxkeys@\reserved@a}[\reserved@a @]}{#5}% + \ifltxkeys@global\global\fi + \ifltxkeys@protected\protected\fi + \expandafter\def\expandafter#1\expandafter{% + \expandafter\@protected@testopt\expandafter#1% + \csname\string#1\endcsname{#3}% + }% + \def\reserved@a{% + \aftercsname\ltxkeys@keycommand@h{\string#1}\tw@{#2}{#4}% + }% + \expandafter\reserved@a\expandafter{% + \expandafter\long\expandafter\edef\expandafter + \ltxkeys@cmdbody\expandafter{\expandafter + {\ltxkeys@inenv}{\unexpanded{#6}}}% + \cptexpandarg\cpt@testpnopt{\ltxkeys@keycommand@j + {\cptgobblescape#1}}{}% + }% +} +\robust@def*\ltxkeys@keycommand@h#1#2#3#4{% + \ifnum#2=\tw@ + \def\ltxkeys@tempb##11{[####1]}% + \else + \let\ltxkeys@tempb\@gobble + \fi + \expandafter\ltxkeys@keycommand@i\expandafter{\number#3}#1{#4}% +} +\robust@def\ltxkeys@keycommand@i#1#2#3{% + \begingroup + \iflacus#3\dolacus + \let\elt\@gobble + \else + \def\elt##1{\expandcsnonce{d##1}}% + \@tempcnta\z@pt + \loop + \advance\@tempcnta\@ne + \csn@def{d\number\@tempcnta}{}% + \ifnum\@tempcnta<9\relax + \repeat + \@tempcnta\z@pt + \def\@do##1##2{% + \edef\ltxkeys@tempa{\cpttrimspace{##1}}% + \ifstrcmpTF{##1}\keycommand@nil{}{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta>#1\relax + \ltxkeys@err{Number of delimiters exceeds + number of parameters}\ltxkeys@ehc + \fi + \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 + delimiter}\ltxkeys@ehc + }% + \csn@edef{d\ltxkeys@tempa}{\cpttrimspace{##2}}% + \@do + }% + }% + \@do#3\keycommand@nil\keycommand@nil + \fi + \iflacus#3\dolacus\else + \ifx\ltxkeys@tempb\@gobble\else + \expandafter\ifx\csname d1\endcsname\@empty\else + \ltxkeys@err{First argument of command \string#2 is + \MsgBrk already delimited by '[]'}\ltxkeys@ehc + \fi + \fi + \fi + \edef\ltxkeys@tempc{% + 0####1\ifx\ltxkeys@tempb\@gobble\elt1\fi + ####2\elt2####3\elt3####4\elt4####5\elt5####6\elt6% + ####7\elt7####8\elt8####9\elt9% + }% + \def\ltxkeys@tempa##1#1##2##{% + \def\ltxkeys@tempc{% + \ltxkeys@inkeycmdfalse + \ltxkeys@global@protected\l@ngrel@x + }% + \cptexpandsecond{\expandafter\endgroup\ltxkeys@tempc + \expandafter\def\expandafter#2\ltxkeys@tempb##1#1}{\elt{#1}}% + }% + \expandafter\ltxkeys@tempa\ltxkeys@tempc###1% +} +\robust@def*\ltxkeys@keycommand@j#1(#2){% + \ltxkeys@setkeys[CMDKEY]{ltxkeys@#1}{#2}% + \pushfunctions\ltxkeyscmd{\val,\ifval,\ifvalTF, + \keyval,\ifkeyval,\ifkeyvalTF}\ltxkeyscmd@depth + \def\val##1{\usename{#1@\cpttrimspace{##1}}}% + \def\ifval##1\then{\usename{if#1@\cpttrimspace{##1}}}% + \def\ifvalTF##1{% + \ifval##1\then\expandafter\iofii\else\expandafter\iiofii\fi + }% + \def\keyval##1{% + \ifcsndefTF{#1@\cpttrimspace{##1}}{% + \usename{#1@\cpttrimspace{##1}}% + }{% + \ltxkeys@err{Key '\cpttrimspace{##1}' not defined by + command '\@backslashchar#1'}\ltxkeys@ehc + }% + }% + \def\ifkeyval##1\then{% + \ifcsndefTF{if#1@\cpttrimspace{##1}}{% + \usename{if#1@\cpttrimspace{##1}}% + }{% + \ltxkeys@err{Key '\cpttrimspace{##1}' not defined by + command '\@backslashchar#1'}\ltxkeys@ehc + }% + }% + \def\ifkeyvalTF##1{% + \ifkeyval##1\then\expandafter\iofii\else\expandafter\iiofii\fi + }% + \long\def\reserved@a##1##2\ltxkeys@nil{% + \ifcondTF\if##1\fi{% + ##2% + }{% + ##2% + \popfunctions\ltxkeyscmd\ltxkeyscmd@depth + }% + }% + \expandafter\reserved@a\ltxkeys@cmdbody\ltxkeys@nil +} +\robust@def*\reltxkeyscmd{% + \let\ltxkeys@inenv\cptswfalse + \cpt@starorlong\ltxkeys@rekeycommand +} +\robust@def*\ltxkeys@rekeycommand#1{% + \ifdefTF{#1}{}{% + \ltxkeys@warn{Command '\string#1' was previously undefined + \MsgBrk but now defined by \string\ltsrenewcommand}% + }% + \let\ifcsdefinable\rc@ifcsdefinable + \ltxkeys@keycommand#1% +} +\robust@def*\ltxkeysenv{% + \let\ltxkeys@inenv\cptswtrue + \cpt@starorlong\ltxkeys@keyenvironment +} +\robust@def*\ltxkeys@keyenvironment#1{\cpt@testopt{\ltxkeys@newenv@a#1}0} +\robust@def*\ltxkeys@newenv@a#1[#2]{% + \begingroup + \toks@{}% + \ifnum#2=\z@pt\else + \@tempcnta\z@pt + \loop + \advance\@tempcnta\@ne + \cptexpanded{% + \toks@{\the\toks@\csn@def{keyenvarg@\romannumeral\@tempcnta}% + {########\the\@tempcnta}}% + }% + \ifnum\@tempcnta<#2\relax + \repeat + \fi + \cpt@ifbrack{\ltxkeys@newenv@b#1[#2]}{\ltxkeys@newenv@c{#1}[#2]}% +} +\robust@def*\ltxkeys@newenv@b#1[#2][#3]{% + \cpt@testltopt{\ltxkeys@newenv@d{#1}{[#2][{#3}]}}{}% +} +\robust@def*\ltxkeys@newenv@c#1[#2]{% + \cpt@testltopt{\ltxkeys@newenv@d{#1}{[#2]}}{}% +} +\robust@def*\ltxkeys@newenv@d#1#2<#3>{% + \cpt@testpnopt{\ltxkeys@newenv@e{#1}{#2}{#3}}{}% +} +\robust@def\ltxkeys@newenv@e#1#2#3(#4)#5#6{% + \ifcsndefTF{#1}{}{\letcsntocsn{#1}{end#1}}% + \def\@do##1{\edef\@do{\unexpanded{##1}}}% + \ifblankTF{#3}{% + \ifblankTF{#4}{% + \@do{#2}% + }{% + \@do{#2(#4)}% + }% + }{% + \ifblankTF{#4}{% + \@do{#2<#3>}% + }{% + \@do{#2<#3>(#4)}% + }% + }% + \xdef\ltxkeys@newenv@f{% + \ifltxkeys@global\global\fi + \ifltxkeys@protected\protected\fi + }% + \cptexpandsecond{% + \endgroup\ltxkeys@keycommand + }{% + \noexpandcsn{#1}\expandcsonce\@do{% + \the\toks@\unexpanded{#5}% + }% + }% + \ltxkeys@newenv@f + \l@ngrel@x\csn@def{end#1}{% + \def\envarg####1{\usename{keyenvarg@\romannumeral####1}}% + #6\relax + \popfunctions\ltxkeyscmd\ltxkeyscmd@depth + \ltxkeys@everyeoehook + }% +} +\robust@def*\reltxkeysenv{% + \let\ltxkeys@inenv\cptswtrue + \cpt@starorlong\ltxkeys@rekeyenvironment +} +\robust@def*\ltxkeys@rekeyenvironment#1{% + \ifdefTF{#1}{}{% + \ltxkeys@warn{Environment '\string#1' was previously undefined + \MsgBrk but now defined by \string\reltxkeysenv}% + }% + \letcsntocs{#1}\relax + \letcsntocs{end#1}\relax + \ltxkeys@keyenvironment{#1}% +} +\robust@def\ltxkeys@ifpattern#1#2{% + \begingroup + \edef\ltxkeys@tempa##1{\def##1####1\detokenize{#1}####2&}% + \ltxkeys@tempa\ltxkeys@tempa{% + \aftercsname\endgroup{@\ifblankTF{##2}{second}{first}oftwo}% + }% + \edef\ltxkeys@tempb##1{##1\detokenize{#1}&}% + \ltxkeys@tempb{\expandafter\ltxkeys@tempa\meaning#2}% +} + +\new@def*\ltxkeys@everyeoehook{} +\robust@def*\ltxkeys@everyeoe#1{% + \ifblankTF{#1}{% + \gdef\ltxkeys@everyeoehook{}% + }{% + \xdef\ltxkeys@everyeoehook{% + \unexpanded{#1}\expandcsonce\ltxkeys@everyeoehook + }% + }% + \ltxkeys@ifpattern\@ignoretrue\ltxkeys@everyeoehook{% + \ltxkeys@ifpattern\ignorespacesafterend\ltxkeys@everyeoehook{% + \ltxkeys@err{Bad '\string\ltxkeys@everyeoe'} + {You can't have both '\string\@ignoretrue' and + '\string\ignorespacesafterend' in + \MsgBrk '\string\ltxkeys@everyeoe'.}% + }{% + \ltxkeys@checkbadeoe\@ignoretrue + }% + }{% + \ltxkeys@ifpattern\ignorespacesafterend\ltxkeys@everyeoehook{% + \ltxkeys@checkbadeoe\ignorespacesafterend + }{}% + }% +} +\new@def*\ltxkeys@checkbadeoe#1{% + \begingroup + \edef\ltxkeys@tempa##1{\def##1####1\detokenize{#1}####2&}% + \ltxkeys@tempa\ltxkeys@tempa{% + \ifblankTF{##2}{}{% + \xifinsetTF{\detokenize{#1}}{##2}{% + \ltxkeys@err{'\detokenize{#1}' repeated in + '\string\ltxkeys@everyeoe'.} + {Multiple '\detokenize{#1}' not allowed in + '\string\ltxkeys@everyeoe'.}% + }{% + \ltxkeys@err{Bad last token in '\string\ltxkeys@everyeoe'} + {'\detokenize{#1}' not the last token in + '\string\ltxkeys@everyeoe'.}% + }% + }% + }% + \expandafter\ltxkeys@tempa\meaning\ltxkeys@everyeoehook&% + \endgroup +} +\ltxkeys@everyeoe\ignorespacesafterend + \robust@def*\ltxkeys@emergencystop{% \immediate\write\sixt@@n{OK, I'm exiting now.}% \interactionmode\z@pt @@ -2218,23 +3848,22 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ }% } \robust@def*\ltxkeys@unknownoptionerror{% - \@tx@warn{Unknown option '\CurrentOption' for package '\@currname'}% - \typein[\answer]{% - ^^JUnknown option '\CurrentOption' for package '\@currname'. - ^^JThe option '\CurrentOption' was not declared in package - ^^J'\@currname'. Perhaps you misspelled its name. - ^^JEnter 'x' and <return> to stop or any character and - <return> to continue. + \ltxkeys@err{Unknown option '\CurrentKey' for + \@cls@pkg\space '\@currname'} + {Unknown option '\CurrentKey' for \@cls@pkg\space '\@currname'. + \MsgBrk The option '\CurrentKey' was not declared in \@cls@pkg + \MsgBrk'\@currname'. Perhaps you misspelled its name. }% - \xifstrcmpTF\answer{x}\ltxkeys@emergencystop\relax } -\cpt@cleanup\ltxkeys@processedoptions - \cptonlypreamble{% - \ltxkeys@declareoption,\ltxkeys@declarecmdoption,% - \ltxkeys@declarebooloption,\ltxkeys@declarechoiceoption,% - \ltxkeys@processoptions,\ltxkeys@executeoptions,% - \ltxkeys@unknownoptionhandler,\ltxkeys@unknownkeyhandler + \ltxkeys@declareoption,\ltxkeys@declareoptions, + \ltxkeys@declareordoption,\ltxkeys@declareordoptions, + \ltxkeys@declarecmdoption,\ltxkeys@declarecmdoptions, + \ltxkeys@declarebooloption,\ltxkeys@declarebooloptions, + \ltxkeys@declarechoiceoption,\ltxkeys@declarechoiceoptions, + \ltxkeys@processoptions,\ltxkeys@executeoptions, + \ltxkeys@unknownoptionhandler,\ltxkeys@declaremultitypeoptions, + \declaremultitypeoptions } \ltxkeys@declareoption*[KV]<ltxkeys>{% \ltxkeys@warn{Unknown option '\CurrentKey' with @@ -2243,15 +3872,38 @@ $Id: ltxkeys.sty,v 0.0.1 2011/07/30 09:00:00 Ahmed Musa Exp $ \ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{keyparser}[{;}]{% \stripallouterbracesincs\ltxkeys@keyparser } -\ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{keystacklimit}[4]{% - \ifx\\#1\\% - \ltxkeys@err{Invalid empty value for 'keystacklimit'}\@ehc - \else - \xdef\cpt@optionstacklimit{\number#1}% +\ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{% + \needvalue{keydepthlimit}% +}{% + \ifblankTF{#1}{% + \ltxkeys@err{Invalid empty value for 'keydepthlimit'} + \ltxkeys@ehc + }{% + \xdef\cpt@optionstacklimit{\number0#1}% + }% +} +\ltxkeys@declarecmdoption[KV]<ltxkeys>[ltxkeys@]{% + \needvalue{keystacklimit}% +}{% + \ltxkeys@setaliaskey{keydepthlimit}% +} +\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{pathkeys}{% + \ifltxkeys@pathkeys + \ltxkeys@afterprocessoptions{\RequirePackage{pathkeys}}% \fi } -\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{verbose}[true]{} -\ltxkeys@executeoptions[KV]<ltxkeys>{keyparser,keystacklimit}\relax +\ltxkeys@declarebooloptions[KV]<ltxkeys>[ltxkeys@] + {tracingkeys,reservenopath}[true]{} +\ltxkeys@declarebooloption[KV]<ltxkeys>[ltxkeys@]{allowemptypath} + [true]{\ifltxkeys@allowemptypath\ltxkeys@useemptytrue\fi} +\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}}% +} \endinput + +%% End of file ltxkeys.sty %% diff --git a/Master/texmf-dist/tex/latex/ltxkeys/pathkeys.sty b/Master/texmf-dist/tex/latex/ltxkeys/pathkeys.sty new file mode 100644 index 00000000000..d047ec0b90e --- /dev/null +++ b/Master/texmf-dist/tex/latex/ltxkeys/pathkeys.sty @@ -0,0 +1,615 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% % +% This is file 'pathkeys.sty', version 0.0.2, October 2011. % +% % +% This package and accompanying files may be distributed and/or % +% modified under the conditions of the LaTeX Project Public License, % +% either version 1.3 of this license or any later version. The latest % +% version of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2011 Ahmed Musa (amusa22@gmail.com). % +% % +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\@ifpackageloaded{ltxkeys}{% + \@ifpackagelater{ltxkeys}{2011/10/22}{}{% + \@latex@error{Loaded version of ltxkeys package is + not current}\@ehc + }% +}{% + \RequirePackage{ltxkeys}[2011/10/22]% +} +\UseNormalCatcodes +\StyleFilePurpose{A robust and fast key-value parser (AM)} +\StyleFileRCSInfo +$Id: pathkeys.sty,v 0.0.2 2011/10/22 09:00:00 Ahmed Musa Exp $ +\ProvidesPackage{pathkeys}[\StyleFileInfo] +\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\SetStyleFileMessages[pathkeys@]{info}{warn}{err} +\newvariables{count}[pathkeys@]{cnta}[\z@pt] +\newvariables{if}[pathkeys@]{chfd}[false] +\newletcs\pathkeys@relax\relax +\new@def\pathkeys@gobbletorelax#1\pathkeys@relax{} +\robust@def*\pathkeys@getkeypath#1{% + \xifinsetTF{:}{\detokenize{#1}}{}{% + \pathkeys@err{I can't find ':' in argument of + \string\pathkeys}\ltxkeys@ehc + }% + \def\reserved@a##1:##2\ltxkeys@nil{% + \iflacus##1\dolacus + \pathkeys@err{Nil flag in argument of + \string\pathkeys}\ltxkeys@ehc + \fi + \ltxkeys@trimspaces{##1}\key@path + \ltxkeys@trimspaces{##2}\key@list + \csv@@normalize*[/]\key@path + \s@expandarg\pathkeys@getkeyflag\key@path + \csv@@normalize*[/]\key@path + \cptsafeactivesedef\key@path\key@path + \xifstrcmpTF\key@flag{ifkeyonpath}{% + \pathkeys@gobbletorelax + }{% + \pathkeys@listadd*![;]\pathkeys@pathhistory\key@path + }% + }% + \reserved@a#1\ltxkeys@nil +} +\robust@def*\pathkeys@getkeyflag#1{% + \def\do##1,##2\ltxkeys@nil{% + \xifinsetTF{\detokenize{##1}\relax}{\detokenize{#1}\relax}{% + \def\reserved@a####1##1\relax{% + \ltxkeys@trimspaces{##1}\key@flag + \ltxkeys@trimspaces{####1}\key@path + }% + \reserved@a#1\relax + }{% + \ifnullTF{##2}{% + \pathkeys@err{Unknown flag in argument of + \string\pathkeys}\ltxkeys@ehc + }{% + \do##2\ltxkeys@nil + }% + }% + }% + \do define,define*,declareoptions,declareoptions*,set,% + executeoptions,processoptions,processoptions*,launch,% + key handler,option handler,ifbool,add value,store value,% + print value,disable,disable*,fdef,ifkeyonpath,\ltxkeys@nil +} +\robust@def*\pathkeys@splitpath#1{% + \def\main@path{}\def\sub@path{}% + \@tempcnta\z@pt + \def\do##1/{% + \defifxTF{##1}\ltxkeys@nnil{}{% + \advance\@tempcnta\@ne + \ifnum\@tempcnta=\@ne + \def\main@path{##1}% + \else + \edef\sub@path{\csliststack{/}\sub@path##1}% + \fi + \do + }% + }% + \do#1/\ltxkeys@nil/% +} +\robust@def*\pathkeys@checkpath#1{% + \iflacus#1\dolacus + \ltxkeys@debug{==}{Empty key path in \string\pathkeys: default used}% + \let\key@path\pathkeys@c@rrentpath + \else + \def\reserved@a##1/##2/##3/##4\ltxkeys@nil{% + \iflacus##2\dolacus + \pathkeys@err{Empty key <sub> in \string\pathkeys}\ltxkeys@ehc + \fi + }% + \reserved@a#1///\ltxkeys@nil + \fi +} +\robust@def*\pathkeys@getkeyname#1{% + \def\reserved@a##1/##2\ltxkeys@nil{% + \ltxkeys@trimspaces{##1}\key@type + }% + \reserved@a#1\ltxkeys@nil + \xifstrcmpTF{\detokenize{choice}}{\cptoxdetok\key@type}{% + \def\reserved@a##1/##2.##3\ltxkeys@nil{% + \ltxkeys@trimspaces{##2}\key@name + }% + \reserved@a#1\ltxkeys@nil + }{% + \def\reserved@a##1/##2/##3\ltxkeys@nil{% + \ltxkeys@trimspaces{##2}\key@name + \ltxkeys@ifrejname{% + \pathkeys@err{^^JI can't find key name in attributes of + key in^^J||\detokenize{#1}||^^J}\ltxkeys@ehc + }% + }% + \reserved@a#1/^?/\ltxkeys@nil + }% +} +\robust@def*\pathkeys@checkifdef{% + \xifinsetTF{,\key@flag,}{,define*,declareoptions*,}{% + \def\ltxkeys@resa{}% + \def\ltxkeys@do##1{% + \pathkeys@getkeyname{##1}% + \ifcsndefTF{pathkeys/curr/\ltxkeys@iffirstnull\main@path/% + \ltxkeys@iffirstnull\sub@path/\key@name + }{% + \edef\ltxkeys@resa{\csliststack,\ltxkeys@resa\key@name}% + }{}% + }% + \cptexpandsecond{\ltxkeys@parse*1}{[\ltxkeys@keyparser]}\key@list + \ifx\ltxkeys@resa\@empty\else + \pathkeys@err{^^JKey names^^J||\ltxkeys@resa||^^J% + in argument of \noexpand\pathkeys are already in + use on path '\key@path'}\ltxkeys@ehc + \fi + }{}% +} +\cpt@setupsafeactivesedef +\robust@def*\pathkeys#1{% + \begintoksgroup + \pathkeys@getkeypath{#1}% + \s@expandarg\pathkeys@checkpath\key@path + \s@expandarg\pathkeys@splitpath\key@path + \pathkeys@checkifdef + \pathkeys@relax + \let\xp\expandcsonce + \let\elt\ltxkeys@iffirstnull + \def\reserved@a##1{% + \def\reserved@a####1##1####2####3\ltxkeys@nil{% + \defifxTF{####2}\ltxkeys@nil{% + \pathkeys@err{Unknown flag '####1' in argument of + \string\pathkeys}\ltxkeys@ehc + }{% + \cptexpanded{\toks@{####2}}% + }% + }% + \expandafter\reserved@a\pathkeys@actions##1{\ltxkeys@nil}\ltxkeys@nil + }% + \s@expandarg\reserved@a\key@flag + \endtoksgroup +} +\robust@def*\pathkeys@actions{% + define{\pathkeys@defkey\ltxkeys@declarekeys{{\sub@path}}}% + define*{\pathkeys@defkey{\ltxkeys@declarekeys*}{{\sub@path}}}% + declareoptions{\pathkeys@defkey + \ltxkeys@declaremultitypeoptions{<\sub@path>}}% + declareoptions*{\pathkeys@defkey + {\ltxkeys@declaremultitypeoptions*}{<\sub@path>}}% + set{\pathkeys@setkeys{\main@path}{\sub@path}{\xp\key@list}}% + executeoptions{\pathkeys@executeoptions{\main@path}% + {\sub@path}{\xp\key@list}}% + processoptions{\pathkeys@processoptions{\main@path}% + {\sub@path}{\xp\key@list}}% + processoptions*{\pathkeys@processoptions*{\main@path}% + {\sub@path}{\xp\key@list}}% + launch{\ltxkeys@launchkeys[\main@path]{\sub@path}{\xp\key@list}}% + handler{\ltxkeys@unknownkeyhandler[\main@path]% + {\sub@path}{\xp\key@list}}% + key handler{\ltxkeys@unknownkeyhandler[\main@path]% + {\sub@path}{\xp\key@list}}% + option handler{\ltxkeys@unknownoptionhandler[\main@path]% + <\sub@path>{\xp\key@list}}% + ifbool{\noexpand\ifp@thkeys@keyvalTF{\key@list}% + {pathkeys/curr/\elt\main@path/\elt\sub@path/\key@list}}% + add value{\p@thkeys@addtovalue{\xp\key@list}% + {pathkeys/curr/\elt\main@path/\elt\sub@path/}}% + store value{\p@thkeys@storevalue{\xp\key@list}% + {pathkeys/curr/\elt\main@path/\elt\sub@path/}}% + print value{\noexpand\p@thkeys@keyval{\key@list}% + {pathkeys/curr/\elt\main@path/\elt\sub@path/\key@list}}% + disable{\ltxkeys@disablekeys[\main@path]{\sub@path}{\key@list}}% + disable*{\ltxkeys@disablekeys*[\main@path]{\sub@path}{\key@list}}% + ifdef{\noexpand\ifp@thkeys@keydef{\main@path}{\sub@path}{\key@list}}% + ifkeyonpath{\noexpand\ifp@thkeys@onpath{\key@path}{\key@list}}% +} +\robust@def*\pathkeys@setkeys#1#2#3{% + \xifinsetTF{\relax[}{\relax\detokenize{#3}}{% + \def\reserved@a[##1]##2\ltxkeys@nil{% + \ltxkeys@setkeys[#1]{#2}[##1]{##2}% + }% + \reserved@a#3\ltxkeys@nil + }{% + \xifinsetTF{]\relax}{\detokenize{#3}\relax}{% + \def\reserved@a##1[##2]\ltxkeys@nil{% + \ltxkeys@setkeys[#1]{#2}[##2]{##1}% + }% + \reserved@a#3\ltxkeys@nil + }{% + \ltxkeys@setkeys[#1]{#2}{#3}% + }% + }% +} +\robust@def*\pathkeys@executeoptions#1#2#3{% + \xifinsetTF{\relax[}{\relax\detokenize{#3}}{% + \def\reserved@a[##1]##2\ltxkeys@nil{% + \ltxkeys@executeoptions[#1]<#2>[##1]{##2}% + }% + \reserved@a#3\ltxkeys@nil + }{% + \xifinsetTF{]\relax}{\detokenize{#3}\relax}{% + \def\reserved@a##1[##2]\ltxkeys@nil{% + \ltxkeys@executeoptions[#1]<#2>[##2]{##1}% + }% + \reserved@a#3\ltxkeys@nil + }{% + \ltxkeys@executeoptions[#1]<#2>{#3}% + }% + }% +} +\robust@def*\pathkeys@processoptions{% + \ltxkeys@testst\pathkeys@pr@cessoptions +} +\robust@def*\pathkeys@pr@cessoptions#1#2#3{% + \edef\reserved@e{\ifltxkeys@st*\fi}% + \xifinsetTF{\relax[}{\relax\detokenize{#3}}{% + \def\reserved@a[##1]##2\ltxkeys@nil{% + \iflacus##2\dolacus\else + \pathkeys@err{Wrong use of 'processoptions' flag in + \string\pathkeys}{The invalid part is '\detokenize{##2}'}% + \fi + \expandafter\ltxkeys@processoptions\reserved@e[#1]<#2>[##1]% + }% + \reserved@a#3\ltxkeys@nil + }{% + \xifinsetTF{]\relax}{\detokenize{#3}\relax}{% + \def\reserved@a##1[##2]\ltxkeys@nil{% + \iflacus##1\dolacus\else + \pathkeys@err{Wrong use of 'processoptions' flag in + \string\pathkeys}{The invalid part is '\detokenize{##1}'}% + \fi + \expandafter\ltxkeys@processoptions\reserved@e[#1]<#2>[##2]% + }% + \reserved@a#3\ltxkeys@nil + }{% + \expandafter\ltxkeys@processoptions\reserved@e[#1]<#2>% + }% + }% +} +\new@def*\pathkeys@defkey#1#2{% + \noexpand\ltxkeys@inkeycmdtrue + #1[\main@path]#2[pathkeys/curr/\elt\main@path/\elt\sub@path/]% + {\expandcsonce\key@list}% + \noexpand\ltxkeys@inkeycmdfalse +} +\robust@def*\p@thkeys@storevalue#1#2{% + \ltxkeys@getlasttoken{#1}% + \ltxkeys@trimspacesincs\ltxkeys@lasttoken + \ltxkeys@trimspacesincs\ltxkeys@resttokens + \ifcsndefTF{#2\ltxkeys@resttokens}{% + \expandafter\edef\ltxkeys@lasttoken + {\expandcsnonce{#2\ltxkeys@resttokens}}% + }{% + \pathkeys@err{Key '\ltxkeys@resttokens' not defined}\ltxkeys@ehc + }% +} +\robust@def*\p@thkeys@addtovalue#1#2{% + \begingroup + \ltxkeys@splitkeyval#1\ltxkeys@nil\ltxkeys@tempa\ltxkeys@tempb + \ifcsndefTF{#2\ltxkeys@tempa}{% + \csn@edef{#2\ltxkeys@tempa}{% + \expandcsnonce{#2\ltxkeys@tempa}% + \expandcsonce\ltxkeys@tempb + }% + \postgroupcsndef{#2\ltxkeys@tempa}\endgroup + }{% + \pathkeys@err{Key '\ltxkeys@tempa' not defined}\ltxkeys@ehc + \endgroup + }% +} +\new@def*\p@thkeys@keyval#1#2{% + \ifcsndefTF{#2}{% + \expandcsnonce{#2}% + }{% + \pathkeys@err{Key '#1' not defined on the given path}\ltxkeys@ehc + }% +} +\new@def*\ifp@thkeys@keyval#1#2\then{% + \ifcsndefTF{if#2}{% + \usename{if#2}% + }{% + \pathkeys@err{Key '#1' not defined or not a boolean}\ltxkeys@ehc + }% +} +\new@def*\ifp@thkeys@keyvalTF#1#2{% + \ifp@thkeys@keyval{#1}{#2}\then\expandafter\iofii\else + \expandafter\iiofii\fi +} +\new@def*\ifp@thkeys@keydef#1#2#3{% + \begingroup + \pathkeys@chfdfalse + \ifcsndefTF{pathkeys/curr/#1/#2/#3}{% + \pathkeys@chfdtrue + }{% + \ifcsndefTF{#1@#2@#3}{% + \pathkeys@chfdtrue + }{}% + }% + \expandafter\endgroup\ifpathkeys@chfd + \expandafter\iofii\else\expandafter\iiofii\fi +} +\robust@def*\ifp@thkeys@onpath#1#2{% + \begingroup + \pathkeys@chfdfalse + \def\ltxkeys@do##1{% + \pathkeys@checkpath{##1}% + \pathkeys@splitpath{##1}% + \let\elt\ltxkeys@iffirstnull + \ifcsndefTF{pathkeys/curr/\elt\main@path/\elt\sub@path/#2}{% + \pathkeys@chfdtrue\loopbreak + }{% + \ifcsndefTF{\main@path @\sub@path @#2}{% + \pathkeys@chfdtrue\loopbreak + }{}% + }% + }% + \ltxkeys@parse1[,]{#1}% + \expandafter\endgroup\ifpathkeys@chfd + \expandafter\iofii\else\expandafter\iiofii\fi +} + +\begingroup +\uccode`\~=`\/% +\uppercase{\endgroup + \def\pathkeys@normalizeslash#1{% + \unexpanded\expandafter{\romannumeral-`\q + \pathkeys@activeslash/#1/~\ltxkeys@nil}% + }% + \def\pathkeys@activeslash#1~#2\ltxkeys@nil{% + \ifblankTF{#2} + {\pathkeys@spaceslash#1 /\ltxkeys@nil} + {\pathkeys@activeslash#1/#2\ltxkeys@nil}% + }% +} +\def\pathkeys@spaceslash#1 /#2\ltxkeys@nil{% + \ifblankTF{#2} + {\pathkeys@slashspace#1/ \ltxkeys@nil} + {\pathkeys@spaceslash#1/#2\ltxkeys@nil}% +} +\def\pathkeys@slashspace#1/ #2\ltxkeys@nil{% + \ifblankTF{#2} + {\pathkeys@doubleslash#1//\ltxkeys@nil} + {\pathkeys@slashspace#1/#2\ltxkeys@nil}% +} +\def\pathkeys@doubleslash#1//#2\ltxkeys@nil{% + \ifblankTF{#2}{% + \ifblankTF{#1}{}{\@gobble#1}% + }{% + \pathkeys@doubleslash#1/#2\ltxkeys@nil + }% +} +\new@def*\pathkeys@n@rmalizeslash#1{% + \pathkeys@ifnopath{#1}{% + \expandafter\pathkeys@normalizeslash\expandafter + {\pathkeys@c@rrentpath/#1}% + }{% + \pathkeys@normalizeslash{#1}% + }% +} +\def\pathkeys@replaceslash#1/#2\ltxkeys@nil{% + \ifblankTF{#2}{% + #1% + }{% + \pathkeys@replaceslash#1@#2\ltxkeys@nil + }% +} +\newletcs\pathkeys@addcons\@empty +\robust@def*\pathkeys@listadd{% + \cpt@testst{\cpt@testcl{\cpt@testopt\pathkeys@l@stadd,}}% +} +\robust@def*\pathkeys@l@stadd[#1]#2#3{% + \ifcpt@st + \let\pathkeys@addcons\@space + \fi + \ifcpt@cl\global\fi + \edef#2{\csliststack{#1\pathkeys@addcons}#2\expandcsonce{#3}}% + \let\pathkeys@addcons\@empty +} +\robust@def*\newpath#1#2{% + \ifcsndefTF{pathkeys@path@\cpttrimspace{#1}}{% + \pathkeys@err{Path '#1' already in use}\@ehc + }{% + \csn@edef{pathkeys@path@\cpttrimspace{#1}}{\cpttrimspace{#2}}% + \pathkeys@listadd*![;]\pathkeys@pathhistory{#2}% + }% +} +\robust@def*\defpath#1#2{% + \csn@edef{pathkeys@path@\cpttrimspace{#1}}{\cpttrimspace{#2}}% + \pathkeys@listadd*![;]\pathkeys@pathhistory{#2}% +} +\newletcs\changepath\defpath +\robust@def*\undefpath#1{% + \edef\ltxkeys@tempa{\usename{pathkeys@path@\cpttrimspace{#1}}}% + \pathkeys@undefpath + \undefcsn{pathkeys@path@\cpttrimspace{#1}}% +} +\robust@def*\pathkeys@undefpath{% + \xifinsetTF\ltxkeys@tempa\pathkeys@pathhistory{% + \def\reserved@a##1{% + \def\reserved@a####1##1####2\ltxkeys@nil{% + \def\pathkeys@pathhistory{####1####2}% + \xifinsetTF{; ;}\pathkeys@pathhistory{% + \def\reserved@a########1; ;########2\ltxkeys@nil{% + \def\pathkeys@pathhistory{########1;########2}% + }% + \expandafter\reserved@a\pathkeys@pathhistory\ltxkeys@nil + }{}% + \pathkeys@undefpath + }% + \expandafter\reserved@a\pathkeys@pathhistory\ltxkeys@nil + }% + \s@expandarg\reserved@a\ltxkeys@tempa + }{}% +} +\new@def*\usepath#1{% + \expandafter\pathkeys@usepath\romannumeral + -`\q\cptcommanormalize{#1},\ltxkeys@nil,\ltxkeys@nnil{}% +} +\new@def*\pathkeys@usepath#1,#2\ltxkeys@nnil#3{% + \ifstrcmpTF{#1}\ltxkeys@nil{% + \@gobble#3% + }{% + \ifcsndefTF{pathkeys@path@#1}{% + \pathkeys@usepath#2\ltxkeys@nnil{#3,\usename{pathkeys@path@#1}}% + }{% + \pathkeys@usepath#2\ltxkeys@nnil{#3,\usename{#1=undefinedpath}}% + }% + }% +} +\new@def*\pathkeys@defaultpath{dft@main/dft@sub} +\newletcs\pathkeys@c@rrentpath\pathkeys@defaultpath +\robust@def*\pathkeys@addtodefaultpath#1{% + \edef\pathkeys@defaultpath + {\expandcsonce\pathkeys@defaultpath/\expandcsonce{#1}}% + \csv@@normalize*[/]\pathkeys@defaultpath + \pathkeys@listadd*![;]\pathkeys@pathhistory\pathkeys@defaultpath +} +\robust@def*\pathkeys@changedefaultpath#1{% + \edef\pathkeys@defaultpath{\expandcsonce{#1}}% + \csv@@normalize*[/]\pathkeys@defaultpath + \pathkeys@listadd*![;]\pathkeys@pathhistory\pathkeys@defaultpath +} +\robust@def*\pathkeys@currentpath#1{% + \edef\pathkeys@c@rrentpath{\expandcsonce{#1}}% + \csv@@normalize*[/]\pathkeys@c@rrentpath + \pathkeys@listadd*![;]\pathkeys@pathhistory\pathkeys@c@rrentpath +} +\robust@def*\pathkeys@usedefaultpath{% + \let\pathkeys@c@rrentpath\pathkeys@defaultpath + \pathkeys@listadd*![;]\pathkeys@pathhistory\pathkeys@c@rrentpath +} +\new@def*\pathkeys@currentpathstack{} +\robust@def*\pathkeys@pushcurrentpath{% + \xdef\pathkeys@currentpathstack{% + \gdef\noexpand\pathkeys@c@rrentpath + {\expandcsonce\pathkeys@c@rrentpath}% + \ltxkeys@nil{\expandcsonce\pathkeys@currentpathstack}% + }% +} +\robust@def*\pathkeys@popcurrentpath{% + \begingroup + \def\reserved@a##1\ltxkeys@nil{\endgroup + ##1\gdef\pathkeys@currentpathstack + }% + \expandafter\reserved@a\pathkeys@currentpathstack + \pathkeys@listadd*![;]\pathkeys@pathhistory\pathkeys@c@rrentpath +} +\new@def*\pathkeys@ifnop@th#1/{} +\new@def*\pathkeys@ifnopath#1{% + \ifcat$\cptoxdetok{\pathkeys@ifnop@th#1{}/}$% + \expandafter\iofii\else\expandafter\iiofii\fi +} +\new@def*\pathkeys@getkeyval#1{% + \ifcsndefTF{pathkeys/curr/\pathkeys@n@rmalizeslash{#1}}{% + \expandcsnonce{pathkeys/curr/\pathkeys@n@rmalizeslash{#1}}% + }{% + \pathkeys@err{Key '\cpttrimspace{#1}' not defined}\ltxkeys@ehc + }% +} +\newletcs\pathkeyskeyval\pathkeys@getkeyval +\new@def*\pathkeys@storevalue#1#2{% + \ifescapedTF{#2}{% + \edef#2{\unexpanded\expandafter + {\romannumeral-`\q\pathkeys@getkeyval{#1}}}% + }{% + \cpt@notescapederr{#2}% + }% +} +\new@def*\ifpathkeyskeyval#1\then{% + \usename{if\pathkeys@getkeyval{#1}}% +} +\new@def*\ifpathkeyskeyvalTF#1{% + \ifpathkeyskeyval#1\then\expandafter\iofii\else + \expandafter\iiofii\fi +} +\new@def*\pathkeys@getval#1{% + \ifcsndefTF{pathkeys/curr/\pathkeys@n@rmalizeslash{#1}}{% + \expandcsnonce{pathkeys/curr/\pathkeys@n@rmalizeslash{#1}}% + }{% + undefinedpathkey% + }% +} +\newletcs\pathkeysval\pathkeys@getval +\new@def*\ifundefinedpathkey{undefinedpathkey\iffalse} +\new@def*\ifpathkeysval#1\then{\usename{if\pathkeys@getval{#1}}} +\new@def*\ifpathkeysvalTF#1{% + \ifpathkeysval#1\then\expandafter\iofii\else + \expandafter\iiofii\fi +} +\robust@def*\pathkeys@useshortcmds{% + \let\pathkeys@useshortcmds\relax + \pathkeys@makeshortcmds{% + \pkv=\pathkeysval,\ifpkv=\ifpathkeysval,\ifpkvTF=\ifpathkeysvalTF, + \pkkv=\pathkeyskeyval,\ifpkkv=\ifpathkeyskeyval, + \ifpkkvTF=\ifpathkeyskeyvalTF + }% +} +\robust@def*\pathkeys@makeshortcmds#1{% + \def\ltxkeys@do##1{% + \ifinsetTF{=}{##1}{% + \def\reserved@a####1=####2\@nil{% + \ifdefTF{####1}{% + \ifx####1####2\else + \pathkeys@err{Command '\string####1' already exists: + \MsgBrk it can't be redefined by + \string\pathkeys@makeshortcmds}\@ehc + \fi + }{% + \let####1=####2% + }% + }% + \reserved@a##1\@nil + }{% + \pathkeys@err{No '=' in short command assignment}\ltxkeys@ehc + }% + }% + \ltxkeys@parse3[,]{#1}% +} +\robust@def*\pathkeys@defineoptions#1{% + \begintoksgroup + \def\do##1/##2/##3\ltxkeys@nil{% + \toks@\expandafter{\the\toks@ + \ifstrcmpTF{##2}{pathkeys}{% + \usename{ltxkeys@declare##1option}% + [KV]<pathkeys>[pathkeys@]{##2}[##3]{}% + }{% + \usename{ltxkeys@declare##1option}% + [KV]<pathkeys>[pathkeys@]{##2}[##3]{% + \ltxkeys@options{##2=####1}% + }% + }% + }% + }% + \def\ltxkeys@do##1{\do##1\ltxkeys@nil}% + \ltxkeys@parse1[;]{#1}% + \endtoksgroup +} +\pathkeys@defineoptions{% + cmd/keyparser/{;}; + cmd/keydepthlimit/4; + cmd/keystacklimit/4; + bool/tracingkeys/true; + bool/reservenopath/true; + bool/allowemptypath/true; + bool/pathkeys/false; +} +\ltxkeys@declareoption*[KV]<pathkeys>{% + \pathkeys@warn{Unknown option '\CurrentKey' with + value '\InnocentVal' ignored.}% +} +%\ltxkeys@executeoptions[KV]<pathkeys>{}\relax +\ltxkeys@processoptions*[KV]<pathkeys>\relax +\cpt@optioncleanup\ltxkeys@processedoptions + +\endinput + +%% End of file pathkeys.sty %% |