diff --git a/tex/crossrefenum.tex b/tex/crossrefenum.tex index 72f1a64..fdfb865 100644 --- a/tex/crossrefenum.tex +++ b/tex/crossrefenum.tex @@ -75,13 +75,6 @@ %%% Initialization: Programming macros %%% -% Trivial macros - -\def\crfnm@appendToToks#1#2{#1=\expandafter{\the#1#2}} -\expandafter\def\expandafter\crfnm@gobspace\space{} -\def\crfnm@lettok#1#2{\let#1= #2} -\crfnm@lettok\crfnm@space{ } - % \crfnm@case is a standard case statement. % #1 is the string or the purely expandable macro to be tested. % #2 is a sequence of tests of the form: @@ -417,6 +410,51 @@ %%% Initialization: Auxiliary macros related to the data structure of \crossrefenum %%% +% Trivial low-level macros + +\def\crfnm@appendToToks#1#2{#1=\expandafter{\the#1#2}} +\expandafter\def\expandafter\crfnm@gobspace\space{} +\def\crfnm@lettok#1#2{\let#1= #2} +\crfnm@lettok\crfnm@space{ } +\def\crfnm@gobbleFirst#1{} + +% Lists of groups + +\def\crfnm@ifIsList[#1]#2#3{% + \expandafter\futurelet\expandafter\crfnm@nextToken + \expandafter\crfnm@ifIsBgroup #1\endofcheck{#2}{#3}% +} + +\def\crfnm@ifIsBgroup#1\endofcheck#2#3{% + % \crfnm@nextToken is the first token in the #1 of \crfnm@ifIsList. + % All the #1 of \crfnm@ifIsList is stored here in #1 and discarded. + \ifx\crfnm@nextToken\bgroup #2\else #3\fi +} + +\def\crfnm@newListFrom[#1][#2] -> #3{% + % #1 is either a list or a reference. + % #2 is the reference appended to #1. + % #3 is the control sequence which the resulting list will be bound to. + \crfnm@ifIsList[#1]{% + \edef#3{#1{#2}}% + }{% + \edef#3{{#1}{#2}}% + }% +} +\def\crfnm@addToList[#1][#2]{\crfnm@newListFrom[#1][#2] -> #1} +\def\crfnm@declareType[#1][#2]{% + % #1 is "simple" or "double", #2 is the type + \expandafter\crfnm@addToList\expandafter[\csname crfnm@#1RefTypes\endcsname][#2]% + \crfnm@addToList[\crfnm@supportedTypes][#2]% +} + +\def\crfnm@replaceFirstInList[#1]#2{% + % #1 is a token, #2 is a list of tokens + {#1}\crfnm@gobbleFirst #2% +} + +% crossrefenum-specific + \edef\crfnm@simpleRefTypes{{\crfnm@page}{\crfnm@note}{\crfnm@line}{\crfnm@edpage}{\crfnm@edline}} \edef\crfnm@doubleRefTypes{{\crfnm@pagenote}{\crfnm@pageline}{\crfnm@edpageline}} \edef\crfnm@customizableDefaultConfig{{Collapsable}{EnumDelim}{EnumDelimInSecond}{BeforeLastInEnum}{BeforeLastInSecond}{RangeSep}} @@ -466,40 +504,6 @@ }% } -\def\crfnm@ifIsList[#1]#2#3{% - \expandafter\futurelet\expandafter\crfnm@nextToken - \expandafter\crfnm@ifIsBgroup #1\endofcheck{#2}{#3}% -} - -\def\crfnm@ifIsBgroup#1\endofcheck#2#3{% - % \crfnm@nextToken is the first token in the #1 of \crfnm@ifIsList. - % All the #1 of \crfnm@ifIsList is stored here in #1 and discarded. - \ifx\crfnm@nextToken\bgroup #2\else #3\fi -} - -\def\crfnm@newListFrom[#1][#2] -> #3{% - % #1 is either a list or a reference. - % #2 is the reference appended to #1. - % #3 is the control sequence which the resulting list will be bound to. - \crfnm@ifIsList[#1]{% - \edef#3{#1{#2}}% - }{% - \edef#3{{#1}{#2}}% - }% -} -\def\crfnm@addToList[#1][#2]{\crfnm@newListFrom[#1][#2] -> #1} -\def\crfnm@declareType[#1][#2]{% - % #1 is "simple" or "double", #2 is the type - \expandafter\crfnm@addToList\expandafter[\csname crfnm@#1RefTypes\endcsname][#2]% - \crfnm@addToList[\crfnm@supportedTypes][#2]% -} - -\def\crfnm@replaceFirstInList[#1]#2{% - % #1 is a token, #2 is a list of tokens - {#1}\crfnm@gobbleFirst #2% -} - -\def\crfnm@gobbleFirst#1{} %%% Initialization: Default configuration %%%