summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-03 21:18:16 +0000
committerKarl Berry <karl@freefriends.org>2024-01-03 21:18:16 +0000
commit353c0f08203d3cbe6012341e8e048755ed360bab (patch)
tree16a0610aa67af5709cf0ef581bf619e01f8dd428 /Master
parent4c36524528f5e6d3f25aae1756a00493d59a76c7 (diff)
advice (3jan24)
git-svn-id: svn://tug.org/texlive/trunk@69283 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/generic/advice/CHANGELOG.md9
-rw-r--r--Master/texmf-dist/source/generic/advice/advice.edtx129
-rw-r--r--Master/texmf-dist/tex/context/third/advice/t-advice.tex46
-rw-r--r--Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex40
-rw-r--r--Master/texmf-dist/tex/latex/advice/advice.sty47
-rw-r--r--Master/texmf-dist/tex/plain/advice/advice.tex42
6 files changed, 222 insertions, 91 deletions
diff --git a/Master/texmf-dist/doc/generic/advice/CHANGELOG.md b/Master/texmf-dist/doc/generic/advice/CHANGELOG.md
index 63de5163a9f..f112324840d 100644
--- a/Master/texmf-dist/doc/generic/advice/CHANGELOG.md
+++ b/Master/texmf-dist/doc/generic/advice/CHANGELOG.md
@@ -14,6 +14,15 @@ those cases, please see [Memoize's GitHub
repository](https://github.com/sasozivanovic/memoize) for the recent
development history.
+## 2024/01/02 v1.1.0
+* Implement `\AdviceCsnameGetOriginal`.
+* Change `\AdviceGetOriginal` to expand to the internal control sequence
+ holding the original definition of the advised command under full expansion.
+* Add the missing info messages for environment (de)activation.
+* Add the original command meaning to trace.
+
+Manual: Memoize 2024/01/02 v1.1.0
+
## 2023/10/25 v1.0.1
* Require package `xparse`, as `\GetDocumentCommandArgSpec` is being dropped
from the LaTeX kernel.
diff --git a/Master/texmf-dist/source/generic/advice/advice.edtx b/Master/texmf-dist/source/generic/advice/advice.edtx
index dcbdfb297e7..415d9da79bd 100644
--- a/Master/texmf-dist/source/generic/advice/advice.edtx
+++ b/Master/texmf-dist/source/generic/advice/advice.edtx
@@ -29,14 +29,14 @@
% \relax
%
%<*main>
-%<latex>\ProvidesPackage{advice}[2023/10/25 v1.0.1 Extend commands and environments]
+%<latex>\ProvidesPackage{advice}[2024/01/02 v1.1.0 Extend commands and environments]
%<context>%D \module[
%<context>%D file=t-advice.tex,
-%<context>%D version=1.0.1,
+%<context>%D version=1.1.0,
%<context>%D title=Advice,
%<context>%D subtitle=Extend commands and environments,
%<context>%D author=Saso Zivanovic,
-%<context>%D date=2023-10-25,
+%<context>%D date=2024-01-02,
%<context>%D copyright=Saso Zivanovic,
%<context>%D license=LPPL,
%<context>%D ]
@@ -96,7 +96,9 @@
% namespace is hard-coded into these keys via |#1|; their arguments are
% the command/environment (cs)name, and setup keys belonging to path
% \meta{installation keypath}|/\meta{setup key name}|.
+ % \indentmacrocode
#2/.code 2 args={%
+ % \noindentmacrocode
% Call the internal setup macro, wrapping the received keylist into a
% |pgfkeys| invocation.
\AdviceSetup{#1}{#2}{##1}{\pgfqkeys{#1/#2}{##2}}%
@@ -151,7 +153,7 @@
% defined right away, as they don't change with the type of activation
% (immediate vs.\ deferred).
activate csname/.style={activate/.expand once={\csname##1\endcsname}},
- deactivate csname/.style={activate/.expand once={\csname##1\endcsname}},
+ deactivate csname/.style={deactivate/.expand once={\csname##1\endcsname}},
% \end{key}
%
% \begin{key}{activate key, deactivate key}
@@ -178,7 +180,8 @@
% These keys are used to setup the handling of the command or
% environment. The storage macros (|\AdviceRunConditions| etc.) have
% public names as they also play a crucial role in the handler
- % definitions, see section~\ref{sec:code:advice:handle}. \indentmacrocode
+ % definitions, see section~\ref{sec:code:advice:handle}.
+ % \indentmacrocode[-0.5em]
run conditions/.store in=\AdviceRunConditions,
bailout handler/.store in=\AdviceBailoutHandler,
outer handler/.store in=\AdviceOuterHandler,
@@ -215,7 +218,7 @@
reset/.code={\csname\advice@setup@init@\AdviceType\endcsname},
% \end{mmzautokey}
%
- % \begin{mmzautokey}
+ % \begin{mmzautokey}{after setup}
% The code given here will be executed once we exit the setup group.
% |integrated driver| of Memoize uses it to declare a conditional.
after setup/.code={\appto\AdviceAfterSetup{##1}},
@@ -257,6 +260,7 @@
% Open a group, so that we allow for embedded |auto| invocations.
\begingroup
\def\AdviceName{#3}%
+ \advice@def@AdviceCsname
% Command, complain, or environment?
\collargs@cs@cases{#3}{%
\def\AdviceType{command}%
@@ -399,7 +403,8 @@
\noexpand\csdef{advice@I#1//\string#2}{%
\def\noexpand\AdviceOuterHandler{\expandonce\AdviceOuterHandler}%
\def\noexpand\AdviceCollector{\expandonce\AdviceCollector}%
- \def\noexpand\AdviceRawCollectorOptions{\expandonce\AdviceRawCollectorOptions}%
+ \def\noexpand\AdviceRawCollectorOptions{%
+ \expandonce\AdviceRawCollectorOptions}%
\def\noexpand\AdviceCollectorOptions{\expandonce\AdviceCollectorOptions}%
\def\noexpand\AdviceArgs{\expandonce\AdviceArgs}%
\def\noexpand\AdviceInnerHandler{\expandonce\AdviceInnerHandler}%
@@ -412,9 +417,9 @@
% \label{sec:code:advice:activation}
%
% \begin{advicekey}{activation/immediate, activation/deferred}
-% The two subkeys of |/advice/activation| install the immediate and the
+% These two subkeys of |/advice/activation| install the immediate and the
% deferred activation code into the installation keypath. They are invoked
-% by \meta{installation keypath}|/activation=|\meta{type}.
+% by key \meta{installation keypath}|/activation=|\meta{type}.
%
% Under the deferred activation regime, the commands are not (de)activated
% right away. Rather, the (de)activation calls are collected in style
@@ -490,9 +495,27 @@
\def\advice@original@cs#1#2{\csname advice@o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice@o#1//\string#2\endcsname
- \csname advice@o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice@o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
+ \fi
+}
+% \end{macro}
+%
+% \begin{macro}{\AdviceCsnameGetOriginal}
+% A version of |\AdviceGetOriginal| which accepts a control sequence name as
+% the second argument.
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice@backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice@o#1//\advice@backslash@other#2\endcsname
+ \expandonce{\csname advice@o#1//\advice@backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
\fi
}
% \end{macro}
@@ -696,6 +719,7 @@
\def\advice@handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice@def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
% We then load the stage-two settings. This defines the following macros:
@@ -724,6 +748,14 @@
% All prepared, we execute the outer handler.
\AdviceOuterHandler
}
+\def\advice@def@AdviceCsname{%
+ \begingroup
+ \escapechar=-1
+ \expandafter\expandafter\expandafter\endgroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\AdviceCsname
+ \expandafter\expandafter\expandafter{\expandafter\string\AdviceName}%
+}
% \end{macro}
%
% \begin{macro}{\ifAdviceRun}
@@ -745,18 +777,22 @@
% CollArgs' command |\CollectArgumentsRaw|. It will provide that command
% with:
% \begin{itemize}
-% \item the collector options, given in the raw format: the caller
-% (|\collargsCaller|), the raw options (|\AdviceRawCollectorOptions|) and the
-% user options (|\AdviceRawCollectorOptions|, wrapped in |\collargsSet|;
+% \item the collector options, given in the raw format:
+% \begin{itemize}
+% \item the caller (|\collargsCaller|),
+% \item the raw options (|\AdviceRawCollectorOptions|), and
+% \item the user options (|\AdviceRawCollectorOptions|, wrapped in
+% |\collargsSet|;
+% \end{itemize}
% \item the argument specification |\AdviceArgs| of the handled command; and
% \item the inner handler |\AdviceInnerHandler| to execute after collecting the
% arguments; the inner handler receives the collected arguments as a single
% braced argument.
% \end{itemize}
-% If the argument specification is not defined (either the user did not set
-% it, or has reset it by writing |args| without a value), it is assumed that
-% the handled command was defined by |xparse| and |\AdviceArgs| will be
-% retrieved by |\GetDocumentCommandArgSpec|.
+% \hangindent=0pt If the argument specification is not defined (either the user
+% did not set it, or has reset it by writing |args| without a value), it is
+% assumed that the handled command was defined by |xparse| and |\AdviceArgs|
+% will be retrieved by |\GetDocumentCommandArgSpec|.
% \begin{listingregion}{_advice-CollectArgumentsRaw.tex}
\def\advice@CollectArgumentsRaw{%
\AdviceIfArgs{}{%
@@ -845,6 +881,7 @@
\advice@activate@error@activated{#1}{#2}{Environment}{already}%
}{%
\csdef{\advice@original@csname{#1}{#2}}{}%
+ \PackageInfo{advice (#1)}{Activated environment "#2"}%
}%
}
\def\advice@deactivate@env#1#2{%
@@ -852,6 +889,7 @@
\csundef{\advice@original@csname{#1}{#2}}{}%
}{%
\advice@activate@error@activated{#1}{#2}{Environment}{not yet}%
+ \PackageInfo{advice (#1)}{Dectivated environment "#2"}%
}%
}
% \end{macro}
@@ -911,6 +949,7 @@
\def\advice@begin@env@outer#1#2#3{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#3}%
+ \let\AdviceCsname\advice@undefined
\def\AdviceReplaced{#2{#3}}%
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}{#3}}%
\advice@init@I{#1}{#3}%
@@ -1000,6 +1039,8 @@
% Install the tracing code.
\def\advice@trace@init@i#1#2{%
\advice@trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice@trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice@original@cs{#1}{#2}}%
\advice@setup@init@i{#1}{#2}%
\edef\AdviceRunConditions{%
% We first execute the original run conditions, so that we can show the
@@ -1032,13 +1073,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice@trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice@trace{\space\space\space\space
- raw options:
+ Raw options:
\detokenize\expandafter{\AdviceRawCollectorOptions}}%
\expandonce\AdviceCollector
}%
@@ -1052,7 +1093,7 @@
Received arguments:
\noexpand\detokenize{##1}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
@@ -1079,38 +1120,38 @@
% The \TikZ; code resides in a special file. It is meant to be |\input| at any
% time, so we need to temporarily assign |@| category code 11.
%<*tikz>
-\edef\mmzresetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}%
+\edef\adviceresetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}%
\catcode`\@=11
\def\AdviceCollectTikZArguments{%
-% We initialize the token register which will hold the collected arguments, and
-% start the collection. Nothing of note happens until \dots
- \mmz@temptoks={}%
- \mmz@tikz@anim
+ % We initialize the token register which will hold the collected arguments,
+ % and start the collection. Nothing of note happens until \dots
+ \toks0={}%
+ \advice@tikz@anim
}
-\def\mmz@tikz@anim{%
- \pgfutil@ifnextchar[{\mmz@tikz@opt}{%
- \pgfutil@ifnextchar:{\mmz@tikz@anim@a}{%
- \mmz@tikz@code}}%]
+\def\advice@tikz@anim{%
+ \pgfutil@ifnextchar[{\advice@tikz@opt}{%
+ \pgfutil@ifnextchar:{\advice@tikz@anim@a}{%
+ \advice@tikz@code}}%]
}
-\def\mmz@tikz@anim@a#1=#2{%
- \toksapp\mmz@temptoks{#1={#2}}%
- \mmz@tikz@anim
+\def\advice@tikz@anim@a#1=#2{%
+ \toksapp0{#1={#2}}%
+ \advice@tikz@anim
}
-\def\mmz@tikz@opt[#1]{%
- \toksapp\mmz@temptoks{[#1]}%
- \mmz@tikz@code
+\def\advice@tikz@opt[#1]{%
+ \toksapp0{[#1]}%
+ \advice@tikz@code
}
-\def\mmz@tikz@code{%
- \pgfutil@ifnextchar\bgroup\mmz@tikz@braced\mmz@tikz@single
+\def\advice@tikz@code{%
+ \pgfutil@ifnextchar\bgroup\advice@tikz@braced\advice@tikz@single
}
-\long\def\mmz@tikz@braced#1{\toksapp\mmz@temptoks{{#1}}\mmz@tikz@done}
-\def\mmz@tikz@single#1;{\toksapp\mmz@temptoks{#1;}\mmz@tikz@done}
+\long\def\advice@tikz@braced#1{\toksapp0{{#1}}\advice@tikz@done}
+\def\advice@tikz@single#1;{\toksapp0{#1;}\advice@tikz@done}
% \dots\ we finish collecting the arguments, when we execute the inner handler,
% with the (braced) collected arguments is its sole argument.
-\def\mmz@tikz@done{%
- \expandafter\AdviceInnerHandler\expandafter{\the\mmz@temptoks}%
+\def\advice@tikz@done{%
+ \expandafter\AdviceInnerHandler\expandafter{\the\toks0}%
}
-\mmzresetatcatcode
+\adviceresetatcatcode
%</tikz>
% \end{macrocode}
%
diff --git a/Master/texmf-dist/tex/context/third/advice/t-advice.tex b/Master/texmf-dist/tex/context/third/advice/t-advice.tex
index e30bed0869a..503c3b7743a 100644
--- a/Master/texmf-dist/tex/context/third/advice/t-advice.tex
+++ b/Master/texmf-dist/tex/context/third/advice/t-advice.tex
@@ -27,11 +27,11 @@
%% (<texmf>/doc/generic/advice/)FILES.
%D \module[
%D file=t-advice.tex,
-%D version=1.0.1,
+%D version=1.1.0,
%D title=Advice,
%D subtitle=Extend commands and environments,
%D author=Saso Zivanovic,
-%D date=2023-10-24,
+%D date=2024-01-02,
%D copyright=Saso Zivanovic,
%D license=LPPL,
%D ]
@@ -88,7 +88,7 @@
activation=#3,
activate deferred/.code={},
activate csname/.style={activate/.expand once={\csname##1\endcsname}},
- deactivate csname/.style={activate/.expand once={\csname##1\endcsname}},
+ deactivate csname/.style={deactivate/.expand once={\csname##1\endcsname}},
activate key/.style={activate@key={#1/activate}{##1}},
deactivate key/.style={activate@key={#1/deactivate}{##1}},
activate@key/.code n args=2{%
@@ -130,6 +130,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice@def@AdviceCsname
\collargs@cs@cases{#3}{%
\def\AdviceType{command}%
\advice@setup@init@command
@@ -187,7 +188,8 @@
\noexpand\csdef{advice@I#1//\string#2}{%
\def\noexpand\AdviceOuterHandler{\expandonce\AdviceOuterHandler}%
\def\noexpand\AdviceCollector{\expandonce\AdviceCollector}%
- \def\noexpand\AdviceRawCollectorOptions{\expandonce\AdviceRawCollectorOptions}%
+ \def\noexpand\AdviceRawCollectorOptions{%
+ \expandonce\AdviceRawCollectorOptions}%
\def\noexpand\AdviceCollectorOptions{\expandonce\AdviceCollectorOptions}%
\def\noexpand\AdviceArgs{\expandonce\AdviceArgs}%
\def\noexpand\AdviceInnerHandler{\expandonce\AdviceInnerHandler}%
@@ -228,9 +230,22 @@
\def\advice@original@cs#1#2{\csname advice@o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice@o#1//\string#2\endcsname
- \csname advice@o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice@o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
+ \fi
+}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice@backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice@o#1//\advice@backslash@other#2\endcsname
+ \expandonce{\csname advice@o#1//\advice@backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
\fi
}
\def\advice@activate#1#2{%
@@ -315,11 +330,20 @@
\def\advice@handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice@def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice@init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice@def@AdviceCsname{%
+ \begingroup
+ \escapechar=-1
+ \expandafter\expandafter\expandafter\endgroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\AdviceCsname
+ \expandafter\expandafter\expandafter{\expandafter\string\AdviceName}%
+}
\newif\ifAdviceRun
\def\advice@default@outer@handler{%
\AdviceCollector
@@ -416,6 +440,8 @@
\def\advice@trace#1{\advice@typeout{[tracing advice] #1}}
\def\advice@trace@init@i#1#2{%
\advice@trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice@trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice@original@cs{#1}{#2}}%
\advice@setup@init@i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -446,13 +472,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice@trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice@trace{\space\space\space\space
- raw options:
+ Raw options:
\detokenize\expandafter{\AdviceRawCollectorOptions}}%
\expandonce\AdviceCollector
}%
@@ -464,7 +490,7 @@
Received arguments:
\noexpand\detokenize{##1}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
diff --git a/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex b/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex
index 6159b6a67af..798919a4449 100644
--- a/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex
+++ b/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex
@@ -25,34 +25,34 @@
%%
%% The files belonging to this work and covered by LPPL are listed in
%% (<texmf>/doc/generic/advice/)FILES.
-\edef\mmzresetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}%
+\edef\adviceresetatcatcode{\catcode`\noexpand\@\the\catcode`\@\relax}%
\catcode`\@=11
\def\AdviceCollectTikZArguments{%
- \mmz@temptoks={}%
- \mmz@tikz@anim
+ \toks0={}%
+ \advice@tikz@anim
}
-\def\mmz@tikz@anim{%
- \pgfutil@ifnextchar[{\mmz@tikz@opt}{%
- \pgfutil@ifnextchar:{\mmz@tikz@anim@a}{%
- \mmz@tikz@code}}%]
+\def\advice@tikz@anim{%
+ \pgfutil@ifnextchar[{\advice@tikz@opt}{%
+ \pgfutil@ifnextchar:{\advice@tikz@anim@a}{%
+ \advice@tikz@code}}%]
}
-\def\mmz@tikz@anim@a#1=#2{%
- \toksapp\mmz@temptoks{#1={#2}}%
- \mmz@tikz@anim
+\def\advice@tikz@anim@a#1=#2{%
+ \toksapp0{#1={#2}}%
+ \advice@tikz@anim
}
-\def\mmz@tikz@opt[#1]{%
- \toksapp\mmz@temptoks{[#1]}%
- \mmz@tikz@code
+\def\advice@tikz@opt[#1]{%
+ \toksapp0{[#1]}%
+ \advice@tikz@code
}
-\def\mmz@tikz@code{%
- \pgfutil@ifnextchar\bgroup\mmz@tikz@braced\mmz@tikz@single
+\def\advice@tikz@code{%
+ \pgfutil@ifnextchar\bgroup\advice@tikz@braced\advice@tikz@single
}
-\long\def\mmz@tikz@braced#1{\toksapp\mmz@temptoks{{#1}}\mmz@tikz@done}
-\def\mmz@tikz@single#1;{\toksapp\mmz@temptoks{#1;}\mmz@tikz@done}
-\def\mmz@tikz@done{%
- \expandafter\AdviceInnerHandler\expandafter{\the\mmz@temptoks}%
+\long\def\advice@tikz@braced#1{\toksapp0{{#1}}\advice@tikz@done}
+\def\advice@tikz@single#1;{\toksapp0{#1;}\advice@tikz@done}
+\def\advice@tikz@done{%
+ \expandafter\AdviceInnerHandler\expandafter{\the\toks0}%
}
-\mmzresetatcatcode
+\adviceresetatcatcode
\endinput
%%
%% End of file `advice-tikz.code.tex'.
diff --git a/Master/texmf-dist/tex/latex/advice/advice.sty b/Master/texmf-dist/tex/latex/advice/advice.sty
index 5678958cb59..aa983950795 100644
--- a/Master/texmf-dist/tex/latex/advice/advice.sty
+++ b/Master/texmf-dist/tex/latex/advice/advice.sty
@@ -25,7 +25,7 @@
%%
%% The files belonging to this work and covered by LPPL are listed in
%% (<texmf>/doc/generic/advice/)FILES.
-\ProvidesPackage{advice}[2023/10/24 v1.0.1 Extend commands and environments]
+\ProvidesPackage{advice}[2024/01/02 v1.1.0 Extend commands and environments]
\RequirePackage{collargs}
\RequirePackage{xparse}
\pgfkeys{
@@ -76,7 +76,7 @@
activation=#3,
activate deferred/.code={},
activate csname/.style={activate/.expand once={\csname##1\endcsname}},
- deactivate csname/.style={activate/.expand once={\csname##1\endcsname}},
+ deactivate csname/.style={deactivate/.expand once={\csname##1\endcsname}},
activate key/.style={activate@key={#1/activate}{##1}},
deactivate key/.style={activate@key={#1/deactivate}{##1}},
activate@key/.code n args=2{%
@@ -119,6 +119,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice@def@AdviceCsname
\collargs@cs@cases{#3}{%
\def\AdviceType{command}%
\advice@setup@init@command
@@ -176,7 +177,8 @@
\noexpand\csdef{advice@I#1//\string#2}{%
\def\noexpand\AdviceOuterHandler{\expandonce\AdviceOuterHandler}%
\def\noexpand\AdviceCollector{\expandonce\AdviceCollector}%
- \def\noexpand\AdviceRawCollectorOptions{\expandonce\AdviceRawCollectorOptions}%
+ \def\noexpand\AdviceRawCollectorOptions{%
+ \expandonce\AdviceRawCollectorOptions}%
\def\noexpand\AdviceCollectorOptions{\expandonce\AdviceCollectorOptions}%
\def\noexpand\AdviceArgs{\expandonce\AdviceArgs}%
\def\noexpand\AdviceInnerHandler{\expandonce\AdviceInnerHandler}%
@@ -217,9 +219,22 @@
\def\advice@original@cs#1#2{\csname advice@o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice@o#1//\string#2\endcsname
- \csname advice@o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice@o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
+ \fi
+}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice@backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice@o#1//\advice@backslash@other#2\endcsname
+ \expandonce{\csname advice@o#1//\advice@backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
\fi
}
\def\advice@activate#1#2{%
@@ -304,11 +319,20 @@
\def\advice@handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice@def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice@init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice@def@AdviceCsname{%
+ \begingroup
+ \escapechar=-1
+ \expandafter\expandafter\expandafter\endgroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\AdviceCsname
+ \expandafter\expandafter\expandafter{\expandafter\string\AdviceName}%
+}
\newif\ifAdviceRun
\def\advice@default@outer@handler{%
\AdviceCollector
@@ -346,6 +370,7 @@
\advice@activate@error@activated{#1}{#2}{Environment}{already}%
}{%
\csdef{\advice@original@csname{#1}{#2}}{}%
+ \PackageInfo{advice (#1)}{Activated environment "#2"}%
}%
}
\def\advice@deactivate@env#1#2{%
@@ -353,6 +378,7 @@
\csundef{\advice@original@csname{#1}{#2}}{}%
}{%
\advice@activate@error@activated{#1}{#2}{Environment}{not yet}%
+ \PackageInfo{advice (#1)}{Dectivated environment "#2"}%
}%
}
\def\advice@begin@rc#1\advice@handle@rc#2#3#4{%
@@ -377,6 +403,7 @@
\def\advice@begin@env@outer#1#2#3{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#3}%
+ \let\AdviceCsname\advice@undefined
\def\AdviceReplaced{#2{#3}}%
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}{#3}}%
\advice@init@I{#1}{#3}%
@@ -432,6 +459,8 @@
\def\advice@trace#1{\advice@typeout{[tracing advice] #1}}
\def\advice@trace@init@i#1#2{%
\advice@trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice@trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice@original@cs{#1}{#2}}%
\advice@setup@init@i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -462,13 +491,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice@trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice@trace{\space\space\space\space
- raw options:
+ Raw options:
\detokenize\expandafter{\AdviceRawCollectorOptions}}%
\expandonce\AdviceCollector
}%
@@ -480,7 +509,7 @@
Received arguments:
\noexpand\detokenize{##1}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
diff --git a/Master/texmf-dist/tex/plain/advice/advice.tex b/Master/texmf-dist/tex/plain/advice/advice.tex
index b648020d0c1..0927e11d290 100644
--- a/Master/texmf-dist/tex/plain/advice/advice.tex
+++ b/Master/texmf-dist/tex/plain/advice/advice.tex
@@ -75,7 +75,7 @@
activation=#3,
activate deferred/.code={},
activate csname/.style={activate/.expand once={\csname##1\endcsname}},
- deactivate csname/.style={activate/.expand once={\csname##1\endcsname}},
+ deactivate csname/.style={deactivate/.expand once={\csname##1\endcsname}},
activate key/.style={activate@key={#1/activate}{##1}},
deactivate key/.style={activate@key={#1/deactivate}{##1}},
activate@key/.code n args=2{%
@@ -117,6 +117,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice@def@AdviceCsname
\collargs@cs@cases{#3}{%
\def\AdviceType{command}%
\advice@setup@init@command
@@ -174,7 +175,8 @@
\noexpand\csdef{advice@I#1//\string#2}{%
\def\noexpand\AdviceOuterHandler{\expandonce\AdviceOuterHandler}%
\def\noexpand\AdviceCollector{\expandonce\AdviceCollector}%
- \def\noexpand\AdviceRawCollectorOptions{\expandonce\AdviceRawCollectorOptions}%
+ \def\noexpand\AdviceRawCollectorOptions{%
+ \expandonce\AdviceRawCollectorOptions}%
\def\noexpand\AdviceCollectorOptions{\expandonce\AdviceCollectorOptions}%
\def\noexpand\AdviceArgs{\expandonce\AdviceArgs}%
\def\noexpand\AdviceInnerHandler{\expandonce\AdviceInnerHandler}%
@@ -215,9 +217,22 @@
\def\advice@original@cs#1#2{\csname advice@o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice@o#1//\string#2\endcsname
- \csname advice@o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice@o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
+ \fi
+}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice@backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice@o#1//\advice@backslash@other#2\endcsname
+ \expandonce{\csname advice@o#1//\advice@backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
\fi
}
\def\advice@activate#1#2{%
@@ -302,11 +317,20 @@
\def\advice@handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice@def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice@init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice@def@AdviceCsname{%
+ \begingroup
+ \escapechar=-1
+ \expandafter\expandafter\expandafter\endgroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\AdviceCsname
+ \expandafter\expandafter\expandafter{\expandafter\string\AdviceName}%
+}
\newif\ifAdviceRun
\def\advice@default@outer@handler{%
\AdviceCollector
@@ -405,6 +429,8 @@
\def\advice@trace#1{\advice@typeout{[tracing advice] #1}}
\def\advice@trace@init@i#1#2{%
\advice@trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice@trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice@original@cs{#1}{#2}}%
\advice@setup@init@i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -435,13 +461,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice@trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice@trace{\space\space\space\space
- raw options:
+ Raw options:
\detokenize\expandafter{\AdviceRawCollectorOptions}}%
\expandonce\AdviceCollector
}%
@@ -453,7 +479,7 @@
Received arguments:
\noexpand\detokenize{##1}}%
\noexpand\advice@trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%