simplify some function names
This commit is contained in:
parent
05bc3d9c60
commit
710915271e
2 changed files with 237 additions and 159 deletions
|
@ -732,12 +732,12 @@
|
|||
% {
|
||||
% \groupthm_new_group:nnnnn,
|
||||
% \groupthm_renew_group:nnnnn,
|
||||
% \groupthm_provide_theorem_group:nnnnn,
|
||||
% \groupthm_declare_theorem_group:nnnnn,
|
||||
% \groupthm_provide_group:nnnnn,
|
||||
% \groupthm_declare_group:nnnnn,
|
||||
% \groupthm_new_group:nVVVV,
|
||||
% \groupthm_renew_group:nVVVV,
|
||||
% \groupthm_provide_theorem_group:nVVVV,
|
||||
% \groupthm_declare_theorem_group:nVVVV
|
||||
% \groupthm_provide_group:nVVVV,
|
||||
% \groupthm_declare_group:nVVVV
|
||||
% }
|
||||
% \begin{syntax}
|
||||
% \cs{groupthm_new_group:nnnnn}\marg{theorem group}\marg{prefix tl}
|
||||
|
@ -1497,15 +1497,47 @@
|
|||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
% With these two helper functions, we can now easily implement the
|
||||
% \texttt{new}, \texttt{renew}, \texttt{provide} and \texttt{declare} variants
|
||||
% of the theorem group macro:
|
||||
% \begin{macro}{\@@_define:nnnNNNn, \@@_define:nnncNNn}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_define:nnnNNNn}\marg{declarator}\marg{type}\marg{instance}\marg{existence cs}\marg{undefine function}\marg{define function}\marg{definition args}
|
||||
% \end{syntax}
|
||||
%
|
||||
% A general definition macro that is used to implement the \texttt{new},
|
||||
% \texttt{renew}, \texttt{provide} and \texttt{declare} definition variants of \meta{type}s.
|
||||
% For the purpose of this package, \meta{type} will be one of
|
||||
% \enquote{theorem group}, \enquote{grouped theorem}, \enquote {theorem family}
|
||||
% and\enquote{theorem family options}, but could technically be anything.
|
||||
%
|
||||
% The \meta{instance} is the actual thing that will be defined by this function.
|
||||
% The \meta{declarator} is one of \texttt{new}, \texttt{renew},
|
||||
% \texttt{provide} and \texttt{declare} and indicates the definition behavior:
|
||||
% \texttt{new} only defines
|
||||
% if \meta{instance} does not yet exist and throws an error otherwise,
|
||||
% \texttt{renew} only (re)defines
|
||||
% if \meta{instance} does exist yet and throws an error otherwise,
|
||||
% \texttt{provides} defines if \meta{instance} does not exist yet,
|
||||
% but does nothing otherwise
|
||||
% and
|
||||
% \texttt{declare} defines \meta{instance} in any case,
|
||||
% possibly by overwriting the old definition.
|
||||
%
|
||||
% The \meta{existence cs} is the one whose existence will be checked to
|
||||
% determine whether the \meta{instance} already exists.
|
||||
%
|
||||
% The \meta{undefine function} will be called in case \meta{instance} has to be undefined.
|
||||
% It is assumed to have argument type \texttt{n} and will be given the \meta{instance}
|
||||
% as an argument in this case.
|
||||
%
|
||||
% The \meta{define function} will be called with the arguments
|
||||
% given as \meta{definition args} in case no error occurs and \meta{instance} should be defined.
|
||||
%
|
||||
% \begin{macro}{\groupthm_new_group:nnnnn, \groupthm_new_group:nVVVV}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
\cs_new:Npn \@@_define:nnnNNNn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
% \end{macrocode}
|
||||
% We first check for wrong usage of \texttt{new}
|
||||
% \begin{macrocode}
|
||||
\bool_if:nT
|
||||
{
|
||||
\str_if_eq_p:nn { #1 } { new }
|
||||
|
@ -1516,7 +1548,9 @@
|
|||
\msg_error:nnnn { groupthm } { wrong ~ definition }
|
||||
{ #2 } { #3 } { already }
|
||||
}
|
||||
|
||||
% \end{macrocode}
|
||||
% Then check for wrong usage of \texttt{renew}
|
||||
% \begin{macrocode}
|
||||
\bool_if:nT
|
||||
{
|
||||
\str_if_eq_p:nn { #1 } { renew }
|
||||
|
@ -1527,7 +1561,9 @@
|
|||
\msg_error:nnnn { groupthm } { wrong ~ definition }
|
||||
{ #2 } { #3 } { not }
|
||||
}
|
||||
|
||||
% \end{macrocode}
|
||||
% Now, remove the old definition if necessary
|
||||
% \begin{macrocode}
|
||||
\bool_if:nT
|
||||
{
|
||||
(
|
||||
|
@ -1539,34 +1575,82 @@
|
|||
{
|
||||
#5 { #1 }
|
||||
}
|
||||
|
||||
% \end{macrocode}
|
||||
% Finally, define new version if not already defined
|
||||
% (this check is necessary for the provide version.)
|
||||
% \begin{macrocode}
|
||||
\cs_if_exist:NF #4
|
||||
{
|
||||
#6 #7
|
||||
}
|
||||
\cs_generate_variant:Nn \@@_define_aux:nnnNNNn { n n n c N N n }
|
||||
|
||||
\cs_new:Npn \@@_define_list_aux:nnnNNnn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
}
|
||||
}
|
||||
\cs_generate_variant:Nn \@@_define:nnnNNNn { n n n c N N n }
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
% \begin{macro}{\@@_define_multiple:nnnNNnn}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_define_multiple:nnnNNnn} \marg{declarator list} \marg{type} \marg{existence cs}
|
||||
% \marg{undefine function}\marg{define function}\marg{function name}\marg{definition args}
|
||||
% \end{syntax}
|
||||
%
|
||||
% This is a wrapper around the \cs{@@_define:nnnNNNn} macro.
|
||||
% It is intended to wrap the multiple variants of it into a family of macros indicating
|
||||
% the variant in their name, e.g.~to define \cs{groupthm_new_group}, \cs{groupthm_renew_group},
|
||||
% \cs{groupthm_provide_group} and \cs{groupthm_declare_group} in the same way except for their
|
||||
% indicated declaration behavior, to avoid repetition when defining these.
|
||||
%
|
||||
% The first five arguments work the same way as in \cs{@@_define:nnnNNn},
|
||||
% except that \meta{declarator list} is now a comma separated list.
|
||||
% In \meta{existence cs}, \texttt{\#\#1} is used to denote the \meta{instance}
|
||||
% that has currently been called to define.
|
||||
%
|
||||
% The \meta{function name} is expected to contain \texttt{\#1},
|
||||
% for which the current \meta{declarator} is inserted.
|
||||
% These control sequences will then be defined.
|
||||
%
|
||||
% The \meta{definition args} denote the arguments passed to the \meta{define function}
|
||||
% and may contain \texttt{\#\#1}, \texttt{\#\#2}, etc. for the arguments that the
|
||||
% \meta{function name} received as arguments on expansion.
|
||||
%
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_define_multiple:nnnNNnn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
\cs_set:Npn \@@_map_aux:n ##1
|
||||
{
|
||||
\cs_new:cn { #6 }
|
||||
{
|
||||
\@@_define_aux:nnncNNn
|
||||
\@@_define:nnncNNn
|
||||
{ ##1 }
|
||||
{ #2 }
|
||||
{ ####1 }
|
||||
{ #3 }
|
||||
#4
|
||||
#5
|
||||
{
|
||||
#7
|
||||
}
|
||||
{ #7 }
|
||||
}
|
||||
}
|
||||
\clist_map_function:nN { #1 } \@@_map_aux:n
|
||||
}
|
||||
|
||||
|
||||
\@@_define_list_aux:nnnNNnn
|
||||
}
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
%
|
||||
% With these helper functions, we can now easily generate the
|
||||
% \texttt{new}, \texttt{renew}, \texttt{provide} and \texttt{declare} variants
|
||||
% of the theorem group macro:
|
||||
%
|
||||
% \begin{macro}
|
||||
% {
|
||||
% \groupthm_new_group:nnnnn, \groupthm_new_group:nVVVV,
|
||||
% \groupthm_renew_group:nnnnn, \groupthm_renew_group:nVVVV,
|
||||
% \groupthm_provide_group:nnnnn, \groupthm_provide_group:nVVVV,
|
||||
% \groupthm_declare_group:nnnnn, \groupthm_declare_group:nVVVV
|
||||
% }
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\@@_define_multiple:nnnNNnn
|
||||
{ new, renew, provide, declare }
|
||||
{ theorem group }
|
||||
{ @@_use_group_##1: }
|
||||
|
@ -1576,18 +1660,16 @@
|
|||
{ { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } }
|
||||
% \end{macrocode}
|
||||
%
|
||||
% Finally, generate some extra variant.
|
||||
% Finally, generate some extra variants
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_generate_variant:Nn \groupthm_new_group:nnnnn { n V V V V }
|
||||
\cs_generate_variant:Nn \groupthm_renew_group:nnnnn { n V V V V }
|
||||
\cs_generate_variant:Nn \groupthm_provide_group:nnnnn { n V V V V }
|
||||
\cs_generate_variant:Nn \groupthm_declare_group:nnnnn { n V V V V }
|
||||
% \end{macrocode}
|
||||
% \end{macro}
|
||||
%
|
||||
% \begin{macrocode}
|
||||
|
||||
% \end{macrocode}
|
||||
%
|
||||
%
|
||||
%
|
||||
% With the \cs{@@_set_normalized_keys:nnn} macro at hand,
|
||||
% it is also easy to provide key-value interfaces for these commands:
|
||||
|
@ -1641,7 +1723,7 @@
|
|||
\cs_new:Npn \groupthm_provide_theorem_group_from_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_provide_theorem_group:nVVVV { #2 }
|
||||
\groupthm_provide_group:nVVVV { #2 }
|
||||
\l_@@_prefix_tl
|
||||
\l_@@_suffix_tl
|
||||
\l_@@_mapname_clist
|
||||
|
@ -1661,7 +1743,7 @@
|
|||
\cs_new:Npn \groupthm_declare_theorem_group_from_keys:nn #1#2
|
||||
{
|
||||
\@@_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_declare_theorem_group:nVVVV { #2 }
|
||||
\groupthm_declare_group:nVVVV { #2 }
|
||||
\l_@@_prefix_tl
|
||||
\l_@@_suffix_tl
|
||||
\l_@@_mapname_clist
|
||||
|
@ -1738,17 +1820,14 @@
|
|||
\cs_new:Npn \groupthm_declare_theorem_group_rule:nnnn #1 #2 #3 #4
|
||||
{
|
||||
\str_set:Nx \l_tmpa_str { \tl_trim_spaces:n { #3 } }
|
||||
|
||||
\str_if_eq:VnT \l_tmpa_str { higher }
|
||||
{
|
||||
\str_set:Nn \l_tmpa_tl { after }
|
||||
}
|
||||
|
||||
\str_if_eq:VnT \l_tmpa_str { lower }
|
||||
{
|
||||
\str_set:Nn \l_tmpa_tl { before }
|
||||
}
|
||||
|
||||
\str_if_eq:nnTF { #1 } { ?? }
|
||||
{
|
||||
\hook_gset_rule:nnVn {??} {#2} \l_tmpa_tl {#4}
|
||||
|
@ -1836,9 +1915,9 @@
|
|||
% \subsection{Grouped Theorems}
|
||||
%
|
||||
%
|
||||
% \begin{macro}{\@@_use_theorem_group:n}
|
||||
% \begin{macro}{\@@_use_group:n}
|
||||
% \begin{syntax}
|
||||
% \cs{@@_use_theorem_group:n}\mymeta{theorem group}
|
||||
% \cs{@@_use_group:n}\mymeta{theorem group}
|
||||
% \end{syntax}
|
||||
%
|
||||
% Uses this theorem group, i.e.~applies its definition by writing
|
||||
|
@ -1846,7 +1925,7 @@
|
|||
% A proper error message is emitted if the group is not defined.
|
||||
%
|
||||
% \begin{macrocode}
|
||||
\cs_new:Npn \@@_use_theorem_group:n #1
|
||||
\cs_new:Npn \@@_use_group:n #1
|
||||
{
|
||||
\cs_if_exist_use:cF { @@_use_group_#1: }
|
||||
{
|
||||
|
@ -1910,7 +1989,7 @@
|
|||
% \end{macrocode}
|
||||
% Now, retrieve the group properties, by writing these into the hooks
|
||||
% \begin{macrocode}
|
||||
\clist_map_function:nN { #2 } \@@_use_theorem_group:n
|
||||
\clist_map_function:nN { #2 } \@@_use_group:n
|
||||
% \end{macrocode}
|
||||
% Execute the hooks, so that local variables will get modified according to the groups
|
||||
% and in the order that were specified for the hooks.
|
||||
|
|
|
@ -220,8 +220,9 @@
|
|||
{ #1 }
|
||||
\__groupthm_remove_from_theorem_group_ordering:n { #1 }
|
||||
}
|
||||
\cs_new:Npn \__groupthm_define_aux:nnnNNNn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
|
||||
\cs_new:Npn \__groupthm_define:nnnNNNn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
\bool_if:nT
|
||||
{
|
||||
\str_if_eq_p:nn { #1 } { new }
|
||||
|
@ -232,7 +233,6 @@
|
|||
\msg_error:nnnn { groupthm } { wrong ~ definition }
|
||||
{ #2 } { #3 } { already }
|
||||
}
|
||||
|
||||
\bool_if:nT
|
||||
{
|
||||
\str_if_eq_p:nn { #1 } { renew }
|
||||
|
@ -243,7 +243,6 @@
|
|||
\msg_error:nnnn { groupthm } { wrong ~ definition }
|
||||
{ #2 } { #3 } { not }
|
||||
}
|
||||
|
||||
\bool_if:nT
|
||||
{
|
||||
(
|
||||
|
@ -255,33 +254,31 @@
|
|||
{
|
||||
#5 { #1 }
|
||||
}
|
||||
|
||||
\cs_if_exist:NF #4
|
||||
{
|
||||
#6 #7
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_define_aux:nnnNNNn { n n n c N N n }
|
||||
|
||||
\cs_new:Npn \__groupthm_define_list_aux:nnnNNnn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
}
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_define:nnnNNNn { n n n c N N n }
|
||||
\cs_new:Npn \__groupthm_define_multiple_aux:nnnNNnn #1 #2 #3 #4 #5 #6 #7
|
||||
{
|
||||
\cs_set:Npn \__groupthm_map_aux:n ##1
|
||||
{
|
||||
\cs_new:cn { #6 }
|
||||
{
|
||||
\__groupthm_define_aux:nnncNNn
|
||||
\__groupthm_define:nnncNNn
|
||||
{ ##1 }
|
||||
{ #2 }
|
||||
{ ####1 }
|
||||
{ #3 }
|
||||
#4
|
||||
#5
|
||||
{
|
||||
#7
|
||||
}
|
||||
{ #7 }
|
||||
}
|
||||
}
|
||||
\clist_map_function:nN { #1 } \__groupthm_map_aux:n
|
||||
}
|
||||
|
||||
\__groupthm_define_list_aux:nnnNNnn
|
||||
}
|
||||
\__groupthm_define_multiple_aux:nnnNNnn
|
||||
{ new, renew, provide, declare }
|
||||
{ theorem group }
|
||||
{ __groupthm_use_group_##1: }
|
||||
|
@ -290,7 +287,9 @@
|
|||
{ groupthm_#1_group:nnnnn }
|
||||
{ { ##1 } { ##2 } { ##3 } { ##4 } { ##5 } }
|
||||
\cs_generate_variant:Nn \groupthm_new_group:nnnnn { n V V V V }
|
||||
|
||||
\cs_generate_variant:Nn \groupthm_renew_group:nnnnn { n V V V V }
|
||||
\cs_generate_variant:Nn \groupthm_provide_group:nnnnn { n V V V V }
|
||||
\cs_generate_variant:Nn \groupthm_declare_group:nnnnn { n V V V V }
|
||||
\cs_new:Npn \groupthm_new_group_from_keys:nn #1#2
|
||||
{
|
||||
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
|
@ -312,7 +311,7 @@
|
|||
\cs_new:Npn \groupthm_provide_theorem_group_from_keys:nn #1#2
|
||||
{
|
||||
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_provide_theorem_group:nVVVV { #2 }
|
||||
\groupthm_provide_group:nVVVV { #2 }
|
||||
\l__groupthm_prefix_tl
|
||||
\l__groupthm_suffix_tl
|
||||
\l__groupthm_mapname_clist
|
||||
|
@ -321,7 +320,7 @@
|
|||
\cs_new:Npn \groupthm_declare_theorem_group_from_keys:nn #1#2
|
||||
{
|
||||
\__groupthm_set_normalized_keys:nnn { #1 } { theoremgroup } { #2 }
|
||||
\groupthm_declare_theorem_group:nVVVV { #2 }
|
||||
\groupthm_declare_group:nVVVV { #2 }
|
||||
\l__groupthm_prefix_tl
|
||||
\l__groupthm_suffix_tl
|
||||
\l__groupthm_mapname_clist
|
||||
|
@ -406,7 +405,7 @@
|
|||
\__powerset_clist_foreach_aux:Nn #1 {#2}
|
||||
\clist_set_eq:NN #1 \l__powerset_copied_clist
|
||||
}
|
||||
\cs_new:Npn \__groupthm_use_theorem_group:n #1
|
||||
\cs_new:Npn \__groupthm_use_group:n #1
|
||||
{
|
||||
\cs_if_exist_use:cF { __groupthm_use_group_#1: }
|
||||
{
|
||||
|
@ -431,7 +430,7 @@
|
|||
\hook_gremove_code:nn { __groupthm/suffix }{*}
|
||||
\hook_gremove_code:nn { __groupthm/mapname }{*}
|
||||
\hook_gremove_code:nn { __groupthm/thmtools }{*}
|
||||
\clist_map_function:nN { #2 } \__groupthm_use_theorem_group:n
|
||||
\clist_map_function:nN { #2 } \__groupthm_use_group:n
|
||||
\hook_use:n { __groupthm/prefix }
|
||||
\hook_use:n { __groupthm/suffix }
|
||||
\hook_use:n { __groupthm/mapname }
|
||||
|
|
Loading…
Reference in a new issue