fix triple backslashes. add ensure group exists macro

This commit is contained in:
Maximilian Keßler 2022-01-21 14:00:33 +01:00
parent ce7436c3db
commit 3d5abe9f79
2 changed files with 36 additions and 13 deletions

View file

@ -1382,13 +1382,13 @@
{ {
% \end{macrocode} % \end{macrocode}
% %
% \begin{macro}{\@@_use_group_\meta{theorem group}:} % \begin{macro}{\@@_use_group__\meta{theorem group}:}
% %
% This is the internal macro that will be called when retrieving contents of a group. % This is the internal macro that will be called when retrieving contents of a group.
% We define this here to store the properties of the group. % We define this here to store the properties of the group.
% %
% \begin{macrocode} % \begin{macrocode}
\cs_new:cpn { @@_use_group_#1: } \cs_new:cpn { @@_use_group__#1: }
{ {
\hook_gput_code:nnn { @@/prefix } { #1 } \hook_gput_code:nnn { @@/prefix } { #1 }
{ {
@ -1442,7 +1442,7 @@
\cs_new:Npn \@@_undefine_group:n #1 \cs_new:Npn \@@_undefine_group:n #1
{ {
\tl_log:n { Undefining ~ theorem ~ group ~ '#1' } \tl_log:n { Undefining ~ theorem ~ group ~ '#1' }
\cs_undefine:c { @@_use_group_#1: } \cs_undefine:c { @@_use_group__#1: }
% \end{macrocode} % \end{macrocode}
% %
% Remove properties from hooks % Remove properties from hooks
@ -1661,7 +1661,7 @@
\@@_define_multiple:nnnNNnn \@@_define_multiple:nnnNNnn
{ new, renew, provide, declare } { new, renew, provide, declare }
{ theorem group } { theorem group }
{ @@_use_group_##1: } { @@_use_group__##1: }
\@@_undefine_group:n \@@_undefine_group:n
\@@_define_group:nnnnn \@@_define_group:nnnnn
{ groupthm_#1_group:nnnnn } { groupthm_#1_group:nnnnn }
@ -1893,6 +1893,26 @@
% \subsection{Grouped Theorems} % \subsection{Grouped Theorems}
% %
% %
%
% \begin{macro}{\@@_ensure_group_exists:n}
% \begin{syntax}
% \cs{@@_ensure_group_exists:n}\meta{theorem group}
% \end{syntax}
%
% Checks if this group exists.
% If not, produces an error message.
%
% \begin{macrocode}
\cs_new:Npn \@@_ensure_group_exists:n #1
{
\cs_if_exist:cF { @@_use_group__#1: }
{
\msg_error:nnn { groupthm } { unknown ~ group } { #1 }
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_use_group:n} % \begin{macro}{\@@_use_group:n}
% \begin{syntax} % \begin{syntax}
% \cs{@@_use_group:n}\mymeta{theorem group} % \cs{@@_use_group:n}\mymeta{theorem group}
@ -1905,10 +1925,8 @@
% \begin{macrocode} % \begin{macrocode}
\cs_new:Npn \@@_use_group:n #1 \cs_new:Npn \@@_use_group:n #1
{ {
\cs_if_exist_use:cF { @@_use_group_#1: } \@@_ensure_group_exists:n { #1 }
{ \use:c { @@_use_group__#1: }
\msg_error:nnn { groupthm } { unknown ~ group } { #1 }
}
} }
% \end{macrocode} % \end{macrocode}
% \end{macro} % \end{macro}

View file

@ -163,7 +163,7 @@
} }
\cs_new:Npn \__groupthm_define_group:nnnnn #1#2#3#4#5 \cs_new:Npn \__groupthm_define_group:nnnnn #1#2#3#4#5
{ {
\cs_new:cpn { __groupthm_use_group_#1: } \cs_new:cpn { __groupthm_use_group__#1: }
{ {
\hook_gput_code:nnn { __groupthm/prefix } { #1 } \hook_gput_code:nnn { __groupthm/prefix } { #1 }
{ {
@ -188,7 +188,7 @@
\cs_new:Npn \__groupthm_undefine_group:n #1 \cs_new:Npn \__groupthm_undefine_group:n #1
{ {
\tl_log:n { Undefining ~ theorem ~ group ~ '#1' } \tl_log:n { Undefining ~ theorem ~ group ~ '#1' }
\cs_undefine:c { __groupthm_use_group_#1: } \cs_undefine:c { __groupthm_use_group__#1: }
\hook_gremove_code:nn { __groupthm/prefix } { #1 } \hook_gremove_code:nn { __groupthm/prefix } { #1 }
\hook_gremove_code:nn { __groupthm/suffix } { #1 } \hook_gremove_code:nn { __groupthm/suffix } { #1 }
\hook_gremove_code:nn { __groupthm/mapname } { #1 } \hook_gremove_code:nn { __groupthm/mapname } { #1 }
@ -288,7 +288,7 @@
\__groupthm_define_multiple:nnnNNnn \__groupthm_define_multiple:nnnNNnn
{ new, renew, provide, declare } { new, renew, provide, declare }
{ theorem group } { theorem group }
{ __groupthm_use_group_##1: } { __groupthm_use_group__##1: }
\__groupthm_undefine_group:n \__groupthm_undefine_group:n
\__groupthm_define_group:nnnnn \__groupthm_define_group:nnnnn
{ groupthm_#1_group:nnnnn } { groupthm_#1_group:nnnnn }
@ -402,13 +402,18 @@
\__powerset_clist_foreach_aux:Nn #1 {#2} \__powerset_clist_foreach_aux:Nn #1 {#2}
\clist_set_eq:NN #1 \l__powerset_copied_clist \clist_set_eq:NN #1 \l__powerset_copied_clist
} }
\cs_new:Npn \__groupthm_use_group:n #1 \cs_new:Npn \__groupthm_ensure_group_exists:n #1
{ {
\cs_if_exist_use:cF { __groupthm_use_group_#1: } \cs_if_exist:cF { __groupthm_use_group__#1: }
{ {
\msg_error:nnn { groupthm } { unknown ~ group } { #1 } \msg_error:nnn { groupthm } { unknown ~ group } { #1 }
} }
} }
\cs_new:Npn \__groupthm_use_group:n #1
{
\__groupthm_ensure_group_exists:n { #1 }
\use:c { __groupthm_use_group__#1: }
}
\cs_new:Npn \__groupthm_use_function_on_name:n #1 \cs_new:Npn \__groupthm_use_function_on_name:n #1
{ {
\tl_set:Nx \l__groupthm_name_tl \tl_set:Nx \l__groupthm_name_tl