summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-18 19:59:51 +0000
committerKarl Berry <karl@freefriends.org>2024-03-18 19:59:51 +0000
commit766a17b21b04d06ba7a41899213bced74b62cc52 (patch)
tree1c3c1f2b3ebbc54d31ff49f124041bb1aa7cceca /Master/texmf-dist/source
parent5e8d8cae840358328c7e78b0dbde730a00729679 (diff)
memoize (18mar24)
git-svn-id: svn://tug.org/texlive/trunk@70690 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/generic/memoize/Makefile7
-rw-r--r--Master/texmf-dist/source/generic/memoize/memoize.edtx471
-rw-r--r--Master/texmf-dist/source/generic/memoize/memoize.ins1
3 files changed, 348 insertions, 131 deletions
diff --git a/Master/texmf-dist/source/generic/memoize/Makefile b/Master/texmf-dist/source/generic/memoize/Makefile
index b459a5fdfa4..12737f4c7f3 100644
--- a/Master/texmf-dist/source/generic/memoize/Makefile
+++ b/Master/texmf-dist/source/generic/memoize/Makefile
@@ -10,16 +10,17 @@ all: ctan/memoize.zip
# Prepare the CTAN submission.
PACKAGE = memoize
-VERSION = 1.1.2
+VERSION = 1.2.0
YEAR = 2024
-MONTH = 01
-DAY = 21
+MONTH = 03
+DAY = 15
FORMAT = generic
COMMON = memoize nomemoize memoizable
PLAIN = memoize-extract-one.tex
GENERIC = memoizable.code.tex
+LATEX = memoize-biblatex.code.tex
SOURCE = memoize.edtx memoize.ins
SCRIPTS := memoize-extract memoize-clean
diff --git a/Master/texmf-dist/source/generic/memoize/memoize.edtx b/Master/texmf-dist/source/generic/memoize/memoize.edtx
index c14b59ae4e2..e77be9a39ff 100644
--- a/Master/texmf-dist/source/generic/memoize/memoize.edtx
+++ b/Master/texmf-dist/source/generic/memoize/memoize.edtx
@@ -64,7 +64,7 @@
% listing options app={basicstyle=\ttfamily\scriptsize}}}
%
% \begin{tcbraster}[raster columns=100]
-% \tcbinputlisting{raster multicolumn=55, ins listing, top=1mm, bottom=1mm, title=memoize.ins,listing file=../memoize.ins, linerange={27-39}, leftupper=1mm}
+% \tcbinputlisting{raster multicolumn=55, ins listing, top=1mm, bottom=1mm, title=memoize.ins,listing file=../memoize.ins, linerange={27-40}, leftupper=1mm}
% \begin{tcboxedraster}[raster columns=1]{blankest, raster multicolumn=45}
% \tcbinputlisting{ins listing, title=advice.ins, listing file=../advice.ins, linerange=28-31}
% \tcbinputlisting{ins listing, title=collar\raisebox{0pt}[\height][0pt]{g}s.ins, listing file=../collargs.ins, linerange=29-31}
@@ -90,55 +90,55 @@
%
% \paragraph{Identification} of |memoize|, |memoizable| and |nomemoize|.
%<*mmz>
-%<latex>\ProvidesPackage{memoize}[2024/01/21 v1.1.2 Fast and flexible externalization]
+%<latex>\ProvidesPackage{memoize}[2024/03/15 v1.2.0 Fast and flexible externalization]
%<context>%D \module[
%<context>%D file=t-memoize.tex,
-%<context>%D version=1.1.2,
+%<context>%D version=1.2.0,
%<context>%D title=Memoize,
%<context>%D subtitle=Fast and flexible externalization,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2024-01-21,
+%<context>%D date=2024-03-15,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
%<context>\writestatus{loading}{ConTeXt User Module / memoize}
%<context>\unprotect
%<context>\startmodule[memoize]
-%<plain>% Package memoize 2024/01/21 v1.1.2
+%<plain>% Package memoize 2024/03/15 v1.2.0
%</mmz>
%<*mmzable>
-%<latex>\ProvidesPackage{memoizable}[2024/01/21 v1.1.2 A programmer's stub for Memoize]
+%<latex>\ProvidesPackage{memoizable}[2024/03/15 v1.2.0 A programmer's stub for Memoize]
%<context>%D \module[
%<context>%D file=t-memoizable.tex,
-%<context>%D version=1.1.2,
+%<context>%D version=1.2.0,
%<context>%D title=Memoizable,
%<context>%D subtitle=A programmer's stub for Memoize,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2024-01-21,
+%<context>%D date=2024-03-15,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
%<context>\writestatus{loading}{ConTeXt User Module / memoizable}
%<context>\unprotect
%<context>\startmodule[memoizable]
-%<plain>% Package memoizable 2024/01/21 v1.1.2
+%<plain>% Package memoizable 2024/03/15 v1.2.0
%</mmzable>
%<*nommz>
-%<latex>\ProvidesPackage{nomemoize}[2024/01/21 v1.1.2 A no-op stub for Memoize]
+%<latex>\ProvidesPackage{nomemoize}[2024/03/15 v1.2.0 A no-op stub for Memoize]
%<context>%D \module[
%<context>%D file=t-nomemoize.tex,
-%<context>%D version=1.1.2,
+%<context>%D version=1.2.0,
%<context>%D title=Memoize,
%<context>%D subtitle=A no-op stub for Memoize,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2024-01-21,
+%<context>%D date=2024-03-15,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
%<context>\writestatus{loading}{ConTeXt User Module / nomemoize}
%<context>\unprotect
%<context>\startmodule[nomemoize]
-%<mmz>% Package nomemoize 2024/01/21 v1.1.2
+%<mmz>% Package nomemoize 2024/03/15 v1.2.0
%</nommz>
%
% \paragraph{Required packages} and \hologo{LaTeX}ization of \hologo{plainTeX}
@@ -361,7 +361,7 @@
% Read \hologo{TeX} file |#2| into token register |#1| (under the current
% category code regime); |\toksapp| is defined in CollArgs.
\def\filetotoks#1#2{%
- \immediate\mmz@openin0{#2}%
+ \immediate\openin0{#2}%
#1={}%
\loop
\unless\ifeof0
@@ -373,12 +373,6 @@
}
% \end{macro}
%
-% \begin{macro}{\mmz@openin,\mmz@openout}
-% A workaround for |morewrites|.
-\let\mmz@openin\openin
-\let\mmz@openout\openout
-% \end{macro}
-%
% \paragraph{Other} little things.
\newif\ifmmz@temp
\newtoks\mmz@temptoks
@@ -583,9 +577,9 @@
}
\def\mmz@remove@quotes@i{%
\CollectArgumentsRaw
- {\collargsBraceCollectedfalse
+ {\collargsReturnPlain
\collargsNoDelimiterstrue
- \collargsAppendPostwrap{{##1}}%
+ \collargsAppendExpandablePostprocessor{{\the\collargsArg}}%
}%
{u"u\mmz@eov}%
\mmz@remove@quotes@ii
@@ -783,11 +777,11 @@
}%
% Spaces at the beginning of the environment body are trimmed by setting
% the first argument to |!t<space>| and disappearing it with
- % |\collargsAppendPostwrap{}|; note that this removes any number of space
+ % |\collargsAppendExpandablePostprocessor{}|; note that this removes any number of space
% tokens. |\CollectArgumentsRaw| automatically adapts the argument type
% |b| to the format.
%
- }{&&{\collargsAppendPostwrap{}}!t{ }+b{memoize}}{\mmz@do}%
+ }{&&{\collargsAppendExpandablePostprocessor{}}!t{ }+b{memoize}}{\mmz@do}%
}%
%</mmz>
% \end{environment}
@@ -1562,7 +1556,7 @@
% |\mmzCMemo|.
\def\mmz@write@cmemo{%
% Open the file for writing.
- \immediate\mmz@openout\mmz@out{\mmz@cmemo@path}%
+ \immediate\openout\mmz@out{\mmz@cmemo@path}%
% The memo starts with the |\mmzMemo| marker (a signal that the memo is valid).
\immediate\write\mmz@out{\noexpand\mmzMemo}%
% We store the content of |\mmzContextExtra| by writing out a command that
@@ -1714,7 +1708,7 @@
% memoized code can update the context. This is one of the two reasons why
% we couldn't write the cc-memo directly into the file, but had to collect
% its contents into token register |\mmzCCMemo|.
- \immediate\mmz@openout\mmz@out{\mmz@ccmemo@path}%
+ \immediate\openout\mmz@out{\mmz@ccmemo@path}%
% Token register |\mmz@ccmemo@resources| consists of calls to
% |\mmz@ccmemo@append@resource|, so the following code writes down the list
% of created externs into the cc-memo. Wanting to have this list at the top
@@ -2428,7 +2422,7 @@
% the external scripts).
\def\mmz@clear@extraction@log{%
\begingroup
- \immediate\mmz@openout0{\jobname.mmz.log}%
+ \immediate\openout0{\jobname.mmz.log}%
\immediate\closeout0
\endgroup
}
@@ -2544,7 +2538,7 @@
% location (the current directory, i.e.\ the directory where \hologo{TeX}
% is executed from; usually, this will be the directory containing the
% \hologo{TeX} source).
- \immediate\mmz@openout\mmz@mmzout{\jobname.mmz}%
+ \immediate\openout\mmz@mmzout{\jobname.mmz}%
},
% The |\mmzPrefix| is used by the clean-up script, which will remove all
% files with the given path prefix but (unless called with |--all|) those
@@ -2567,6 +2561,8 @@
\immediate\write\mmz@mmzout{%
\noexpand\mmzNewExtern{#1}{\pagenumber}{\expectedwidth}{\expectedheight}%
}%
+ % Support |latexmk|:
+ %<latex>\typeout{No file #1}%
},
record/mmz/new cmemo/.code={%
\immediate\write\mmz@mmzout{\noexpand\mmzNewCMemo{#1}}%
@@ -2607,7 +2603,7 @@
% \begin{key}{record/sh/...} Define the Linux shell script record type.
record/sh/begin/.code={%
\newwrite\mmz@shout
- \immediate\mmz@openout\mmz@shout{\mmz@shname}%
+ \immediate\openout\mmz@shout{\mmz@shname}%
},
record/sh/new extern/.code={%
\begingroup
@@ -2626,7 +2622,7 @@
% Rinse and repeat for Windows.
record/bat/begin/.code={%
\newwrite\mmz@batout
- \immediate\mmz@openout\mmz@batout{\mmz@batname}%
+ \immediate\openout\mmz@batout{\mmz@batname}%
},
record/bat/new extern/.code={%
\begingroup
@@ -2664,7 +2660,7 @@
% variables |.DEFAULT_GOAL| and |.PHONY|.
\newwrite\mmz@makefileout
\newtoks\mmz@makefile@externs
- \immediate\mmz@openout\mmz@makefileout{\mmz@makefilename}%
+ \immediate\openout\mmz@makefileout{\mmz@makefilename}%
\immediate\write\mmz@makefileout{.DEFAULT_GOAL = externs}%
\immediate\write\mmz@makefileout{.PHONY: externs}%
},
@@ -3401,6 +3397,57 @@
outer handler=\global\advance\mmzExtraPages1\relax\AdviceOriginal}}
%</latex>
%
+% Utility macro for clarity below. |#1| is the name of the package which should
+% be loaded (used with \hologo{LaTeX}) and |#2| is the name of the command
+% which should be defined (used with \hologo{plainTeX} and \hologo{ConTeXt})
+% for |#3| to be executed at the beginning of the document. We make sure that
+% we can use |#1| etc.\ inside |#3|.
+\def\mmz@if@package@loaded#1#2#3{%
+ \mmzset{%
+ begindocument/before/.append code={%
+ %<latex>\@ifpackageloaded{#1}{%
+ %<plain,context>\ifdefined#2%
+ #3%
+ %<plain,context>\fi
+ %<latex>}{}%
+ }%
+ }%
+}
+%
+% \subsection{\pkg{PGF}}
+%
+\mmz@if@package@loaded{pgf}{%
+ %<plain>\pgfpicture
+ %<context>\startpgfpicture
+}{%
+ \def\mmzPgfAtBeginMemoization{%
+ \edef\mmz@pgfpictureid{%
+ \the\pgf@picture@serial@count
+ }%
+ }%
+ \def\mmzPgfAtEndMemoization{%
+ \edef\mmz@temp{%
+ \the\numexpr\pgf@picture@serial@count-\mmz@pgfpictureid\relax
+ }%
+ \ifx\mmz@temp=0
+ \else
+ \xtoksapp\mmzCCMemo{%
+ \unexpanded{%
+ \global\expandafter\advance\csname pgf@picture@serial@count\endcsname
+ }%
+ \mmz@temp
+ }%
+ \fi
+ }%
+ % \begin{listingregion}{_support-pgf.tex}
+ \mmzset{%
+ at begin memoization=\mmzPgfAtBeginMemoization,
+ at end memoization=\mmzPgfAtEndMemoization,
+ }%
+ % \end{listingregion}
+}
+%
+%
% \subsection{\TikZ;}
% \label{sec:code:mmz:tikz}
%
@@ -3408,32 +3455,16 @@
% Advice). All the action happens at the end of the preamble, so that we can
% detect whether \TikZ; was loaded (regardless of whether Memoize was loaded
% before \TikZ;, or vice versa), but still input the definitions.
-\mmzset{
- begindocument/before/.append code={%
- %<latex>\@ifpackageloaded{tikz}{%
- %<plain,context>\ifdefined\tikz
- \input advice-tikz.code.tex
- %<latex>}{}%
- %<plain,context>\fi
- % We define and activate the automemoization handlers for the \TikZ; command
- % and environment.
- \mmzset{%
- auto/memoize tikz/.style={
- memoize,
- at begin memoization=\edef\mmz@pgfpictureid{%
- \the\pgf@picture@serial@count
- },
- at end memoization=\xtoksapp\mmzCCMemo{%
- \unexpanded{%
- \global\expandafter\advance\csname pgf@picture@serial@count\endcsname
- }%
- \the\numexpr\pgf@picture@serial@count-\mmz@pgfpictureid\relax\relax
- },
- },
- auto=\tikz{memoize tikz, collector=\AdviceCollectTikZArguments},
- auto={tikzpicture}{memoize tikz},
- }%
- },
+\mmz@if@package@loaded{tikz}{\tikz}{%
+ \input advice-tikz.code.tex
+ % We define and activate the automemoization handlers for the \TikZ; command
+ % and environment.
+ % \begin{listingregion}{_support-tikz.tex}
+ \mmzset{%
+ auto={tikzpicture}{memoize},
+ auto=\tikz{memoize, collector=\AdviceCollectTikZArguments},
+ }%
+ % \end{listingregion}
}
%
%
@@ -3441,18 +3472,16 @@
% \label{sec:code:forest}
%
% Forest will soon feature extensive memoization support, but for now, let's
-% just enable the basic, single extern externalization.
+% just enable the basic, single extern externalization. Command |\Forest| is
+% defined using |xparse|, so |args| is unnecessary.
%<*latex>
-\mmzset{
- begindocument/before/.append code={%
- \@ifpackageloaded{forest}{%
- \mmzset{
- auto={forest}{memoize},
-% Yes, |\Forest| is defined using |xparse|.
- auto=\Forest{memoize},
- }%
- }{}%
- },
+\mmz@if@package@loaded{forest}{\Forest}{%
+ % \begin{listingregion}{_support-forest.tex}
+ \mmzset{
+ auto={forest}{memoize},
+ auto=\Forest{memoize},
+ }%
+ % \end{listingregion}
}
%</latex>
%
@@ -3502,69 +3531,176 @@
}{}}
%</latex>
%
-% \subsection{Morewrites}
-% \label{sec:code:morewrites}
-%
-% Use the old grammar for |\openin| and |\openout| as a temporary workaround.
-% |prefix|es containing spaces must be quoted manually.
-%<*latex>
-\AddToHook{begindocument/before}{%
- \@ifpackageloaded{morewrites}{%
- \def\mmz@openin#1#2{\openin#1=#2\relax}%
- \def\mmz@openout#1#2{\openout#1=#2\relax}%
- }{}%
-}
-%</latex>
-%
% \subsection{Biblatex}
% \label{sec:biblatex}
%
+%
%<*latex>
\mmzset{
- begindocument/before/.append style={%
- auto=\blx@bbl@entry{outer handler=\mmz@biblatex@entry},
- auto/cite/.style={run if memoizing, outer handler=\mmz@biblatex@cite},
- auto/cites/.style={run if memoizing, outer handler=\mmz@biblatex@cites},
- auto=\cite{cite},
- auto=\cites{cites},
- }%
+ biblatex/.code={%
+ \mmz@if@package@loaded{biblatex}{}{%
+ \input memoize-biblatex.code.tex
+ \mmzset{#1}%
+ }%
+ },
}
+%</latex>
+%</mmz>
+%<*biblatex>
+\edef\memoizeresetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}%
+\catcode`\@=11
+\mmzset{%
+ % Advise macro |\entry| occuring in |.bbl| files to collect the entry,
+ % verbatim. |args|: |m| = citation key, |&&{...}u| = the entry, verbatim,
+ % braced --- so |\blx@bbl@entry| will receive two mandatory arguments.
+ auto=\blx@bbl@entry{
+ inner handler=\mmz@biblatex@entry,
+ args={%
+ m%
+ &&{\collargsVerb
+ \collargsAppendExpandablePostprocessor{{\the\collargsArg}}%
+ }u{\endentry}%
+ },
+ % No braces around the collected arguments, as each is already braced on
+ % its own.
+ raw collector options=\collargsReturnPlain,
+ },
+ % \begin{mmzautokey}{cite,volcite,cites,volcites}
+ % Define handlers for citation commands.
+ auto/cite/.style={
+ run conditions=\mmz@biblatex@cite@rc,
+ outer handler=\mmz@biblatex@cite@outer,
+ args=l*m,
+ raw collector options=\mmz@biblatex@def@star\collargsReturnNo,
+ inner handler=\mmz@biblatex@cite@inner,
+ },
+ % We need a dedicated |volcite| even though |\volcite| executes |\cite|
+ % because otherwise, we would end up with |\cite{volume}{key}| in the cc-memo
+ % when |biblatex ccmemo cite=replicate|.
+ auto/volcite/.style={
+ run if memoizing,
+ outer handler=\mmz@biblatex@cite@outer,
+ args=lml*m,
+ raw collector options=\mmz@biblatex@def@star\collargsReturnNo,
+ inner handler=\mmz@biblatex@cite@inner,
+ },
+ auto/cites/.style={
+ run conditions=\mmz@biblatex@cite@rc,
+ outer handler=\mmz@biblatex@cites@outer,
+ args=l*m,
+ raw collector options=\mmz@biblatex@def@star\collargsClearArgsfalse\collargsReturnNo,
+ inner handler=\mmz@biblatex@cites@inner,
+ },
+ auto/volcites/.style={
+ run if memoizing,
+ outer handler=\mmz@biblatex@cites@outer,
+ args=lml*m,
+ raw collector options=\mmz@biblatex@def@star\collargsClearArgsfalse\collargsReturnNo,
+ inner handler=\mmz@biblatex@cites@inner,
+ },
+ % \end{mmzautokey}
+ % \begin{mmzautokey}{biblatex ccmemo cite}
+ % What to put into the cc-memo, |\nocite| or the handled citation command?
+ biblatex ccmemo cite/.is choice,
+ biblatex ccmemo cite/nocite/.code={%
+ \let\mmz@biblatex@do@ccmemo\mmz@biblatex@do@nocite
+ },
+ biblatex ccmemo cite/replicate/.code={%
+ \let\mmz@biblatex@do@ccmemo\mmz@biblatex@do@replicate
+ },
+ % \end{mmzautokey}
+}%
% \begin{macro}{\mmz@biblatex@entry}
% This macro stores the MD5 sum of the |\entry| when reading the |.bbl| file.
-\def\mmz@biblatex@entry#1#2\endentry{%
- \protected@edef\mmz@temp{\pdf@mdfivesum{#2}}%
+\def\mmz@biblatex@entry#1#2{%
+ \edef\mmz@temp{\pdf@mdfivesum{#2}}%
\global\cslet{mmz@bbl@#1}\mmz@temp
- \AdviceOriginal{#1}#2\endentry
+ \mmz@scantokens{\AdviceOriginal{#1}#2}%
}
% \end{macro}
-% \begin{macro}{\mmz@biblatex@cite}
-% This macro puts the cites reference keys into the context, and adds the
-% handled |\cite| command to the cc-memo.
-\def\mmz@biblatex@cite#1#{\mmz@biblatex@cite@i{#1}}
-\def\mmz@biblatex@cite@i#1#2{%
- \forcsvlist\mmz@biblatex@cite@do@key{#2}%
- \xtoksapp\mmzCCMemo{%
- \noexpand\setbox0\noexpand\hbox{%
- \expandonce\AdviceOriginal\unexpanded{#1}{#2}%
- }}%
- \AdviceOriginal#1{#2}%
+% \begin{macro}{\mmz@biblatex@cite@rc}
+% Run if memoizing but not within a |\volcite| command. Applied to |\cite(s)|.
+\def\mmz@biblatex@cite@rc{%
+ \ifmemoizing
+ % We cannot use the official |\ifvolcite|, or even the |blx@volcite| toggle
+ % it depends on, because these are defined\slash set within the
+ % next-citation hook, which is yet to be executed. So we depend on the
+ % internal detail that |\volcite| and friends redefine |\blx@citeargs| to
+ % |\blx@volciteargs|.
+ \ifx\blx@citeargs\blx@volciteargs
+ \else
+ \AdviceRuntrue
+ \fi
+ \fi
+}
+% \end{macro}
+% \begin{macro}{\mmz@biblatex@cite@outer}
+% Initialize the macro receiving the citation key(s), and execute the
+% collector.
+\def\mmz@biblatex@cite@outer{%
+ \gdef\mmz@biblatex@keys{}%
+ \AdviceCollector
+}
+% \end{macro}
+% \begin{macro}{\mmz@biblatex@mark@citation@key}
+% We \emph{append} to |\mmz@biblatex@keys| to automatically collect all
+% citation keys of a |\cites| command; note that we use this system for
+% |\cite| as well.
+\def\mmz@biblatex@def@star{%
+ \collargsAlias{*}{&&{\mmz@biblatex@mark@citation@key}}%
}
-\def\mmz@biblatex@cite@do@key#1{%
+\def\mmz@biblatex@mark@citation@key{%
+ \collargsAppendPreprocessor{\xappto\mmz@biblatex@keys{,\the\collargsArg}}%
+}
+% \end{macro}
+% \begin{macro}{\mmz@biblatex@cite@inner}
+\def\mmz@biblatex@cite@inner{%
+ % This macro puts the cites reference keys into the context, and adds
+ % |\nocite|, or the handled citation command, to the cc-memo.
+ \mmz@biblatex@do@context
+ \mmz@biblatex@do@ccmemo
+ \expandafter\AdviceOriginal\the\collargsArgs
+}
+\def\mmz@biblatex@do@context{%
+ \expandafter\forcsvlist
+ \expandafter\mmz@biblatex@do@context@one
+ \expandafter{\mmz@biblatex@keys}%
+}
+\def\mmz@biblatex@do@context@one#1{%
\mmz@mtoc@csname{mmz@bbl@#1}%
\ifcsdef{mmz@bbl@#1}{}{\mmzAbort}%
}
+\def\mmz@biblatex@do@nocite{%
+ \xtoksapp\mmzCCMemo{%
+ \noexpand\nocite{\mmz@biblatex@keys}%
+ }%
+}
+\def\mmz@biblatex@do@replicate{%
+ \xtoksapp\mmzCCMemo{%
+ {%
+ \nullfont
+ % It is ok to use |\AdviceName| here, as the cc-memo is never input
+ % during memoization.
+ \expandonce\AdviceName\the\collargsArgs
+ }%
+ }%
+}
+\let\mmz@biblatex@do@ccmemo\mmz@biblatex@do@nocite
% \end{macro}
-% \begin{macro}{\mmz@biblatex@cites}
-% This macro puts the cites reference keys into the context, and adds the
-% handled |\cites| command to the cc-memo.
-\def\mmz@biblatex@cites{%
- \mmz@temptoks{}%
- \mmz@biblatex@cites@i
+% \begin{macro}{\mmz@biblatex@cites@outer}
+% Same as for |cite|, but we iterate the collector as long as the arguments
+% continue.
+\def\mmz@biblatex@cites@outer{%
+ \global\collargsArgs{}%
+ \gdef\mmz@biblatex@keys{}%
+ \AdviceCollector
}
-\def\mmz@biblatex@cites@i{%
- \futurelet\mmz@temp\mmz@biblatex@cites@ii
+\def\mmz@biblatex@cites@inner{%
+ \futurelet\mmz@temp\mmz@biblatex@cites@inner@again
}
-\def\mmz@biblatex@cites@ii{%
+% If the following token is an opening brace or bracket, the
+% multicite arguments continue.
+\def\mmz@biblatex@cites@inner@again{%
\mmz@tempfalse
\ifx\mmz@temp\bgroup
\mmz@temptrue
@@ -3574,26 +3710,97 @@
\fi
\fi
\ifmmz@temp
- \expandafter\mmz@biblatex@cites@iii
+ \expandafter\AdviceCollector
\else
- \expandafter\mmz@biblatex@cites@z
+ \expandafter\mmz@biblatex@cites@inner@finish
\fi
}
-\def\mmz@biblatex@cites@iii#1#{\mmz@biblatex@cites@iv{#1}}
-\def\mmz@biblatex@cites@iv#1#2{%
- \forcsvlist\mmz@biblatex@cite@do@key{#2}%
- \toksapp\mmz@temptoks{#1{#2}}%
- \mmz@biblatex@cites@i
-}
-\def\mmz@biblatex@cites@z{%
- \xtoksapp\mmzCCMemo{%
- \noexpand\setbox0\noexpand\hbox{%
- \expandonce\AdviceOriginal\the\mmz@temptoks
- }}%
- \expandafter\AdviceOriginal\the\mmz@temptoks
+\def\mmz@biblatex@cites@inner@finish{%
+ \mmz@biblatex@do@context
+ \mmz@biblatex@do@ccmemo
+ \expandafter\AdviceOriginal\the\collargsArgs
}
-%</latex>
% \end{macro}
+%
+% \paragraph{Advise} the citation commands.
+\mmzset{
+ auto=\cite{cite},
+ auto=\Cite{cite},
+ auto=\parencite{cite},
+ auto=\Parencite{cite},
+ auto=\footcite{cite},
+ auto=\footcitetext{cite},
+ auto=\textcite{cite},
+ auto=\Textcite{cite},
+ auto=\smartcite{cite},
+ auto=\Smartcite{cite},
+ auto=\supercite{cite},
+ auto=\cites{cites},
+ auto=\Cites{cites},
+ auto=\parencites{cites},
+ auto=\Parencites{cites},
+ auto=\footcites{cites},
+ auto=\footcitetexts{cites},
+ auto=\smartcites{cites},
+ auto=\Smartcites{cites},
+ auto=\textcites{cites},
+ auto=\Textcites{cites},
+ auto=\supercites{cites},
+ auto=\autocite{cite},
+ auto=\Autocite{cite},
+ auto=\autocites{cites},
+ auto=\Autocites{cites},
+ auto=\citeauthor{cite},
+ auto=\Citeauthor{cite},
+ auto=\citetitle{cite},
+ auto=\citeyear{cite},
+ auto=\citedate{cite},
+ auto=\citeurl{cite},
+ auto=\nocite{cite},
+ auto=\fullcite{cite},
+ auto=\footfullcite{cite},
+ auto=\volcite{volcite},
+ auto=\Volcite{volcite},
+ auto=\volcites{volcites},
+ auto=\Volcites{volcites},
+ auto=\pvolcite{volcite},
+ auto=\Pvolcite{volcite},
+ auto=\pvolcites{volcites},
+ auto=\Pvolcites{volcites},
+ auto=\fvolcite{volcite},
+ auto=\Fvolcite{volcite},
+ auto=\fvolcites{volcites},
+ auto=\Fvolcites{volcites},
+ auto=\ftvolcite{volcite},
+ auto=\ftvolcites{volcites},
+ auto=\Ftvolcite{volcite},
+ auto=\Ftvolcites{volcites},
+ auto=\svolcite{volcite},
+ auto=\Svolcite{volcite},
+ auto=\svolcites{volcites},
+ auto=\Svolcites{volcites},
+ auto=\tvolcite{volcite},
+ auto=\Tvolcite{volcite},
+ auto=\tvolcites{volcites},
+ auto=\Tvolcites{volcites},
+ auto=\avolcite{volcite},
+ auto=\Avolcite{volcite},
+ auto=\avolcites{volcites},
+ auto=\Avolcites{volcites},
+ auto=\notecite{cite},
+ auto=\Notecite{cite},
+ auto=\pnotecite{cite},
+ auto=\Pnotecite{cite},
+ auto=\fnotecite{cite},
+ % Similar to |volcite|, these commands must be handled specifically in order
+ % to function correctly with |biblatex ccmemo cite=replicate|.
+ auto=\citename{cite, args=l*mlm},
+ auto=\citelist{cite, args=l*mlm},
+ auto=\citefield{cite, args=l*mlm},
+}
+\memoizeresetatcatcode
+%</biblatex>
+%<*mmz>
%
%
% \section{Initialization}
@@ -3627,6 +3834,14 @@
end document/.style={enddocument/afterlastpage},
}
%</plain,context>
+% We clear the hooks after executing the last of them.
+\mmzset{
+ begindocument/end/.append style={
+ begindocument/before/.code={},
+ begindocument/.code={},
+ begindocument/end/.code={},
+ }
+}
% \end{key}
%
% Formats other than \hologo{plainTeX} need a way to prevent extraction during
diff --git a/Master/texmf-dist/source/generic/memoize/memoize.ins b/Master/texmf-dist/source/generic/memoize/memoize.ins
index 2c24ac368b2..74b0bc1b3e6 100644
--- a/Master/texmf-dist/source/generic/memoize/memoize.ins
+++ b/Master/texmf-dist/source/generic/memoize/memoize.ins
@@ -36,5 +36,6 @@
\file{t-memoizable.tex}{\from{memoize.dtx}{mmzable,context}}%
\file{memoizable.code.tex}{\from{memoize.dtx}{mmzable,generic}}%
\file{memoize-extract-one.tex}{\from{memoize.dtx}{extract-one}}%
+ \file{memoize-biblatex.code.tex}{\from{memoize.dtx}{biblatex}}%
}
\endbatchfile