add makefile in cache tests
Build branch fast-groupthm (b15dedb) from kesslermaximilian/LatexPackages
This commit is contained in:
parent
7086f95008
commit
286377b621
4 changed files with 444 additions and 167 deletions
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"build_time": "",
|
||||
"source files": {
|
||||
"version": "v2.8.1-18-g48651b4",
|
||||
"commit": "48651b491976be468ce6383ceee369ae0dfb7dac",
|
||||
"version": "v2.8.2",
|
||||
"commit": "b15dedb36666df299d532ebacd861ff40858857b",
|
||||
"dirty": false
|
||||
},
|
||||
"pytex": {
|
||||
|
@ -352,6 +352,17 @@
|
|||
"md5sum": "70c0a0df0c209857ec5eb10971b727e9",
|
||||
"dirty": false
|
||||
},
|
||||
{
|
||||
"name": "wip/cache/mkessler-cache.sty",
|
||||
"source file": "wip/cache/cache.pysty3",
|
||||
"build time": "2022/02/03 14:08",
|
||||
"source version": "v2.8.2",
|
||||
"source commit hash": "b15dedb36666df299d532ebacd861ff40858857b",
|
||||
"pytex version": "v1.2.0-31-gc9bb0e8",
|
||||
"pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51",
|
||||
"md5sum": "6ee0c2e6128d54b6743531b515d7c905",
|
||||
"dirty": false
|
||||
},
|
||||
{
|
||||
"name": "math/categories/mkessler-categories.sty",
|
||||
"source file": "math/categories/categories.pysty3",
|
||||
|
@ -410,23 +421,23 @@
|
|||
{
|
||||
"name": "environments/groupthm/groupthm.sty",
|
||||
"source file": "environments/groupthm/groupthm.dtx",
|
||||
"build time": "2022/01/31 20:05",
|
||||
"source version": "v2.8.1-18-g48651b4",
|
||||
"source commit hash": "48651b491976be468ce6383ceee369ae0dfb7dac",
|
||||
"build time": "2022/02/03 14:08",
|
||||
"source version": "v2.8.2",
|
||||
"source commit hash": "b15dedb36666df299d532ebacd861ff40858857b",
|
||||
"pytex version": "v1.2.0-31-gc9bb0e8",
|
||||
"pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51",
|
||||
"md5sum": "271b4255bfd348eb8fb3c3dbd63c4b63",
|
||||
"md5sum": "f1cce2b87d3e6d2b320b84daece33f22",
|
||||
"dirty": false
|
||||
},
|
||||
{
|
||||
"name": "environments/fancythm/fancythm.sty",
|
||||
"source file": "environments/fancythm/fancythm.dtx",
|
||||
"build time": "2022/01/31 20:05",
|
||||
"source version": "v2.8.1-18-g48651b4",
|
||||
"source commit hash": "48651b491976be468ce6383ceee369ae0dfb7dac",
|
||||
"build time": "2022/02/03 14:08",
|
||||
"source version": "v2.8.2",
|
||||
"source commit hash": "b15dedb36666df299d532ebacd861ff40858857b",
|
||||
"pytex version": "v1.2.0-31-gc9bb0e8",
|
||||
"pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51",
|
||||
"md5sum": "607c774cd2cfd9efa081b6d3e2225481",
|
||||
"md5sum": "e659775e98a2451a69f4bf6ab66917f0",
|
||||
"dirty": false
|
||||
}
|
||||
]
|
||||
|
|
|
@ -184,7 +184,7 @@
|
|||
}
|
||||
\tl_set:Nx \l__fancythm_name_tl
|
||||
{
|
||||
\exp_not:N \__fancythm_translate:n { \tl_use:N \l__fancythm_name_tl }
|
||||
\exp_not:N \csname __fancythm_translate:n \exp_not:N \endcsname { \tl_use:N \l__fancythm_name_tl }
|
||||
}
|
||||
}
|
||||
\cs_new:Npn \__fancythm_wrap_multiple:nnn #1 #2 #3
|
||||
|
@ -209,11 +209,11 @@
|
|||
{
|
||||
\IfBooleanT { ####1 }
|
||||
{
|
||||
\groupthm_add_theorem_to_group:n { star }
|
||||
\AddTheoremToGroup { star }
|
||||
}
|
||||
\IfBooleanT { ####2 }
|
||||
{
|
||||
\groupthm_add_theorem_to_group:n { dagger }
|
||||
\AddTheoremToGroup { dagger }
|
||||
}
|
||||
}
|
||||
{ ##2 }
|
||||
|
@ -379,6 +379,7 @@
|
|||
\fancythm_provide_tiny_theorem:nn { } { reminder }
|
||||
}
|
||||
}
|
||||
\DeclareHookRule { begindocument / before } { groupthm } { after } { fancythm }
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `fancythm.sty'.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%%
|
||||
%% The original source files were:
|
||||
%%
|
||||
%% groupthm.dtx (with options: `package')
|
||||
%% groupthm.dtx (with options: `package,benchmark')
|
||||
%%
|
||||
%% IMPORTANT NOTICE:
|
||||
%%
|
||||
|
@ -21,25 +21,18 @@
|
|||
%% same distribution. (The sources need not necessarily be
|
||||
%% in the same archive or directory.)
|
||||
%% File: groupthm.dtx
|
||||
\ProvidesExplPackage{groupthm}{2022/01/17}{0.0.1}{Grouped theorems.}
|
||||
\ProvidesExplPackage{groupthm}{2022/02/02}{0.0.2}{Grouped theorems.}
|
||||
\RequirePackage{amsthm}
|
||||
\RequirePackage{thmtools}
|
||||
\RequirePackage{l3benchmark}
|
||||
\RequirePackage{l3keys2e}
|
||||
\cs_new:Npn \__groupthm_thmtools_declare_theorem:nn #1 #2
|
||||
{
|
||||
\tl_log:n { Declaring ~ thmtools ~ theorem ~ #2 }
|
||||
\declaretheorem [ #1 ] { #2 }
|
||||
\bool_if:NT \g__groupthm_cache_bool
|
||||
\__groupthm_cache:n
|
||||
{
|
||||
\hook_gput_code:nnn { enddocument / afterlastpage } { groupthm }
|
||||
{
|
||||
\iow_now:cx { @auxout }
|
||||
{
|
||||
\token_to_str:N \ExplSyntaxOn
|
||||
\exp_not:N \__groupthm_thmtools_declare_theorem:nn { #1 } { #2 }
|
||||
\token_to_str:N \ExplSyntaxOff
|
||||
}
|
||||
}
|
||||
\csname __groupthm_thmtools_declare_theorem:nn \endcsname { #1 } { #2 }
|
||||
}
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_thmtools_declare_theorem:nn { V n }
|
||||
|
@ -83,7 +76,6 @@
|
|||
\hook_new:n { __groupthm/suffix }
|
||||
\hook_new:n { __groupthm/mapname }
|
||||
\hook_new:n { __groupthm/thmtools }
|
||||
\hook_new:n { __groupthm/definelazy }
|
||||
\hook_new:n { __groupthm/groupsort }
|
||||
\cs_generate_variant:Nn \hook_gset_rule:nnnn { n n V n }
|
||||
\bool_new:N \l__groupthm_key_starred_version_bool
|
||||
|
@ -106,6 +98,10 @@
|
|||
\int_new:N \g__groupthm_cache_version_aux_int
|
||||
\int_new:N \g__groupthm_cache_version_document_int
|
||||
\int_set:Nn \g__groupthm_cache_version_aux_int { -1 }
|
||||
\tl_new:N \g__groupthm_lazy_document_tl
|
||||
\tl_new:N \g__groupthm_lazy_auxfile_tl
|
||||
\clist_new:N \g__groupthm_dump_auxfile_clist
|
||||
\clist_new:N \g__groupthm_dump_cache_clist
|
||||
\keys_define:nn { groupthm }
|
||||
{
|
||||
cache .bool_set:N = \g__groupthm_cache_bool,
|
||||
|
@ -342,6 +338,8 @@
|
|||
\cs_set:Npn \__groupthm_map_aux:n ##1
|
||||
{
|
||||
\cs_new:cn { #6 }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\__groupthm_define:nnncNNn
|
||||
{ ##1 }
|
||||
|
@ -353,6 +351,7 @@
|
|||
{ #7 }
|
||||
}
|
||||
}
|
||||
}
|
||||
\clist_map_function:nN { #1 } \__groupthm_map_aux:n
|
||||
}
|
||||
\__groupthm_define_multiple:nnnNNnn
|
||||
|
@ -416,6 +415,8 @@
|
|||
}
|
||||
}
|
||||
\cs_new:Npn \groupthm_declare_group_rule:nnnn #1 #2 #3 #4
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\str_set:Nx \l_tmpa_str { \tl_trim_spaces:n { #3 } }
|
||||
\str_if_eq:VnT \l_tmpa_str { higher }
|
||||
|
@ -434,6 +435,7 @@
|
|||
\hook_gset_rule:nnVn { __groupthm / #1 } {#2} \l_tmpa_str {#4}
|
||||
}
|
||||
}
|
||||
}
|
||||
\cs_generate_variant:Nn \groupthm_declare_group_rule:nnnn { n n n x }
|
||||
\NewDocumentCommand { \DeclareTheoremGroupRule } { O{??} m m m }
|
||||
{
|
||||
|
@ -443,15 +445,18 @@
|
|||
}
|
||||
}
|
||||
\cs_new:Npn \groupthm_add_parent:nn #1 #2
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\__groupthm_ensure_group_exists:n { #1 }
|
||||
\__groupthm_ensure_group_exists:n { #2 }
|
||||
\clist_gput_left:cn { g__groupthm_parents_group__#1__clist } { #2 }
|
||||
}
|
||||
}
|
||||
\cs_generate_variant:Nn \groupthm_add_parent:nn { n x }
|
||||
\NewDocumentCommand { \AddTheoremGroupParent } { m m }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
\__groupthmlazy:n
|
||||
{
|
||||
\groupthm_add_parent:nn { #1 } { #2 }
|
||||
}
|
||||
|
@ -481,6 +486,8 @@
|
|||
}
|
||||
}
|
||||
\cs_new:Npn \groupthm_append_to_group:nn #1 #2
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\groupthm_new_group:nx { #1 } { __append__ \int_use:N \g__groupthm_append_groups_int }
|
||||
\groupthm_add_parent:nx { #2 } { __append__ \int_use:N \g__groupthm_append_groups_int }
|
||||
|
@ -488,15 +495,14 @@
|
|||
{ ?? } { #2 } { before } { __append__ \int_use:N \g__groupthm_append_groups_int }
|
||||
\int_gincr:N \g__groupthm_append_groups_int
|
||||
}
|
||||
}
|
||||
\NewDocumentCommand { \AppendToTheoremGroup } { O{} m }
|
||||
{
|
||||
\__groupthm_lazy:n {
|
||||
\__groupthmlazy:n
|
||||
{
|
||||
\groupthm_append_to_group:nn { #1 } { #2 }
|
||||
}
|
||||
}
|
||||
\groupthm_new_group:nnnnn { all } { } { } { } { }
|
||||
\groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no }
|
||||
\groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no }
|
||||
\clist_new:N \l__powerset_copied_clist
|
||||
\seq_new:N \l__powerset_saved_seq
|
||||
\cs_generate_variant:Nn \clist_remove_all:Nn { N V }
|
||||
|
@ -593,6 +599,8 @@
|
|||
\__groupthm_wrap_multiple:nnn
|
||||
{ new, provide }
|
||||
{ groupthm_#1_theorem:nnn }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\__groupthm_set_normalized_keys:nnn { ##1 } { grouped ~ theorem } { ##2 }
|
||||
\bool_if:nT { ##3 }
|
||||
|
@ -614,6 +622,7 @@
|
|||
\l__groupthm_thmtools_clist
|
||||
}
|
||||
}
|
||||
}
|
||||
\__groupthm_wrap_multiple_document:nnnn
|
||||
{ new, provide }
|
||||
{ \__groupthm_Declarator: GroupedTheorem }
|
||||
|
@ -659,6 +668,8 @@
|
|||
\__groupthm_wrap_multiple:nnn
|
||||
{ new, provide }
|
||||
{ groupthm_#1_family:nnn }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\__groupthm_set_normalized_keys:nnn { ##1 } { theorem ~ family } { ##2 }
|
||||
\bool_if:nTF { ##3}
|
||||
|
@ -679,6 +690,7 @@
|
|||
\l__groupthm_thmtools_clist
|
||||
\l_tmpa_clist
|
||||
}
|
||||
}
|
||||
\__groupthm_wrap_multiple_document:nnnn
|
||||
{ new, provide }
|
||||
{ \__groupthm_Declarator: GroupedTheoremFamily }
|
||||
|
@ -693,6 +705,8 @@
|
|||
}
|
||||
}
|
||||
\cs_new:Npn \groupthm_add_theorem_to_group:n #1
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\bool_if:NTF \l__groupthm_in_family_options_environment_bool
|
||||
{
|
||||
|
@ -702,13 +716,11 @@
|
|||
\msg_error:nn { groupthm } { misuse ~ add ~ theorem ~ to ~ group }
|
||||
}
|
||||
}
|
||||
}
|
||||
\NewDocumentCommand { \AddTheoremToGroup } { m }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\groupthm_add_theorem_to_group:n { #1 }
|
||||
}
|
||||
}
|
||||
\cs_new:Npn \__groupthm_define_family_options:nnnn #1 #2 #3 #4
|
||||
{
|
||||
\DeclareDocumentEnvironment
|
||||
|
@ -740,6 +752,10 @@
|
|||
\__groupthm_sort_group_names:
|
||||
\end { __#1__groups_ \clist_use:Nn \l__groupthm_group_clist { _ } }
|
||||
}
|
||||
\__groupthm_cache_slow:n
|
||||
{
|
||||
\csname __groupthm_define_family_options:nnnn \endcsname { #1 } { #2 } { #3 } { #4 }
|
||||
}
|
||||
}
|
||||
\__groupthm_define_multiple:nnnNNnn
|
||||
{ new, renew, provide, declare }
|
||||
|
@ -757,6 +773,8 @@
|
|||
{ new, renew, provide, declare }
|
||||
{ \__groupthm_Declarator: GroupedTheoremFamilyOptions }
|
||||
{ s O{} m m m }
|
||||
{
|
||||
\__groupthm_lazy:n
|
||||
{
|
||||
\keys_set:nn { groupthm / theorem ~ family ~ options } { starred ~ version }
|
||||
\keys_set:nn { groupthm / theorem ~ family ~ options } { ##2 }
|
||||
|
@ -784,61 +802,110 @@
|
|||
\l_tmpa_clist
|
||||
}
|
||||
}
|
||||
\cs_new:Npn \__groupthm_lazy:n
|
||||
{
|
||||
}
|
||||
\bool_if:NTF \g__groupthm_cache_bool
|
||||
{
|
||||
\hook_gput_code:nnn {__groupthm/definelazy} { groupthm }
|
||||
\cs_new:Npn \__groupthm_write_auxout:n
|
||||
{
|
||||
\iow_now:cn { @auxout }
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_write_auxout:n { x }
|
||||
\cs_new:Npn \__groupthm_dump_auxfile:n
|
||||
{
|
||||
\clist_gput_right:Nn \g__groupthm_dump_auxfile_clist
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_dump_auxfile:n { x }
|
||||
|
||||
\cs_new:Npn \__groupthm_cache_auxfile:n
|
||||
{
|
||||
\clist_gput_right:Nn \g__groupthm_dump_cache_clist
|
||||
}
|
||||
\cs_generate_variant:Nn \__groupthm_cache_auxfile:n { V }
|
||||
|
||||
\hook_gput_code:nnn { enddocument } { groupthm }
|
||||
{
|
||||
\__groupthm_benchmark_once:nn
|
||||
{
|
||||
Benchmarking ~ writing ~ to ~ auxfile:
|
||||
}
|
||||
{
|
||||
\use:n
|
||||
\clist_map_function:NN \g__groupthm_dump_auxfile_clist
|
||||
\__groupthm_write_auxout:n
|
||||
\__groupthm_write_auxout:n
|
||||
{
|
||||
\csname tl_gput_right:cn \endcsname
|
||||
{
|
||||
g__groupthm_lazy_auxfile_tl
|
||||
}
|
||||
}
|
||||
\__groupthm_write_auxout:x { \str_use:N \c_left_brace_str }
|
||||
\clist_map_function:NN \g__groupthm_dump_cache_clist
|
||||
\__groupthm_write_auxout:n
|
||||
\__groupthm_write_auxout:x { \str_use:N \c_right_brace_str }
|
||||
}
|
||||
}
|
||||
|
||||
\__groupthm_dump_auxfile:x
|
||||
{
|
||||
\ExplSyntaxOn
|
||||
\int_gset:Nn \exp_not:N \g__groupthm_cache_version_aux_int
|
||||
{
|
||||
\int_use:N \g__groupthm_cache_version_document_int
|
||||
}
|
||||
\ExplSyntaxOff
|
||||
}
|
||||
\cs_new:Npn \__groupthm_lazy:n
|
||||
{
|
||||
\tl_gput_right:Nn \g__groupthm_lazy_document_tl
|
||||
}
|
||||
\cs_set_eq:NN \__groupthm_cache:n \__groupthm_cache_auxfile:n
|
||||
\cs_new:Npn \__groupthm_cache_slow:n #1
|
||||
{
|
||||
\tl_set:Nn \l_tmpa_tl
|
||||
{
|
||||
{ #1 }
|
||||
}
|
||||
\regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl
|
||||
\__groupthm_cache_auxfile:V \l_tmpa_tl
|
||||
}
|
||||
\hook_gput_code:nnn { begindocument } { groupthm }
|
||||
{
|
||||
\bool_if:nT
|
||||
{
|
||||
\g__groupthm_cache_bool
|
||||
&&
|
||||
\int_compare_p:n
|
||||
{
|
||||
\cs_set_eq:NN \__groupthm_lazy:n \use:n
|
||||
\int_compare:nNnTF
|
||||
\g__groupthm_cache_version_aux_int < \g__groupthm_cache_version_document_int
|
||||
{
|
||||
\__groupthm_benchmark_once:nn
|
||||
{
|
||||
Benchmarking ~ declarations ~ of ~ theorems ~ from ~ document:
|
||||
}
|
||||
{
|
||||
\tl_use:N \g__groupthm_lazy_document_tl
|
||||
}
|
||||
}
|
||||
{
|
||||
\hook_use_once:n { __groupthm / define lazy }
|
||||
\__groupthm_benchmark_once:nn
|
||||
{
|
||||
Benchmarking ~ declarations ~ of ~ theorems ~ from ~ aux ~ file:
|
||||
}
|
||||
{
|
||||
\tl_use:N \g__groupthm_lazy_auxfile_tl
|
||||
}
|
||||
}
|
||||
\hook_gput_code:nnn { enddocument / afterlastpage } { before-groupthm }
|
||||
{
|
||||
\cs_set_eq:NN \__groupthm_thmtools_declare_theorem:nn \use_none:nn
|
||||
\iow_now:cx { @auxout }
|
||||
{
|
||||
\token_to_str:N \ExplSyntaxOn
|
||||
\int_gset:Nn \g__groupthm_cache_version_aux_int
|
||||
{ \int_use:N \g__groupthm_cache_version_document_int }
|
||||
}
|
||||
\iow_now:cn { @auxout }
|
||||
{
|
||||
\bool_if:nT
|
||||
{
|
||||
\g__groupthm_cache_bool
|
||||
&&
|
||||
\int_compare_p:n
|
||||
{
|
||||
\g__groupthm_cache_version_aux_int < \g__groupthm_cache_version_document_int
|
||||
}
|
||||
}
|
||||
{
|
||||
\cs_set_eq:NN \__groupthm_thmtools_declare_theorem:nn \use_none:nn
|
||||
\cs_set_eq:NN \__groupthm_cache:n \use_none:n
|
||||
\cs_set_eq:NN \__groupthm_lazy:n \use:n
|
||||
}
|
||||
}
|
||||
\iow_now:cx { @auxout }
|
||||
\groupthm_new_group:nnnnn { all } { } { } { } { }
|
||||
\groupthm_new_group:nnnnn { starred } { } { } { } { numbered = no }
|
||||
\groupthm_new_group:nnnnn { unnumbered } { } { } { } { numbered = no }
|
||||
\cs_new:Npn \__groupthm_benchmark_once:nn #1
|
||||
{
|
||||
\token_to_str:N \ExplSyntaxOff
|
||||
\iow_term:n { [groupthm] ~ #1 }
|
||||
\iow_log:n { [groupthm] ~ #1 }
|
||||
\benchmark_once:n
|
||||
}
|
||||
}
|
||||
\hook_gset_rule:nnnn { enddocument / afterlastpage } { before-groupthm } { before } { groupthm }
|
||||
\endinput
|
||||
%%
|
||||
%% End of file `groupthm.sty'.
|
||||
|
|
198
wip/cache/mkessler-cache.sty
vendored
Normal file
198
wip/cache/mkessler-cache.sty
vendored
Normal file
|
@ -0,0 +1,198 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Copyright © 2022 Maximilian Keßler
|
||||
%
|
||||
% This work may be distributed and/or modified
|
||||
%
|
||||
% 1. under the LaTeX Project Public License and/or
|
||||
% 2. under the GNU General Public License
|
||||
%
|
||||
% Distribution under conditions of the LaTeX Project Public License,
|
||||
% requires either version 1.3 of this license or (at your option)
|
||||
% any later version.
|
||||
% The latest version of this license is in
|
||||
% http://www.latex-project.org/lppl.txt
|
||||
% and version 1.3 or later is part of all distributions of LaTeX
|
||||
% version 2005/12/01 or later.
|
||||
%
|
||||
% This work has the LPPL maintenance status \`maintained'.
|
||||
%
|
||||
% The Current Maintainer of this work is Maximilian Keßler.
|
||||
%
|
||||
%
|
||||
% Distribution under the GNU General Public License requires either
|
||||
% version 3 or (at your opinion) any later version.
|
||||
%
|
||||
% This package has been generated by PyTeX, available at
|
||||
% https://github.com/kesslermaximilian/PyTeX
|
||||
% and built from source file 'cache.pysty3'.
|
||||
% It is STRONGLY DISCOURAGED to edit this source file directly, since local
|
||||
% changes will not be versioned by Git and overwritten by the next build. Always
|
||||
% edit the source file and build the package again.
|
||||
%
|
||||
% Build details:
|
||||
% PyTeX version: v1.2.0-31-gc9bb0e8 (commit c9bb0e8)
|
||||
% Source code version: v2.8.2 (commit b15dedb)
|
||||
%
|
||||
% This LaTeX package is free software and is dual-licensed
|
||||
% under the LPPLv1.3c and the GPLv3 licenses.
|
||||
% You may use it freely for your purposes.
|
||||
% The latest version of the package sources can be obtained
|
||||
% via GitLab under
|
||||
% https://gitlab.com/latexci/packages/LatexPackages
|
||||
% The latest version of the built packages can be obtained via GitLab under
|
||||
% https://gitlab.com/latexci/packages/LatexPackagesBuild
|
||||
% For further information see the urls above.
|
||||
% Reportings of bugs, suggestions and improvements are welcome, see the README
|
||||
% at the Git repository for further information.
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\ProvidesExplPackage{mkessler-cache}{2022/02/03}{2.8.2}{Cache definitions of previous LaTeX runs to avoid computations}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%%%% This is just a proof of concept package,
|
||||
%%%% there is possibly more room for clean-up
|
||||
%%%% and / or speed-up etc.
|
||||
|
||||
%%% Also, the provided
|
||||
%%% \DeclareCachedDocumentCommand
|
||||
%%% is of course not really
|
||||
%%% useful and just for demonstration
|
||||
%%% purposes
|
||||
|
||||
\bool_new:N \g__cache_cache_bool
|
||||
\int_new:N \g__cache_cache_version_document_int
|
||||
\int_new:N \g__cache_cache_version_aux_int
|
||||
\int_gset:Nn \g__cache_cache_version_aux_int { -1 }
|
||||
|
||||
\clist_new:N \g__cache_dump_auxfile_clist %% usual dump
|
||||
\clist_new:N \g__cache_dump_cache_clist %% will be dumped such that it is restored as \g__cache_lazy_auxfile_tl on next run.
|
||||
\tl_new:N \g__cache_lazy_document_tl
|
||||
\tl_new:N \g__cache_lazy_auxfile_tl
|
||||
|
||||
\keys_define:nn { cache }
|
||||
{
|
||||
cache .bool_set:N = \g__cache_cache_bool,
|
||||
cache .default:n = { true },
|
||||
__cache version__ .int_set:N = \g__cache_cache_version_document_int,
|
||||
cache version .meta:nn = { cache } { cache = true, __cache version__ = #1 },
|
||||
cache version .default:n = { 0 },
|
||||
}
|
||||
\RequirePackage{l3keys2e}
|
||||
\ProcessKeysOptions{cache}
|
||||
|
||||
|
||||
% Setting up lazy execution and
|
||||
% selecting of executing after reading of aux file
|
||||
% if cache option has been used
|
||||
\bool_if:NTF \g__cache_cache_bool
|
||||
{
|
||||
%% Writing things (at one go) to aux file at end of document:
|
||||
\cs_new:Npn \__cache_dump_auxfile:n
|
||||
{
|
||||
\clist_gput_right:Nn \g__cache_dump_auxfile_clist
|
||||
}
|
||||
\cs_generate_variant:Nn \__cache_dump_auxfile:n { x }
|
||||
|
||||
\cs_new:Npn \__cache_dump_cache:n
|
||||
{
|
||||
\clist_gput_right:Nn \g__cache_dump_cache_clist
|
||||
}
|
||||
\cs_generate_variant:Nn \__cache_dump_cache:n { V }
|
||||
|
||||
|
||||
\cs_new:Npn \__cache_write_auxout:n
|
||||
{
|
||||
\iow_now:cn { @auxout }
|
||||
}
|
||||
\cs_generate_variant:Nn \__cache_write_auxout:n { x }
|
||||
|
||||
%%% Handles dumping data to aux file at end of document
|
||||
\hook_gput_code:nnn { enddocument } { cache }
|
||||
{
|
||||
\clist_map_function:NN \g__cache_dump_auxfile_clist
|
||||
\__cache_write_auxout:n
|
||||
|
||||
\__cache_write_auxout:n
|
||||
{
|
||||
\csname tl_gput_right:cn \endcsname
|
||||
{
|
||||
g__cache_lazy_auxfile_tl
|
||||
}
|
||||
}
|
||||
\__cache_write_auxout:x { \str_use:N \c_left_brace_str }
|
||||
|
||||
\clist_map_function:NN \g__cache_dump_cache_clist
|
||||
\__cache_write_auxout:n
|
||||
|
||||
\__cache_write_auxout:x { \str_use:N \c_right_brace_str }
|
||||
}
|
||||
|
||||
%%% Writes the current cache version into aux file
|
||||
\__cache_dump_auxfile:x
|
||||
{
|
||||
\ExplSyntaxOn
|
||||
\int_gset:Nn \exp_not:N \g__cache_cache_version_aux_int
|
||||
{
|
||||
\int_use:N \g__cache_cache_version_document_int
|
||||
}
|
||||
\ExplSyntaxOff
|
||||
}
|
||||
|
||||
%%% Executing something lazily at beginning of document
|
||||
%%% Lazy code only gets executed if auxfile version is older than document
|
||||
\cs_new:Npn \__cache_lazy:n
|
||||
{
|
||||
\tl_gput_right:Nn \g__cache_lazy_document_tl
|
||||
}
|
||||
|
||||
%%% Caching things. Handles writing and reading to aux file
|
||||
%%% and makes code available in the next run of LaTeX
|
||||
\cs_new:Npn \__cache_cache:n #1
|
||||
{
|
||||
\tl_set:Nn \l_tmpa_tl
|
||||
{
|
||||
{ #1 }
|
||||
}
|
||||
\regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl
|
||||
\__cache_dump_cache:V \l_tmpa_tl
|
||||
}
|
||||
|
||||
%%% This handles loading either the cached definitions
|
||||
%%% from last run or executing the lazy definitions from the current run
|
||||
%%% after loading the aux file
|
||||
\hook_gput_code:nnn { begindocument } { cache }
|
||||
{
|
||||
\int_compare:nNnTF
|
||||
\g__cache_cache_version_aux_int < \g__cache_cache_version_document_int
|
||||
{
|
||||
\tl_use:N \g__cache_lazy_document_tl
|
||||
}
|
||||
{
|
||||
\tl_use:N \g__cache_lazy_auxfile_tl
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
\cs_set_eq:NN \__cache_lazy:n \use:n
|
||||
\cs_set_eq:NN \__cache_cache:n \use_none:n
|
||||
}
|
||||
|
||||
\cs_new:Npn \__cached_new_document_command:nnn #1 #2 #3
|
||||
{
|
||||
\NewDocumentCommand{#1}{#2}{#3}
|
||||
\__cache_cache:n
|
||||
{
|
||||
\csname __cached_new_document_command:nnn \endcsname { #1 } { #2 } { #3 }
|
||||
}
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\DeclareCachedDocumentCommand}{mmm}
|
||||
{
|
||||
\__cache_lazy:n
|
||||
{
|
||||
\__cached_new_document_command:nnn{#1}{#2}{#3}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue