[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh441: Rename \DeclareDefaultHookLabel to \SetDefaultHookLabel (1ecc7bca)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Dec 14 15:52:31 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh441
Link       : https://github.com/latex3/latex2e/commit/1ecc7bca37ebb8031fc4b58939fd1c2818a6e65e

>---------------------------------------------------------------

commit 1ecc7bca37ebb8031fc4b58939fd1c2818a6e65e
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Dec 14 11:52:31 2020 -0300

    Rename \DeclareDefaultHookLabel to \SetDefaultHookLabel


>---------------------------------------------------------------

1ecc7bca37ebb8031fc4b58939fd1c2818a6e65e
 base/lthooks.dtx                       | 34 +++++++++++++++++++++++++---------
 base/testfiles-lthooks/lthooks-024.lvt |  8 ++++----
 base/testfiles-lthooks/lthooks-028.lvt |  4 ++--
 base/testfiles-lthooks/lthooks-028.tlg |  4 ++--
 4 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 03895255..a2276447 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -380,7 +380,7 @@
 % If \meta{hook} name or \meta{label} consist just of a single dot
 % (|.|), or starts with a dot followed by a slash (|./|) then the dot
 % denotes the \meta{default label} (usually the current package or class
-% name---see~\cs{DeclareDefaultHookLabel}).
+% name---see~\cs{SetDefaultHookLabel}).
 % A \enquote{|.|} or \enquote{|./|} anywhere else in a \meta{hook} or in
 % \meta{label} is treated literally and is not replaced.
 %
@@ -430,19 +430,19 @@
 % In some cases, for example in large packages, one may want to separate
 % it in logical parts, but still use the main package name as
 % \meta{label}, then the \meta{default label} can be set using
-% \cs{DeclareDefaultHookLabel}:
+% \cs{SetDefaultHookLabel}:
 %
-% \begin{function}{\DeclareDefaultHookLabel}
+% \begin{function}{\SetDefaultHookLabel}
 %   \begin{syntax}
-%     \cs{DeclareDefaultHookLabel} \Arg{default label}
+%     \cs{SetDefaultHookLabel} \Arg{default label}
 %   \end{syntax}
 %   Sets the \meta{default label} to be used in \meta{label} arguments.
-%   If \cs{DeclareDefaultHookLabel} is not used in the
+%   If \cs{SetDefaultHookLabel} is not used in the
 %   current package, \cs{@currname} is used instead.  If \cs{@currname}
 %   is not set, the code is assumed to be in the main document, in which
 %   case \texttt{top-level} is used.
 %
-%   The effect of \cs{DeclareDefaultHookLabel} holds for the current
+%   The effect of \cs{SetDefaultHookLabel} holds for the current
 %   file, and is reset to the previous value when the file is closed.
 % \end{function}
 %
@@ -3942,6 +3942,15 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\msg_new:nnn { hooks } { ddhl-deprecated }
+  {
+    \iow_char:N \\DeclareDefaultHookLabel~is~deprecated.\\
+    Use~\iow_char:N \\SetDefaultHookLabel~instead.\\ \\
+    The~deprecated~name~will~be~removed~in~the~next~release.
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \msg_new:nnn { hooks } { should-not-happen }
   {
     ERROR!~This~should~not~happen.~#1 \\
@@ -3987,13 +3996,14 @@
 %    \end{macrocode}
 %  \end{macro}
 %
+% \begin{macro}{\SetDefaultHookLabel}
 % \begin{macro}{\DeclareDefaultHookLabel}
 % \begin{macro}{\@@_curr_name_push:n,\@@_curr_name_pop:}
 %   The token list \cs{g_@@_hook_curr_name_tl} stores the name of the
 %   current package/file to be used as label for hooks.
 %   Providing a consistent interface is tricky, because packages can
 %   be loaded within packages, and some packages may not use
-%   \cs{DeclareDefaultHookLabel} to change the default label (in which
+%   \cs{SetDefaultHookLabel} to change the default label (in which
 %   case \cs{@currname} is used, if set).
 %
 %   To pull that off, we keep a stack that contains the default label
@@ -4024,7 +4034,7 @@
 %   Finally, an empty entry is added to the
 %   stack to account for the \verb|top-level|.  The item is empty so
 %   that the hard-coded default is used, but a call to
-%   \cs{DeclareDefaultHookLabel} will change it if needed.
+%   \cs{SetDefaultHookLabel} will change it if needed.
 %    \begin{macrocode}
 \seq_gpush:Nn \g_@@_name_stack_seq { }
 %    \end{macrocode}
@@ -4062,14 +4072,20 @@
 %   Now define a wrapper that replaces the top of the stack with the
 %   argument, and updates \cs{g_@@_hook_curr_name_tl} accordingly.
 %    \begin{macrocode}
-\NewDocumentCommand \DeclareDefaultHookLabel { m }
+\NewDocumentCommand \SetDefaultHookLabel { m }
   {
     \seq_gpop:NN \g_@@_name_stack_seq \l_@@_return_tl
     \@@_curr_name_push:n {#1}
   }
+\NewDocumentCommand \DeclareDefaultHookLabel { m }
+  {
+    \msg_error:nn { hooks } { ddhl-deprecated }
+    \SetDefaultHookLabel {#1}
+  }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 %
 %
diff --git a/base/testfiles-lthooks/lthooks-024.lvt b/base/testfiles-lthooks/lthooks-024.lvt
index 5e415086..8e15d86a 100644
--- a/base/testfiles-lthooks/lthooks-024.lvt
+++ b/base/testfiles-lthooks/lthooks-024.lvt
@@ -55,9 +55,9 @@
   \RemoveFromHook{foo}[*]
 }
 
-% pkgA sets \DeclareDefaultHookLabel
+% pkgA sets \SetDefaultHookLabel
 \begin{filecontents}{\jobname-pkgA.sty}
-\DeclareDefaultHookLabel{pkgA}
+\SetDefaultHookLabel{pkgA}
 \testme{pkgA}
 \usepackage{\jobname-pkgB}
 \testme{pkgA}
@@ -72,7 +72,7 @@
 
 % pkgC also sets a default label
 \begin{filecontents}{\jobname-pkgC.sty}
-\DeclareDefaultHookLabel{pkgC}
+\SetDefaultHookLabel{pkgC}
 \testme{pkgC}
 \end{filecontents}
 
@@ -88,7 +88,7 @@
 \cs_undefine:c { ver@\jobname-pkgC.sty }
 \ExplSyntaxOff
 
-\DeclareDefaultHookLabel{my-document}
+\SetDefaultHookLabel{my-document}
 \testme{my-document}
 \usepackage{\jobname-pkgA}
 \testme{my-document}
diff --git a/base/testfiles-lthooks/lthooks-028.lvt b/base/testfiles-lthooks/lthooks-028.lvt
index ce4ebd05..aad1e362 100644
--- a/base/testfiles-lthooks/lthooks-028.lvt
+++ b/base/testfiles-lthooks/lthooks-028.lvt
@@ -14,11 +14,11 @@
 \usepackage{\jobname-pkg}
 
 % Expect an error
-\DeclareDefaultHookLabel{not-top-level}
+\SetDefaultHookLabel{not-top-level}
 \AtBeginDocument[top-level]{\TIMO\typeout{'top-level' with changed label}\OMIT}
 
 % Return default label to top-level
-\DeclareDefaultHookLabel{top-level}
+\SetDefaultHookLabel{top-level}
 \AtBeginDocument[top-level]{\TIMO\typeout{'top-level' with default label}\OMIT}
 
 \OMIT
diff --git a/base/testfiles-lthooks/lthooks-028.tlg b/base/testfiles-lthooks/lthooks-028.tlg
index a2d6551a..0aca927b 100644
--- a/base/testfiles-lthooks/lthooks-028.tlg
+++ b/base/testfiles-lthooks/lthooks-028.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
 Don't change this file in any respect.
 (lthooks-028-pkg.sty
 ! Package hooks Error: Illegal \AddToHook{begindocument}[top-level]{...}.
-(hooks)                'top-level' is reserved to the user's document.
+(hooks)                'top-level' is reserved for the user's document.
 For immediate help type H <return>.
  ...                                              
 l. ......ypeout{'top-level' from \jobname-pkg}\OMIT}
@@ -11,7 +11,7 @@ The 'top-level' label is meant for user code only, and should only be used
 this package, or another suitable label.
 )
 ! Package hooks Error: Illegal \AddToHook{begindocument}[top-level]{...}.
-(hooks)                'top-level' is reserved to the user's document.
+(hooks)                'top-level' is reserved for the user's document.
 For immediate help type H <return>.
  ...                                              
 l. ......eout{'top-level' with changed label}\OMIT}





More information about the latex3-commits mailing list.