[latex3-commits] [git/LaTeX3-latex3-latex2e] gh674: Make patching commands a global operation (d023292b)
PhelypeOleinik
phelype.oleinik at latex-project.org
Wed Sep 29 05:17:26 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : gh674
Link : https://github.com/latex3/latex2e/commit/d023292b2cec19dcc039e4399ff1415021dcedec
>---------------------------------------------------------------
commit d023292b2cec19dcc039e4399ff1415021dcedec
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Wed Sep 29 00:17:26 2021 -0300
Make patching commands a global operation
Fixes #674
>---------------------------------------------------------------
d023292b2cec19dcc039e4399ff1415021dcedec
base/changes.txt | 5 +++++
base/ltcmdhooks.dtx | 14 ++++++++++----
base/testfiles-lthooks/github-0674.lvt | 31 +++++++++++++++++++++++++++++++
base/testfiles-lthooks/github-0674.tlg | 13 +++++++++++++
4 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 50f916b2..9b3dfc7b 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2021-09-28 Phelype Oleinik <phelype.oleinik at latex-project.org>
+
+ * ltcmdhooks.dtx (subsection{Patching commands}):
+ Make patching commands a global operation (gh/674).
+
2021-09-18 David Carlisle <David.Carlisle at latex-project.org>
* ltpara.dtx: use a \hskip rather than \kern as the guard to
diff --git a/base/ltcmdhooks.dtx b/base/ltcmdhooks.dtx
index b6c57a41..6f28abcf 100644
--- a/base/ltcmdhooks.dtx
+++ b/base/ltcmdhooks.dtx
@@ -13,8 +13,8 @@
%
%%% From File: ltcmdhooks.dtx
%
-\def\ltcmdhooksversion{v1.0d}
-\def\ltcmdhooksdate{2021/08/25}
+\def\ltcmdhooksversion{v1.0e}
+\def\ltcmdhooksdate{2021/09/28}
%
%
%
@@ -751,10 +751,13 @@
% command expanded once grabbing the parameters in
% \cs{l_@@_patch_replacement_tl}, and \hook{cmd/\#3/after} if |#4| is
% |after|.
+%
+% \changes{v1.0e}{2021/09/28}
+% {Make patching commands a global operation (gh/674)}
% \begin{macrocode}
\use:x
{
- \l_@@_patch_prefixes_tl \tex_def:D
+ \l_@@_patch_prefixes_tl \tex_gdef:D
\exp_not:N #2 \exp_not:V \l_@@_patch_param_text_tl
{
\str_if_eq:nnT {#4} { before }
@@ -1061,8 +1064,11 @@
% \end{macrocode}
% And to close, copy the newly-defined command into the old name and
% the patching is finally completed:
+%
+% \changes{v1.0e}{2021/09/28}
+% {Make patching commands a global operation (gh/674)}
% \begin{macrocode}
- \cs_set_eq:NN #1 \kerneltmpDoNotUse
+ \cs_gset_eq:NN #1 \kerneltmpDoNotUse
}
% \end{macrocode}
% \end{macro}
diff --git a/base/testfiles-lthooks/github-0674.lvt b/base/testfiles-lthooks/github-0674.lvt
new file mode 100644
index 00000000..e5a703e0
--- /dev/null
+++ b/base/testfiles-lthooks/github-0674.lvt
@@ -0,0 +1,31 @@
+
+\RequirePackage[enable-debug]{expl3}
+\ExplSyntaxOn
+\debug_on:n { check-declarations , deprecation }
+\ExplSyntaxOff
+
+\input{test2e}
+
+\documentclass{article}
+
+\def\foo#1/#2{<foo code>}
+
+\begingroup
+\AddToHook{cmd/textbf/before}{\XXX} % patching happens later so no longer inside a group
+\AddToHook{cmd/foo/before}{\XXX}
+\endgroup
+
+\begin{document}
+
+\begingroup
+\AddToHook{cmd/textbf/after}{\YYY} % patch is undone at group end
+\AddToHook{cmd/foo/after}{\YYY}
+\endgroup
+
+\START
+\ShowCommand\textbf % after hook not patched in but "before" hook is
+\ShowCommand\foo
+\END
+
+\end{document}
+
diff --git a/base/testfiles-lthooks/github-0674.tlg b/base/testfiles-lthooks/github-0674.tlg
new file mode 100644
index 00000000..d0aed422
--- /dev/null
+++ b/base/testfiles-lthooks/github-0674.tlg
@@ -0,0 +1,13 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+> \textbf=robust macro:
+->\protect \textbf .
+> \textbf =\long macro:
+#1->\UseHook {cmd/textbf/before}\ifmmode \nfss at text {\bfseries #1}\else \hmode at bgroup \text at command {#1}\bfseries \check at icl #1\check at icr \expandafter \egroup \fi \UseHook {cmd/textbf/after}.
+<argument> \textbf
+l. ...\ShowCommand\textbf
+ % after hook not patched in but "befor...
+> \foo=macro:
+#1/#2->\UseHook {cmd/foo/before}<foo code>\UseHook {cmd/foo/after}.
+<argument> \foo
+l. ...\ShowCommand\foo
More information about the latex3-commits
mailing list.