fix some bugs regarding usage of \declarator

This commit is contained in:
Maximilian Keßler 2022-01-21 15:32:23 +01:00
parent 0e78a52b61
commit 06bcb6cf10
2 changed files with 26 additions and 18 deletions

View file

@ -1588,6 +1588,7 @@
} }
{ {
\tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. } \tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. }
\tl_log:n { Declarator ~ was ~ #1. }
#5 { #3 } #5 { #3 }
} }
% \end{macrocode} % \end{macrocode}
@ -1708,7 +1709,6 @@
{ {
\cs_set:Npn \@@_map_aux:n ##1 \cs_set:Npn \@@_map_aux:n ##1
{ {
\def \declarator { ##1 }
\cs_new:cn { #2 } \cs_new:cn { #2 }
{ {
#3 #3
@ -1733,7 +1733,7 @@
% \begin{macrocode} % \begin{macrocode}
\@@_wrap_multiple:nnn \@@_wrap_multiple:nnn
{ new, renew, provide, declare } { new, renew, provide, declare }
{ groupthm_ \declarator _group:nn } { groupthm_#1_group:nn }
{ {
\@@_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 } \@@_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 }
\use:c { groupthm_#1_group:nVVVV } \use:c { groupthm_#1_group:nVVVV }
@ -1759,16 +1759,17 @@
% and upper-case versions of the current declarator. % and upper-case versions of the current declarator.
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \@@_new_document_command:Nnn #1 #2 #3
{
\NewDocumentCommand { #1 } { #2 } { #3 }
}
\cs_generate_variant:Nn \@@_new_document_command:Nnn { c n n }
\cs_new:Npn \@@_wrap_multiple_document:nnnn #1 #2 #3 #4 \cs_new:Npn \@@_wrap_multiple_document:nnnn #1 #2 #3 #4
{ {
\cs_set:Npn \@@_map_aux:n ##1 \cs_set:Npn \@@_map_aux:n ##1
{ {
\def \declarator { ##1 }
\def \Declarator { \text_titlecase_first:n { ##1 } } \def \Declarator { \text_titlecase_first:n { ##1 } }
\exp_args:Nc \NewDocumentCommand { #2 } { #3 } \@@_new_document_command:cnn { #2 } { #3 } { #4 }
{
#4
}
} }
\clist_map_function:nN { #1 } \@@_map_aux:n \clist_map_function:nN { #1 } \@@_map_aux:n
} }
@ -1785,7 +1786,7 @@
{ \Declarator TheoremGroup } { \Declarator TheoremGroup }
{ O{} m } { O{} m }
{ {
\use:c { groupthm_ \declarator _group:nn } { ##1 } { ##2 } \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 }
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}
@ -2070,7 +2071,10 @@
% \end{macrocode} % \end{macrocode}
% Now, retrieve the group properties, by writing these into the hooks % Now, retrieve the group properties, by writing these into the hooks
% \begin{macrocode} % \begin{macrocode}
\clist_map_function:nN { #2 } \@@_use_group:n \@@_flatten_groups_hierarchy:nN { #2 } \l_@@_group_clist
\clist_map_function:NN \l_@@_group_clist \@@_use_group:n
\tl_log:x { Flattened ~ groups ~ '#2' ~ to ~ '\clist_use:Nn \l_@@_group_clist {,}' ~ when ~
defining ~ theorem ~ '#1' }
% \end{macrocode} % \end{macrocode}
% Execute the hooks, so that local variables will get modified according to the groups % Execute the hooks, so that local variables will get modified according to the groups
% and in the order that were specified for the hooks. % and in the order that were specified for the hooks.

View file

@ -257,6 +257,7 @@
} }
{ {
\tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. } \tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. }
\tl_log:n { Declarator ~ was ~ #1. }
#5 { #3 } #5 { #3 }
} }
\cs_if_exist:NTF #4 \cs_if_exist:NTF #4
@ -304,7 +305,6 @@
{ {
\cs_set:Npn \__groupthm_map_aux:n ##1 \cs_set:Npn \__groupthm_map_aux:n ##1
{ {
\def \declarator { ##1 }
\cs_new:cn { #2 } \cs_new:cn { #2 }
{ {
#3 #3
@ -315,7 +315,7 @@
\__groupthm_wrap_multiple:nnn \__groupthm_wrap_multiple:nnn
{ new, renew, provide, declare } { new, renew, provide, declare }
{ groupthm_ \declarator _group:nn } { groupthm_#1_group:nn }
{ {
\__groupthm_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 } \__groupthm_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 }
\use:c { groupthm_#1_group:nVVVV } \use:c { groupthm_#1_group:nVVVV }
@ -325,16 +325,17 @@
\l__groupthm_mapname_clist \l__groupthm_mapname_clist
\l__groupthm_thmtools_clist \l__groupthm_thmtools_clist
} }
\cs_new:Npn \__groupthm_new_document_command:Nnn #1 #2 #3
{
\NewDocumentCommand { #1 } { #2 } { #3 }
}
\cs_generate_variant:Nn \__groupthm_new_document_command:Nnn { c n n }
\cs_new:Npn \__groupthm_wrap_multiple_document:nnnn #1 #2 #3 #4 \cs_new:Npn \__groupthm_wrap_multiple_document:nnnn #1 #2 #3 #4
{ {
\cs_set:Npn \__groupthm_map_aux:n ##1 \cs_set:Npn \__groupthm_map_aux:n ##1
{ {
\def \declarator { ##1 }
\def \Declarator { \text_titlecase_first:n { ##1 } } \def \Declarator { \text_titlecase_first:n { ##1 } }
\exp_args:Nc \NewDocumentCommand { #2 } { #3 } \__groupthm_new_document_command:cnn { #2 } { #3 } { #4 }
{
#4
}
} }
\clist_map_function:nN { #1 } \__groupthm_map_aux:n \clist_map_function:nN { #1 } \__groupthm_map_aux:n
} }
@ -343,7 +344,7 @@
{ \Declarator TheoremGroup } { \Declarator TheoremGroup }
{ O{} m } { O{} m }
{ {
\use:c { groupthm_ \declarator _group:nn } { ##1 } { ##2 } \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 }
} }
\cs_new:Npn \groupthm_declare_group_rule:nnnn #1 #2 #3 #4 \cs_new:Npn \groupthm_declare_group_rule:nnnn #1 #2 #3 #4
{ {
@ -467,7 +468,10 @@
\hook_gremove_code:nn { __groupthm/suffix }{*} \hook_gremove_code:nn { __groupthm/suffix }{*}
\hook_gremove_code:nn { __groupthm/mapname }{*} \hook_gremove_code:nn { __groupthm/mapname }{*}
\hook_gremove_code:nn { __groupthm/thmtools }{*} \hook_gremove_code:nn { __groupthm/thmtools }{*}
\clist_map_function:nN { #2 } \__groupthm_use_group:n \__groupthm_flatten_groups_hierarchy:nN { #2 } \l__groupthm_group_clist
\clist_map_function:NN \l__groupthm_group_clist \__groupthm_use_group:n
\tl_log:x { Flattened ~ groups ~ '#2' ~ to ~ '\clist_use:Nn \l__groupthm_group_clist {,}' ~ when ~
defining ~ theorem ~ '#1' }
\hook_use:n { __groupthm/prefix } \hook_use:n { __groupthm/prefix }
\hook_use:n { __groupthm/suffix } \hook_use:n { __groupthm/suffix }
\hook_use:n { __groupthm/mapname } \hook_use:n { __groupthm/mapname }