From 06bcb6cf102ebfb7ea68e3f237df7b752a54b89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 21 Jan 2022 15:32:23 +0100 Subject: [PATCH] fix some bugs regarding usage of \declarator --- doc/environments/groupthm/groupthm.dtx | 22 +++++++++++++--------- doc/environments/groupthm/groupthm.sty | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/doc/environments/groupthm/groupthm.dtx b/doc/environments/groupthm/groupthm.dtx index 6cbcf0d..0a3abcc 100644 --- a/doc/environments/groupthm/groupthm.dtx +++ b/doc/environments/groupthm/groupthm.dtx @@ -1588,6 +1588,7 @@ } { \tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. } + \tl_log:n { Declarator ~ was ~ #1. } #5 { #3 } } % \end{macrocode} @@ -1708,7 +1709,6 @@ { \cs_set:Npn \@@_map_aux:n ##1 { - \def \declarator { ##1 } \cs_new:cn { #2 } { #3 @@ -1733,7 +1733,7 @@ % \begin{macrocode} \@@_wrap_multiple:nnn { new, renew, provide, declare } - { groupthm_ \declarator _group:nn } + { groupthm_#1_group:nn } { \@@_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 } \use:c { groupthm_#1_group:nVVVV } @@ -1759,16 +1759,17 @@ % and upper-case versions of the current declarator. % % \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_set:Npn \@@_map_aux:n ##1 { - \def \declarator { ##1 } \def \Declarator { \text_titlecase_first:n { ##1 } } - \exp_args:Nc \NewDocumentCommand { #2 } { #3 } - { - #4 - } + \@@_new_document_command:cnn { #2 } { #3 } { #4 } } \clist_map_function:nN { #1 } \@@_map_aux:n } @@ -1785,7 +1786,7 @@ { \Declarator TheoremGroup } { O{} m } { - \use:c { groupthm_ \declarator _group:nn } { ##1 } { ##2 } + \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 } } % \end{macrocode} % \end{macro} @@ -2070,7 +2071,10 @@ % \end{macrocode} % Now, retrieve the group properties, by writing these into the hooks % \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} % Execute the hooks, so that local variables will get modified according to the groups % and in the order that were specified for the hooks. diff --git a/doc/environments/groupthm/groupthm.sty b/doc/environments/groupthm/groupthm.sty index b6cddf7..f65811f 100644 --- a/doc/environments/groupthm/groupthm.sty +++ b/doc/environments/groupthm/groupthm.sty @@ -257,6 +257,7 @@ } { \tl_log:n { Removing ~ definition ~ of ~ #2 ~ '#3'. } + \tl_log:n { Declarator ~ was ~ #1. } #5 { #3 } } \cs_if_exist:NTF #4 @@ -304,7 +305,6 @@ { \cs_set:Npn \__groupthm_map_aux:n ##1 { - \def \declarator { ##1 } \cs_new:cn { #2 } { #3 @@ -315,7 +315,7 @@ \__groupthm_wrap_multiple:nnn { new, renew, provide, declare } - { groupthm_ \declarator _group:nn } + { groupthm_#1_group:nn } { \__groupthm_set_normalized_keys:nnn { ##1 } { theoremgroup } { ##2 } \use:c { groupthm_#1_group:nVVVV } @@ -325,16 +325,17 @@ \l__groupthm_mapname_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_set:Npn \__groupthm_map_aux:n ##1 { - \def \declarator { ##1 } \def \Declarator { \text_titlecase_first:n { ##1 } } - \exp_args:Nc \NewDocumentCommand { #2 } { #3 } - { - #4 - } + \__groupthm_new_document_command:cnn { #2 } { #3 } { #4 } } \clist_map_function:nN { #1 } \__groupthm_map_aux:n } @@ -343,7 +344,7 @@ { \Declarator TheoremGroup } { 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 { @@ -467,7 +468,10 @@ \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_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/suffix } \hook_use:n { __groupthm/mapname }