texlive[69283] Master/texmf-dist: advice (3jan24)
commits+karl at tug.org
commits+karl at tug.org
Wed Jan 3 22:18:17 CET 2024
Revision: 69283
https://tug.org/svn/texlive?view=revision&revision=69283
Author: karl
Date: 2024-01-03 22:18:16 +0100 (Wed, 03 Jan 2024)
Log Message:
-----------
advice (3jan24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/generic/advice/CHANGELOG.md
trunk/Master/texmf-dist/source/generic/advice/advice.edtx
trunk/Master/texmf-dist/tex/context/third/advice/t-advice.tex
trunk/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex
trunk/Master/texmf-dist/tex/latex/advice/advice.sty
trunk/Master/texmf-dist/tex/plain/advice/advice.tex
Modified: trunk/Master/texmf-dist/doc/generic/advice/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/generic/advice/CHANGELOG.md 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/doc/generic/advice/CHANGELOG.md 2024-01-03 21:18:16 UTC (rev 69283)
@@ -14,6 +14,15 @@
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.
Modified: trunk/Master/texmf-dist/source/generic/advice/advice.edtx
===================================================================
--- trunk/Master/texmf-dist/source/generic/advice/advice.edtx 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/source/generic/advice/advice.edtx 2024-01-03 21:18:16 UTC (rev 69283)
@@ -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 at 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 at def@AdviceCsname
% Command, complain, or environment?
\collargs at cs@cases{#3}{%
\def\AdviceType{command}%
@@ -399,7 +403,8 @@
\noexpand\csdef{advice at 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,13 +495,31 @@
\def\advice at original@cs#1#2{\csname advice at o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice at o#1//\string#2\endcsname
- \csname advice at o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice at 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 at backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice at o#1//\advice at backslash@other#2\endcsname
+ \expandonce{\csname advice at o#1//\advice at backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
+ \fi
+}
+% \end{macro}
+%
% \begin{macro}{\advice at activate,\advice at deactivate}
% These macros execute either the command, or the environment (de)activator.
\def\advice at activate#1#2{%
@@ -696,6 +719,7 @@
\def\advice at handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice at 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 at 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 at CollectArgumentsRaw{%
\AdviceIfArgs{}{%
@@ -845,6 +881,7 @@
\advice at activate@error at activated{#1}{#2}{Environment}{already}%
}{%
\csdef{\advice at original@csname{#1}{#2}}{}%
+ \PackageInfo{advice (#1)}{Activated environment "#2"}%
}%
}
\def\advice at deactivate@env#1#2{%
@@ -852,6 +889,7 @@
\csundef{\advice at original@csname{#1}{#2}}{}%
}{%
\advice at activate@error at activated{#1}{#2}{Environment}{not yet}%
+ \PackageInfo{advice (#1)}{Dectivated environment "#2"}%
}%
}
% \end{macro}
@@ -911,6 +949,7 @@
\def\advice at begin@env at outer#1#2#3{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#3}%
+ \let\AdviceCsname\advice at undefined
\def\AdviceReplaced{#2{#3}}%
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}{#3}}%
\advice at init@I{#1}{#3}%
@@ -1000,6 +1039,8 @@
% Install the tracing code.
\def\advice at trace@init at i#1#2{%
\advice at trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice at trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice at original@cs{#1}{#2}}%
\advice at setup@init at 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 at trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice at 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 at 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 at temptoks={}%
- \mmz at 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 at tikz@anim
}
-\def\mmz at tikz@anim{%
- \pgfutil at ifnextchar[{\mmz at tikz@opt}{%
- \pgfutil at ifnextchar:{\mmz at tikz@anim at a}{%
- \mmz at tikz@code}}%]
+\def\advice at tikz@anim{%
+ \pgfutil at ifnextchar[{\advice at tikz@opt}{%
+ \pgfutil at ifnextchar:{\advice at tikz@anim at a}{%
+ \advice at tikz@code}}%]
}
-\def\mmz at tikz@anim at a#1=#2{%
- \toksapp\mmz at temptoks{#1={#2}}%
- \mmz at tikz@anim
+\def\advice at tikz@anim at a#1=#2{%
+ \toksapp0{#1={#2}}%
+ \advice at tikz@anim
}
-\def\mmz at tikz@opt[#1]{%
- \toksapp\mmz at temptoks{[#1]}%
- \mmz at tikz@code
+\def\advice at tikz@opt[#1]{%
+ \toksapp0{[#1]}%
+ \advice at tikz@code
}
-\def\mmz at tikz@code{%
- \pgfutil at ifnextchar\bgroup\mmz at tikz@braced\mmz at tikz@single
+\def\advice at tikz@code{%
+ \pgfutil at ifnextchar\bgroup\advice at tikz@braced\advice at tikz@single
}
-\long\def\mmz at tikz@braced#1{\toksapp\mmz at temptoks{{#1}}\mmz at tikz@done}
-\def\mmz at tikz@single#1;{\toksapp\mmz at temptoks{#1;}\mmz at tikz@done}
+\long\def\advice at tikz@braced#1{\toksapp0{{#1}}\advice at tikz@done}
+\def\advice at tikz@single#1;{\toksapp0{#1;}\advice at 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 at tikz@done{%
- \expandafter\AdviceInnerHandler\expandafter{\the\mmz at temptoks}%
+\def\advice at tikz@done{%
+ \expandafter\AdviceInnerHandler\expandafter{\the\toks0}%
}
-\mmzresetatcatcode
+\adviceresetatcatcode
%</tikz>
% \end{macrocode}
%
Modified: trunk/Master/texmf-dist/tex/context/third/advice/t-advice.tex
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/advice/t-advice.tex 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/tex/context/third/advice/t-advice.tex 2024-01-03 21:18:16 UTC (rev 69283)
@@ -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 at key={#1/activate}{##1}},
deactivate key/.style={activate at key={#1/deactivate}{##1}},
activate at key/.code n args=2{%
@@ -130,6 +130,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice at def@AdviceCsname
\collargs at cs@cases{#3}{%
\def\AdviceType{command}%
\advice at setup@init at command
@@ -187,7 +188,8 @@
\noexpand\csdef{advice at 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,11 +230,24 @@
\def\advice at original@cs#1#2{\csname advice at o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice at o#1//\string#2\endcsname
- \csname advice at o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice at o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
\fi
}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice at backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice at o#1//\advice at backslash@other#2\endcsname
+ \expandonce{\csname advice at o#1//\advice at backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
+ \fi
+}
\def\advice at activate#1#2{%
\collargs at cs@cases{#2}%
{\advice at activate@cmd{#1}{#2}}%
@@ -315,11 +330,20 @@
\def\advice at handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice at def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice at init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice at 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 at default@outer at handler{%
\AdviceCollector
@@ -416,6 +440,8 @@
\def\advice at trace#1{\advice at typeout{[tracing advice] #1}}
\def\advice at trace@init at i#1#2{%
\advice at trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice at trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice at original@cs{#1}{#2}}%
\advice at setup@init at i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -446,13 +472,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice at trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice at 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 at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
Modified: trunk/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/tex/generic/advice/advice-tikz.code.tex 2024-01-03 21:18:16 UTC (rev 69283)
@@ -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 at temptoks={}%
- \mmz at tikz@anim
+ \toks0={}%
+ \advice at tikz@anim
}
-\def\mmz at tikz@anim{%
- \pgfutil at ifnextchar[{\mmz at tikz@opt}{%
- \pgfutil at ifnextchar:{\mmz at tikz@anim at a}{%
- \mmz at tikz@code}}%]
+\def\advice at tikz@anim{%
+ \pgfutil at ifnextchar[{\advice at tikz@opt}{%
+ \pgfutil at ifnextchar:{\advice at tikz@anim at a}{%
+ \advice at tikz@code}}%]
}
-\def\mmz at tikz@anim at a#1=#2{%
- \toksapp\mmz at temptoks{#1={#2}}%
- \mmz at tikz@anim
+\def\advice at tikz@anim at a#1=#2{%
+ \toksapp0{#1={#2}}%
+ \advice at tikz@anim
}
-\def\mmz at tikz@opt[#1]{%
- \toksapp\mmz at temptoks{[#1]}%
- \mmz at tikz@code
+\def\advice at tikz@opt[#1]{%
+ \toksapp0{[#1]}%
+ \advice at tikz@code
}
-\def\mmz at tikz@code{%
- \pgfutil at ifnextchar\bgroup\mmz at tikz@braced\mmz at tikz@single
+\def\advice at tikz@code{%
+ \pgfutil at ifnextchar\bgroup\advice at tikz@braced\advice at tikz@single
}
-\long\def\mmz at tikz@braced#1{\toksapp\mmz at temptoks{{#1}}\mmz at tikz@done}
-\def\mmz at tikz@single#1;{\toksapp\mmz at temptoks{#1;}\mmz at tikz@done}
-\def\mmz at tikz@done{%
- \expandafter\AdviceInnerHandler\expandafter{\the\mmz at temptoks}%
+\long\def\advice at tikz@braced#1{\toksapp0{{#1}}\advice at tikz@done}
+\def\advice at tikz@single#1;{\toksapp0{#1;}\advice at tikz@done}
+\def\advice at tikz@done{%
+ \expandafter\AdviceInnerHandler\expandafter{\the\toks0}%
}
-\mmzresetatcatcode
+\adviceresetatcatcode
\endinput
%%
%% End of file `advice-tikz.code.tex'.
Modified: trunk/Master/texmf-dist/tex/latex/advice/advice.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/advice/advice.sty 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/tex/latex/advice/advice.sty 2024-01-03 21:18:16 UTC (rev 69283)
@@ -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 at key={#1/activate}{##1}},
deactivate key/.style={activate at key={#1/deactivate}{##1}},
activate at key/.code n args=2{%
@@ -119,6 +119,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice at def@AdviceCsname
\collargs at cs@cases{#3}{%
\def\AdviceType{command}%
\advice at setup@init at command
@@ -176,7 +177,8 @@
\noexpand\csdef{advice at 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,11 +219,24 @@
\def\advice at original@cs#1#2{\csname advice at o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice at o#1//\string#2\endcsname
- \csname advice at o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice at o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
\fi
}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice at backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice at o#1//\advice at backslash@other#2\endcsname
+ \expandonce{\csname advice at o#1//\advice at backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
+ \fi
+}
\def\advice at activate#1#2{%
\collargs at cs@cases{#2}%
{\advice at activate@cmd{#1}{#2}}%
@@ -304,11 +319,20 @@
\def\advice at handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice at def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice at init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice at 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 at default@outer at handler{%
\AdviceCollector
@@ -346,6 +370,7 @@
\advice at activate@error at activated{#1}{#2}{Environment}{already}%
}{%
\csdef{\advice at original@csname{#1}{#2}}{}%
+ \PackageInfo{advice (#1)}{Activated environment "#2"}%
}%
}
\def\advice at deactivate@env#1#2{%
@@ -353,6 +378,7 @@
\csundef{\advice at original@csname{#1}{#2}}{}%
}{%
\advice at activate@error at activated{#1}{#2}{Environment}{not yet}%
+ \PackageInfo{advice (#1)}{Dectivated environment "#2"}%
}%
}
\def\advice at begin@rc#1\advice at handle@rc#2#3#4{%
@@ -377,6 +403,7 @@
\def\advice at begin@env at outer#1#2#3{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#3}%
+ \let\AdviceCsname\advice at undefined
\def\AdviceReplaced{#2{#3}}%
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}{#3}}%
\advice at init@I{#1}{#3}%
@@ -432,6 +459,8 @@
\def\advice at trace#1{\advice at typeout{[tracing advice] #1}}
\def\advice at trace@init at i#1#2{%
\advice at trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice at trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice at original@cs{#1}{#2}}%
\advice at setup@init at i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -462,13 +491,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice at trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice at 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 at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
Modified: trunk/Master/texmf-dist/tex/plain/advice/advice.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/advice/advice.tex 2024-01-03 21:18:06 UTC (rev 69282)
+++ trunk/Master/texmf-dist/tex/plain/advice/advice.tex 2024-01-03 21:18:16 UTC (rev 69283)
@@ -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 at key={#1/activate}{##1}},
deactivate key/.style={activate at key={#1/deactivate}{##1}},
activate at key/.code n args=2{%
@@ -117,6 +117,7 @@
\def\AdviceSetup#1#2#3{%
\begingroup
\def\AdviceName{#3}%
+ \advice at def@AdviceCsname
\collargs at cs@cases{#3}{%
\def\AdviceType{command}%
\advice at setup@init at command
@@ -174,7 +175,8 @@
\noexpand\csdef{advice at 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,11 +217,24 @@
\def\advice at original@cs#1#2{\csname advice at o#1//\string#2\endcsname}
\def\AdviceGetOriginal#1#2{%
\ifcsname advice at o#1//\string#2\endcsname
- \csname advice at o#1//\string#2\expandafter\endcsname
+ \expandonce{\csname advice at o#1//\string#2\expandafter\endcsname\expandafter}%
\else
- \expandafter#2%
+ \expandafter\noexpand\expandafter#2%
\fi
}
+\begingroup
+\catcode`\/=0
+\catcode`\\=12
+/gdef/advice at backslash@other{\}%
+/endgroup
+\def\AdviceCsnameGetOriginal#1#2{%
+ \ifcsname advice at o#1//\advice at backslash@other#2\endcsname
+ \expandonce{\csname advice at o#1//\advice at backslash@other#2\expandafter\endcsname
+ \expandafter}%
+ \else
+ \expandonce{\csname#2\expandafter\endcsname\expandafter}%
+ \fi
+}
\def\advice at activate#1#2{%
\collargs at cs@cases{#2}%
{\advice at activate@cmd{#1}{#2}}%
@@ -302,11 +317,20 @@
\def\advice at handle@outer#1#2{%
\def\AdviceNamespace{#1}%
\def\AdviceName{#2}%
+ \advice at def@AdviceCsname
\let\AdviceReplaced\AdviceName
\def\AdviceOriginal{\AdviceGetOriginal{#1}{#2}}%
\advice at init@I{#1}{#2}%
\AdviceOuterHandler
}
+\def\advice at 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 at default@outer at handler{%
\AdviceCollector
@@ -405,6 +429,8 @@
\def\advice at trace#1{\advice at typeout{[tracing advice] #1}}
\def\advice at trace@init at i#1#2{%
\advice at trace{Advising \detokenize\expandafter{\string#2} (\detokenize{#1})}%
+ \advice at trace{\space\space Original command meaning:
+ \expandafter\expandafter\expandafter\meaning\advice at original@cs{#1}{#2}}%
\advice at setup@init at i{#1}{#2}%
\edef\AdviceRunConditions{%
\expandonce\AdviceRunConditions
@@ -435,13 +461,13 @@
Executing collector:
\detokenize\expandafter{\AdviceCollector}}%
\noexpand\advice at trace{\space\space\space\space
- argument specification:
+ Argument specification:
\detokenize\expandafter{\AdviceArgs}}%
\noexpand\advice at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceCollectorOptions}}%
\noexpand\advice at 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 at trace{\space\space\space\space
- options:
+ Options:
\detokenize\expandafter{\AdviceOptions}}%
\expandonce{\AdviceInnerHandler}{##1}%
}%
More information about the tex-live-commits
mailing list.