From 48651b491976be468ce6383ceee369ae0dfb7dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 31 Jan 2022 21:02:48 +0100 Subject: [PATCH] activate caching for all Document Commands --- src/environments/groupthm/groupthm.dtx | 75 +++++++++++++++++++------- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx index 4a43b19..b52e1d0 100644 --- a/src/environments/groupthm/groupthm.dtx +++ b/src/environments/groupthm/groupthm.dtx @@ -1795,7 +1795,10 @@ { \@@_Declarator: TheoremGroup } { O{} m } { - \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 } + \@@_lazy:n + { + \use:c { groupthm_#1 _group:nn } { ##1 } { ##2 } + } } % \end{macrocode} % \end{macro} @@ -1850,7 +1853,10 @@ % \begin{macrocode} \NewDocumentCommand { \DeclareTheoremGroupRule } { O{??} m m m } { - \groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4} + \@@_lazy:n + { + \groupthm_declare_group_rule:nnnn {#1} {#2} {#3} {#4} + } } % \end{macrocode} % \end{macro} @@ -1886,7 +1892,10 @@ % \begin{macrocode} \NewDocumentCommand { \AddTheoremGroupParent } { m m } { - \groupthm_add_parent:nn { #1 } { #2 } + \@@_lazy:n + { + \groupthm_add_parent:nn { #1 } { #2 } + } } % \end{macrocode} % \end{macro} @@ -1973,7 +1982,9 @@ % \begin{macrocode} \NewDocumentCommand { \AppendToTheoremGroup } { O{} m } { - \groupthm_append_to_group:nn { #1 } { #2 } + \@@_lazy:n { + \groupthm_append_to_group:nn { #1 } { #2 } + } } % \end{macrocode} % \end{macro} @@ -2289,13 +2300,7 @@ { \@@_Declarator: GroupedTheorem } { s O{} m } { - \bool_if:NTF \g_@@_cache_bool - { - \hook_gput_code:nnn {@@/definelazy} { groupthm } - } - { - \use:n - } + \@@_lazy:n { \use:c { groupthm_#1_theorem:nnn } { ##2 } @@ -2448,10 +2453,13 @@ { \@@_Declarator: GroupedTheoremFamily } { s O{} m } { - \use:c { groupthm_#1_family:nnn } - { ##2 } - { ##3 } - { ##1 } + \@@_lazy:n + { + \use:c { groupthm_#1_family:nnn } + { ##2 } + { ##3 } + { ##1 } + } } % \end{macrocode} % \end{macro} @@ -2497,9 +2505,12 @@ % % \begin{macrocode} \NewDocumentCommand { \AddTheoremToGroup } { m } - { - \groupthm_add_theorem_to_group:n { #1 } - } + { + \@@_lazy:n + { + \groupthm_add_theorem_to_group:n { #1 } + } + } % \end{macrocode} % \end{macro} % @@ -2665,6 +2676,34 @@ % % \subsection{Caching} % +% +% +% +% +% \begin{macro}{\@@_lazy:n} +% \begin{syntax} +% \cs{@@_lazy:n}\marg{code} +% \end{syntax} +% +% Executes this code lazy at beginning of the document, +% iff caching is active. +% +% At beginning of document, code will be only executed +% if the aux file version was too old, otherwise dropped. +% +% \begin{macrocode} +\cs_new:Npn \@@_lazy:n + { + \bool_if:NTF \g_@@_cache_bool + { + \hook_gput_code:nnn {@@/definelazy} { groupthm } + } + { + \use:n + } + } +% \end{macrocode} +% \end{macro} % % %