From b041d8c9905615f973265953d6495155b9e61f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 31 Jan 2022 19:17:58 +0100 Subject: [PATCH] implement option interface for groupthm. --- src/environments/groupthm/groupthm.dtx | 78 ++++++++++++++++++- .../groupthm/groupthm.synctex(busy) | 0 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 src/environments/groupthm/groupthm.synctex(busy) diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx index 8c57f15..e138894 100644 --- a/src/environments/groupthm/groupthm.dtx +++ b/src/environments/groupthm/groupthm.dtx @@ -836,6 +836,7 @@ % \begin{macrocode} \RequirePackage{amsthm} \RequirePackage{thmtools} +\RequirePackage{l3keys2e} % \end{macrocode} % % \begin{macro}{\@@_thmtools_declare_theorem:nn, \@@_thmtools_declare_theorem:Vn} @@ -965,6 +966,9 @@ \hook_new:n { @@/thmtools } % \end{macrocode} % \begin{macrocode} +\hook_new:n { @@/definelazy } +% \end{macrocode} +% \begin{macrocode} \hook_new:n { @@/groupsort } % \end{macrocode} % @@ -1047,6 +1051,10 @@ \bool_new:N \l_@@_in_family_options_environment_bool % \end{macrocode} % \end{variable} +% +% +% +% % \begin{variable}{\g_@@_append_groups_int} % % This counts the number of times we appended to a group. @@ -1055,6 +1063,33 @@ \int_new:N \g_@@_append_groups_int % \end{macrocode} % \end{variable} +% +% +% +% +% \begin{variable}{\g_@@_cache_bool} +% +% This stores whether we cache definitions in the aux file. +% +% \begin{macrocode} +\bool_new:N \g_@@_cache_bool +% \end{macrocode} +% \end{variable} +% +% +% +% \begin{variable}{\g_@@_cache_version_aux_int, \g_@@_cache_version_document_int} +% +% The version of the cached theorems in the aux file +% and the version the package has been loaded with. +% +% \begin{macrocode} +\int_new:N \g_@@_cache_version_aux_int +\int_new:N \g_@@_cache_version_document_int +\int_set:Nn \g_@@_cache_version_aux_int { -1 } +% \end{macrocode} +% \end{variable} +% % % % \subsection{Key interface} @@ -1068,6 +1103,14 @@ % % % \begin{macrocode} +\keys_define:nn { groupthm } + { + cache .bool_set:N = \g_@@_cache_bool, + cache .default:n = { true }, + __cache version__ .int_set:N = \g_@@_cache_version_document_int, + cache version .meta:nn = { groupthm } { cache = true, __cache version__ = #1 }, + cache version .default:n = { 0 }, + } \keys_define:nn { groupthm / theorem ~ group } { prefix .tl_set:N = \l_@@_key_prefix_tl, @@ -1118,6 +1161,13 @@ } % \end{macrocode} % +% +% +% Process package options: +% \begin{macrocode} +\ProcessKeysOptions { groupthm } +% \end{macrocode} +% % % The only key whose default requires such handling is the \enquote{\texttt{name}} key, % which will be set to a capitalized version of the environment name @@ -1918,11 +1968,13 @@ % % We also provide the three default groups: % +% \begin{variable}{all, starred, unnumbered} % \begin{macrocode} \groupthm_new_group:nnnnn { all } { } { } { } { } \groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no } \groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no } % \end{macrocode} +% \end{variable} % % \subsection{Iterating over powersets} % For generating the different variants of a theorem family, @@ -2224,10 +2276,27 @@ { \@@_Declarator: GroupedTheorem } { s O{} m } { - \use:c { groupthm_#1_theorem:nnn } + \bool_if:nTF + { + \g_@@_cache_bool + && + \int_compare_p:n + { + \g_@@_cache_version_aux_int < \g_@@_cache_version_document_int + } + } + { + \hook_gput_code:nnn {@@/lazy} { groupthm } + } + { + \use:n + } + { + \use:c { groupthm_#1_theorem:nnn } { ##2 } { ##3 } { ##1 } + } } % \end{macrocode} % \end{macro} @@ -2585,8 +2654,11 @@ } % \end{macrocode} % \end{macro} -% -% +% +% +% +% +% \subsection{Caching} % % % diff --git a/src/environments/groupthm/groupthm.synctex(busy) b/src/environments/groupthm/groupthm.synctex(busy) new file mode 100644 index 0000000..e69de29