[latex3-commits] [git/LaTeX3-latex3-latex2e] hook-args: Correct behaviour of reversed and pair declarations (c0a09088)
PhelypeOleinik
phelype.oleinik at latex-project.org
Thu Mar 30 05:24:59 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : hook-args
Link : https://github.com/latex3/latex2e/commit/c0a090884ff08677ebf9aee8b4870d77b9c23bdf
>---------------------------------------------------------------
commit c0a090884ff08677ebf9aee8b4870d77b9c23bdf
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Thu Mar 30 00:24:59 2023 -0300
Correct behaviour of reversed and pair declarations
>---------------------------------------------------------------
c0a090884ff08677ebf9aee8b4870d77b9c23bdf
base/lthooks.dtx | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index b2517775..a7fe4f5c 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -2891,13 +2891,12 @@
{ \@@_normalize_hook_args:Nn \@@_new_reversed:nn {#1} {#2} }
\cs_new_protected:Npn \@@_new_reversed:nn #1 #2
{
- \@@_new:nn {#1} {#2}
-% \end{macrocode}
-% If the hook already exists the above will generate an error
-% message, so the next line should be executed (but it is --- too
-% bad).
-% \begin{macrocode}
- \tl_gset:cn { g_@@_#1_reversed_tl } { - }
+ \@@_if_declared:nTF {#1}
+ { \msg_error:nnn { hooks } { exists } {#1} }
+ {
+ \@@_new:nn {#1} {#2}
+ \tl_gset:cn { g_@@_#1_reversed_tl } { - }
+ }
}
%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
@@ -2926,14 +2925,21 @@
%<latexrelease>\IncludeInRelease{2023/06/01}{\hook_new_pair_with_args:nnn}
%<latexrelease> {Hooks~with~args}
\cs_new_protected:Npn \hook_new_pair:nn #1#2
- {
- \hook_new:n {#1}
- \hook_new_reversed:n {#2}
- }
+ { \@@_normalize_hook_args:Nnn \@@_new_pair:nnn {#1} {#2} { 0 } }
\cs_new_protected:Npn \hook_new_pair_with_args:nnn #1#2#3
+ { \@@_normalize_hook_args:Nnn \@@_new_pair:nnn {#1} {#2} {#3} }
+\cs_new_protected:Npn \@@_new_pair:nnn #1 #2 #3
{
- \hook_new_with_args:nn {#1} {#3}
- \hook_new_reversed_with_args:nn {#2} {#3}
+ \@@_if_declared:nTF {#1}
+ { \msg_error:nnn { hooks } { exists } {#1} }
+ {
+ \@@_if_declared:nTF {#2}
+ { \msg_error:nnn { hooks } { exists } {#2} }
+ {
+ \@@_new:nn {#1} {#3}
+ \@@_new_reversed:nn {#2} {#3}
+ }
+ }
}
%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
@@ -2941,6 +2947,11 @@
% \begin{macrocode}
%<latexrelease>\IncludeInRelease{2020/10/01}{\hook_new_pair_with_args:nnn}
%<latexrelease> {Hooks~with~args}
+%<latexrelease>\cs_gset_protected:Npn \hook_new_pair:nn #1#2
+%<latexrelease> {
+%<latexrelease> \hook_new:n {#1}
+%<latexrelease> \hook_new_reversed:n {#2}
+%<latexrelease> }
%<latexrelease>\cs_gset_protected:Npn \hook_new_pair_with_args:nnn #1#2#3
%<latexrelease> { }
%<latexrelease>\EndIncludeInRelease
More information about the latex3-commits
mailing list.