Debian Codegraph @

texmf-dist/source/latex/memoize-ext/memoize-ext-l3draw.dtx

raw
1 % \iffalse meta-comment
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % memoize-ext.dtx
4 % Additions and changes Copyright (C) 2024-2026 Clea F. Rees.
5 % Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below).
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.3c
9 % of this license or (at your option) any later version.
10 % The latest version of this license is in
11 % https://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2008-05-04 or later.
14 %
15 % This work has the LPPL maintenance status 'muaintained'.
16 %
17 % The Current Maintainer of this work is Clea F. Rees.
18 %
19 % This work consists of all files listed in manifest.txt.
20 %
21 % The file memoize-ext.dtx is a derived work under the terms of the
22 % LPPL. It is based on version 2.4 of skeleton.dtx which is part of
23 % dtxtut by Scott Pakin. A copy of dtxtut, including the
24 % unmodified version of skeleton.dtx is available from
25 % https://www.ctan.org/pkg/dtxtut and released under the LPPL.
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 % \fi
28 %
29 % \iffalse
30 %<*driver>
31 \GetIdInfo $Id: memoize-ext-l3draw.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
32 \ProvidesExplFile{\ExplFileName}{\ExplFileDate}{v0.3.5 \ExplFileVersion}{\ExplFileDescription}
33 \begin{document}
34 \let\MakePrivateLetters\MyMakePrivateLetters
35 \DocInput{\filename}
36 \end{document}
37 %</driver>
38 % \fi
39 %
40 % \title{\ExplFileName}
41 % \date{\ExplFileVersion~\ExplFileDate}
42 % \maketitle
43 %
44 % \begin{abstract}
45 % \noindent Support for auto-memoization of content created with \pkg{l3draw} \autocite{latex-project-l3draw}.
46 % \pkg{memoize-ext-l3draw} is part of \pkg{memoize-ext}.
47 % \end{abstract}
48 %
49 % \tableofcontents
50 %
51 %
52 % \MaybeStop{%
53 % \PrintChanges
54 % \PrintIndex
55 % }
56 %
57 % ^^A \section{Implementation}
58 %
59 %<*sty>
60 %<@@=mmzx>
61 % \begin{macrocode}
62 \GetIdInfo $Id: memoize-ext-l3draw.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
63 %<!debug> \ProvidesExplPackage{\ExplFileName}{\ExplFileDate}
64 %<!debug> {v0.3.5 \ExplFileVersion}{\ExplFileDescription}
65 %<debug> \ProvidesExplPackage{\ExplFileName-debug}{\ExplFileDate}
66 %<debug> {v0.3.5 \ExplFileVersion}{\ExplFileDescription}
67 %
68 %<!debug> \disable@package@load {memoize-ext-l3draw-debug}
69 %<debug> \disable@package@load {memoize-ext-l3draw}
70 { Only~one~of~memoize-ext-l3draw~and~memoize-ext-l3draw-debug~
71 should~be~loaded.
72 Since~
73 %<!debug> memoize-ext-l3draw
74 %<debug> memoize-ext-l3draw-debug
75 ~has~been~loaded,~I~will~ignore~your~request~for~
76 %<debug> memoize-ext-l3draw
77 %<!debug> memoize-ext-l3draw-debug
78 .}
79 %
80 %<!debug> \RequirePackage{memoize-ext}
81 %<debug> \RequirePackage{memoize-ext-debug}
82 %<!debug> \RequirePackage{memoize-ext-expl3}
83 %<debug> \RequirePackage{memoize-ext-expl3-debug}
84 % \end{macrocode}
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % l3draw
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 %
89 % \begin{var}{\g_@@_draw_id_begin_int}
90 % \changes{v0.3.4}{2026-03-15}{Save and compare \pkg{l3draw} id.}
91 % Temporary \texttt{int}.
92 % \begin{macrocode}
93 \int_new:N \g_@@_draw_id_begin_int
94 % \end{macrocode}
95 % \end{var}
96 % \begin{fn}{\@@_advice_collect_draw_args:w}
97 % The \pkg{l3draw} picture environment is essentially a function with a weird argument specification, so we use a custom collector.
98 % \begin{macrocode}
99 \cs_new:Npn \@@_advice_collect_draw_args:w #1 \draw_end:
100 {
101 \toks0={ #1 \draw_end: }
102 \exp_args:No \AdviceInnerHandler {\the\toks0}
103 }
104 % \end{macrocode}
105 % \end{fn}
106 % \begin{macro}{\AdviceCollectDrawArguments}
107 % Public wrapper.
108 % \begin{macrocode}
109 \cs_new:Npn \AdviceCollectDrawArguments{
110 \toks0 = {}
111 \@@_advice_collect_draw_args:w
112 }
113 % \end{macrocode}
114 % \end{macro}
115 % \changes{v0.3.4}{2026-03-17}{Hopefully slightly saner code for incrementing \pkg{l3draw} id.}
116 % Default configuration.
117 % \changes{v0.3.4}{2026-03-15}{Replicate changes to \pkg{l3draw}'s id.}
118 % This replicates changes to \verb|\g_draw_id_int|, but does so by executing code at the start and end of \emph{every} memoization.
119 % There must be a more efficient way to do do this \dots.
120 % \begin{macrocode}
121 \mmzset{%
122 gincr~draw~id/.style={
123 at~begin~memoization={
124 \gtoksapp\mmzCCMemo
125 {
126 \UseName{int_gincr:c} {g_draw_id_int}
127 }
128 },
129 },
130 auto~csname={draw_begin:}{memoize,collector=\AdviceCollectDrawArguments,gincr~draw~id,},
131 auto~csname={__draw_record_origin:}{run~if~memoizing,replicate~expl~fn,},
132 }
133 % \end{macrocode}
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135 %</sty>
136 %
137 %\Finale
138 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 %^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: