groupthm: handle theorem family options cache

also use an aux file hook to collect definitions
    from aux file
This commit is contained in:
Maximilian Keßler 2022-01-31 22:17:58 +01:00
parent 5b7e93e76a
commit a3211f8a8f

View file

@ -855,11 +855,14 @@
{
\hook_gput_code:nnn { enddocument / afterlastpage } { groupthm }
{
\iow_now:cx { @auxout }
\iow_now:cn { @auxout }
{
\token_to_str:N \ExplSyntaxOn
\exp_not:N \@@_thmtools_declare_theorem:nn { #1 } { #2 }
\token_to_str:N \ExplSyntaxOff
\ExplSyntaxOn
\hook_gput_code:nnn { @@ / auxfile define cached } { groupthm }
{
\@@_thmtools_declare_theorem:nn { #1 } { #2 }
}
\ExplSyntaxOff
}
}
}
@ -979,7 +982,8 @@
\hook_new:n { @@/thmtools }
% \end{macrocode}
% \begin{macrocode}
\hook_new:n { @@/definelazy }
\hook_new:n { @@/document define cached }
\hook_new:n { @@/auxfile define cached }
% \end{macrocode}
% \begin{macrocode}
\hook_new:n { @@/groupsort }
@ -2526,7 +2530,7 @@
% The \meta{extra groups} will be added regardless of the arguments given
% to the \meta{theorem family}
% The \meta{declaring backend} is one of \texttt{New}, \texttt{Renew}, \texttt{Provide}
% and \texttt{Declare} and is given to the \texttt{DocumentEnvironment} command from \pkg{xpars}.
% and \texttt{Declare} and is given to the \texttt{DocumentEnvironment} command from \pkg{xparse}.
%
% \begin{macrocode}
\cs_new:Npn \@@_define_family_options:nnnn #1 #2 #3 #4
@ -2579,11 +2583,14 @@
}
\hook_gput_code:nnn { enddocument / afterlastpage } { groupthm }
{
\iow_now:cx { @auxout }
\iow_now:cn { @auxout }
{
\token_to_str:N \ExplSyntaxOn
\exp_not:N \@@_define_family_options:nnnn { #1 } { #2 } { #3 } { #4 }
\token_to_str:N \ExplSyntaxOff
\ExplSyntaxOn
\hook_gput_code:nnn { @@ / auxfile define cached } { groupthm }
{
\@@_define_family_options:nnnn { #1 } { #2 } { #3 } { #4 }
}
\ExplSyntaxOff
}
}
}
@ -2705,7 +2712,7 @@
{
\bool_if:NTF \g_@@_cache_bool
{
\hook_gput_code:nnn {@@/definelazy} { groupthm }
\hook_gput_code:nnn {@@/document define cached} { groupthm }
}
{
\use:n
@ -2716,55 +2723,51 @@
%
%
%
% This makes sure that at the beginning of the document, after reading
% in the aux file with possible precomputed definitions of the last run,
% we will execute either the definitions of the auxfile or all the
% lazy computation from the current run that we collected.
%
% These hooks should actually be one-time hooks, but this would cause
% problems when \LaTeX rereads the aux file a second time at the end
% of the document, since we want no declarations there
%
%
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { groupthm }
{
\bool_if:nT
{
\g_@@_cache_bool
&&
\int_compare_p:n
{
\g_@@_cache_version_aux_int < \g_@@_cache_version_document_int
}
}
{
\hook_use_once:n { @@ / define lazy }
}
}
\hook_gput_code:nnn { begindocument } { groupthm }
{
\bool_if:nTF
{
\g_@@_cache_bool
&&
\int_compare_p:n
{
\g_@@_cache_version_aux_int < \g_@@_cache_version_document_int
}
}
{
\hook_use:n { @@ / document define cached }
}
{
\hook_use:n { @@ / auxfile define cached }
}
}
% \end{macrocode}
%
%
%
%
% This code makes sure that in the next run of \LaTeX, when reading in the aux-file,
% before processing the rest of the groupthm aux file macros,
% we set the depth of the document cache version available so that we can
% query this value in the next run as soon as possible.
%
% \begin{macrocode}
\hook_gput_code:nnn { enddocument / afterlastpage } { before-groupthm }
{
\cs_set_eq:NN \@@_thmtools_declare_theorem:nn \use_none:nn
\iow_now:cx { @auxout }
{
\token_to_str:N \ExplSyntaxOn
\int_gset:Nn \g_@@_cache_version_aux_int
{ \int_use:N \g_@@_cache_version_document_int }
}
\iow_now:cn { @auxout }
{
\bool_if:nT
{
\g_@@_cache_bool
&&
\int_compare_p:n
{
\g_@@_cache_version_aux_int < \g_@@_cache_version_document_int
}
}
{
\cs_set_eq:NN \@@_thmtools_declare_theorem:nn \use_none:nn
}
}
\iow_now:cx { @auxout }
{
\token_to_str:N \ExplSyntaxOff
}
}