[latex3-commits] [git/LaTeX3-latex3-latex2e] gh625: Change cannot-remove from error to warning (5da20f6a)

PhelypeOleinik phelype.oleinik at latex-project.org
Wed Jul 28 02:50:01 CEST 2021


Repository : https://github.com/latex3/latex2e
On branch  : gh625
Link       : https://github.com/latex3/latex2e/commit/5da20f6a6f67889befc99424c94271573c42d9c1

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

commit 5da20f6a6f67889befc99424c94271573c42d9c1
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Tue Jul 27 21:50:01 2021 -0300

    Change cannot-remove from error to warning


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

5da20f6a6f67889befc99424c94271573c42d9c1
 base/doc/ltnews34.tex                    |  4 ++--
 base/lthooks.dtx                         | 14 +++++++-------
 base/testfiles-lthooks/lthooks-001.lvt   |  4 ++--
 base/testfiles-lthooks/lthooks-001.tlg   | 18 ++----------------
 base/testfiles-lthooks/lthooks-002.lvt   |  4 ++--
 base/testfiles-lthooks/lthooks-002.tlg   | 18 ++----------------
 base/testfiles-lthooks2/lthooks2-006.tlg | 16 ++--------------
 support/test209.tex                      |  3 ++-
 support/test2e.tex                       |  3 ++-
 9 files changed, 23 insertions(+), 61 deletions(-)

diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index e16828f8..a6f7fce5 100644
--- a/base/doc/ltnews34.tex
+++ b/base/doc/ltnews34.tex
@@ -158,8 +158,8 @@ not cancel two \cs{AddToHook} to that label, and this asymmetry caused
 confusion and was a recipe for further problems.
 
 The implementation was changed and now \cs{RemoveFromHook} only removes
-labels that already exist in a hook, and will raise error if they don't.
-For usage across packages, for removing code in a hook, the
+labels that already exist in a hook, and will display a warning if they
+don't.  For usage across packages, for removing code in a hook, the
 \texttt{voids} relation should be used instead:  this relation is
 non-destructive (meaning it can be later reverted with another one), and
 it is truly independent of package loading order, so it should be
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index d95b5838..556882d2 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -322,8 +322,8 @@
 %    \meta{default label} is used (see section~\ref{sec:default-label}).
 %
 %    If there is no code under the \meta{label} in the \meta{hook},
-%    or if the \meta{hook} does not exist, an error is raised when
-%    you attempt to \cs{RemoveFromHook}.
+%    or if the \meta{hook} does not exist, a warning is issued when
+%    you attempt to \cs{RemoveFromHook}, and the command is ignored.
 %    \cs{RemoveFromHook} should be used when you know exactly what
 %    labels are in a hook, usually added and removed within the same
 %    package.  If you want to prevent the execution of code from another
@@ -1025,8 +1025,8 @@
 %    Removes any code for \meta{hook} labeled \meta{label}.
 %
 %    If there is no code under the \meta{label} in the \meta{hook},
-%    or if the \meta{hook} does not exist, an error is raised when
-%    you attempt to \cs{RemoveFromHook}.
+%    or if the \meta{hook} does not exist, a warning is issued when
+%    you attempt to \cs{hook_gremove_code:nn}, and the command is ignored.
 %
 %    If the second argument is \texttt{*}, then all code chunks are
 %    removed. This is rather dangerous as it drops code from other
@@ -3152,7 +3152,7 @@
               { \@@_tl_gclear:c { @@_toplevel~#1 } }
               {
                 \prop_gpop:cnNF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
-                  { \msg_error:nnnn { hooks } { cannot-remove } {#1} {#2} }
+                  { \msg_warning:nnnn { hooks } { cannot-remove } {#1} {#2} }
               }
           }
 %    \end{macrocode}
@@ -3163,9 +3163,9 @@
       }
 %    \end{macrocode}
 %
-%    If the code pool for this hook doesn't exist, raise an error:
+%    If the code pool for this hook doesn't exist, show a warning:
 %    \begin{macrocode}
-      { \msg_error:nnnn { hooks } { cannot-remove } {#1} {#2} }
+      { \msg_warning:nnnn { hooks } { cannot-remove } {#1} {#2} }
   }
 %    \end{macrocode}
 %
diff --git a/base/testfiles-lthooks/lthooks-001.lvt b/base/testfiles-lthooks/lthooks-001.lvt
index 4107712d..a8d3d2ae 100644
--- a/base/testfiles-lthooks/lthooks-001.lvt
+++ b/base/testfiles-lthooks/lthooks-001.lvt
@@ -24,8 +24,8 @@
 
 
 \hook_gremove_code:nn{xxx}{label2}
-\hook_gremove_code:nn{xxx}{label3} % errors because label3 doesn't exist
-\hook_gremove_code:nn{yyy}{label3} % errors because yyy doesn't exist
+\hook_gremove_code:nn{xxx}{label3} % warns about label3 doesn't exist
+\hook_gremove_code:nn{yyy}{label3} % warns about yyy doesn't exist
 
 \prop_log:N \g__hook_xxx_code_prop
 
diff --git a/base/testfiles-lthooks/lthooks-001.tlg b/base/testfiles-lthooks/lthooks-001.tlg
index bd3e95bb..4ca5cf24 100644
--- a/base/testfiles-lthooks/lthooks-001.tlg
+++ b/base/testfiles-lthooks/lthooks-001.tlg
@@ -109,24 +109,10 @@ All initialized (non-empty) hooks:
  file/after/ulem.sty -> \__hook_toplevel file/after/ulem.sty \def \@hspace ##1{\begingroup \setlength \skip@ {##1}\edef \x {\endgroup \hskip \the \skip@ \relax }\x }\__hook_next file/after/ulem.sty  
  file/after/varwidth.sty -> \__hook_toplevel file/after/varwidth.sty \FirstAidNeededT {varwidth}{sty}{....-..-.. ver 0.92; \space Variable-width minipages}{\def \@vwid at sift {\skip@ \lastskip \unskip \ifdim \lastskip =\z@ \unskip \fi \dimen@ \lastkern \unkern \count@ \lastpenalty \unpenalty \setbox \z@ \lastbox \ifvoid \z@ \advance \sift at deathcycles \@ne \else \sift at deathcycles \z@ \fi \ifnum \sift at deathcycles >33 \let \@vwid at sift \relax \PackageWarning {varwidth}{Failed to reprocess entire contents}\fi \ifnum \count@ =\@vwid at preeqp \@vwid at eqmodefalse \fi \ifnum \count@ =\@vwid at posteqp \@vwid at eqmodetrue \fi \ifnum \count@ =\@vwid at toppen \let \@vwid at sift \relax \else \ifnum \count@ =\@vwid at offsets \@vwid at setoffsets \else \ifnum \count@ =\@vwid at postw \else \@vwid at resetb \fi \@vwid at append \fi \fi \@vwid at sift }}\__hook_next file/after/varwidth.sty  
  xxx -> foobar\__hook_toplevel xxx \__hook_next xxx  
-! LaTeX hooks Error: Cannot remove chunk 'label3' from hook 'xxx' because it
+LaTeX hooks Warning: Cannot remove chunk 'label3' from hook 'xxx' because it
 (hooks)              does not exist in that hook.
-Type <return> to continue.
- ...                                              
-l. ...\hook_gremove_code:nn{xxx}{label3}
-                                        % errors because label3 doesn't exist
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
-! LaTeX hooks Error: Cannot remove chunk 'label3' from hook 'yyy' because the
+LaTeX hooks Warning: Cannot remove chunk 'label3' from hook 'yyy' because the
 (hooks)              hook does not exist.
-Type <return> to continue.
- ...                                              
-l. ...\hook_gremove_code:nn{yyy}{label3}
-                                        % errors because yyy doesn't exist
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
 The property list \g__hook_xxx_code_prop contains the pairs (without outer
 braces):
 >  {label1}  =>  {foo}.
diff --git a/base/testfiles-lthooks/lthooks-002.lvt b/base/testfiles-lthooks/lthooks-002.lvt
index 9e4ff00a..f8bf1b02 100644
--- a/base/testfiles-lthooks/lthooks-002.lvt
+++ b/base/testfiles-lthooks/lthooks-002.lvt
@@ -24,8 +24,8 @@
 \ExplSyntaxOff
 
 \RemoveFromHook{xxx}[label2]
-\RemoveFromHook{xxx}[label3] % errors because label3 doesn't exist
-\RemoveFromHook{yyy}[label3] % errors because yyy doesn't exist
+\RemoveFromHook{xxx}[label3] % warns about label3 doesn't exist
+\RemoveFromHook{yyy}[label3] % warns about yyy doesn't exist
 \AddToHook{xxx}{baz}           % this becomes top-level
 
 
diff --git a/base/testfiles-lthooks/lthooks-002.tlg b/base/testfiles-lthooks/lthooks-002.tlg
index 9a5b8e83..64b6ceb5 100644
--- a/base/testfiles-lthooks/lthooks-002.tlg
+++ b/base/testfiles-lthooks/lthooks-002.tlg
@@ -109,24 +109,10 @@ All initialized (non-empty) hooks:
  file/after/ulem.sty -> \__hook_toplevel file/after/ulem.sty \def \@hspace ##1{\begingroup \setlength \skip@ {##1}\edef \x {\endgroup \hskip \the \skip@ \relax }\x }\__hook_next file/after/ulem.sty  
  file/after/varwidth.sty -> \__hook_toplevel file/after/varwidth.sty \FirstAidNeededT {varwidth}{sty}{....-..-.. ver 0.92; \space Variable-width minipages}{\def \@vwid at sift {\skip@ \lastskip \unskip \ifdim \lastskip =\z@ \unskip \fi \dimen@ \lastkern \unkern \count@ \lastpenalty \unpenalty \setbox \z@ \lastbox \ifvoid \z@ \advance \sift at deathcycles \@ne \else \sift at deathcycles \z@ \fi \ifnum \sift at deathcycles >33 \let \@vwid at sift \relax \PackageWarning {varwidth}{Failed to reprocess entire contents}\fi \ifnum \count@ =\@vwid at preeqp \@vwid at eqmodefalse \fi \ifnum \count@ =\@vwid at posteqp \@vwid at eqmodetrue \fi \ifnum \count@ =\@vwid at toppen \let \@vwid at sift \relax \else \ifnum \count@ =\@vwid at offsets \@vwid at setoffsets \else \ifnum \count@ =\@vwid at postw \else \@vwid at resetb \fi \@vwid at append \fi \fi \@vwid at sift }}\__hook_next file/after/varwidth.sty  
  xxx -> foobar\__hook_toplevel xxx \__hook_next xxx  
-! LaTeX hooks Error: Cannot remove chunk 'label3' from hook 'xxx' because it
+LaTeX hooks Warning: Cannot remove chunk 'label3' from hook 'xxx' because it
 (hooks)              does not exist in that hook.
-Type <return> to continue.
- ...                                              
-l. ...\RemoveFromHook{xxx}[label3]
-                                  % errors because label3 doesn't exist
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
-! LaTeX hooks Error: Cannot remove chunk 'label3' from hook 'yyy' because the
+LaTeX hooks Warning: Cannot remove chunk 'label3' from hook 'yyy' because the
 (hooks)              hook does not exist.
-Type <return> to continue.
- ...                                              
-l. ...\RemoveFromHook{yyy}[label3]
-                                  % errors because yyy doesn't exist
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
 **** Add to hook xxx (top-level) on input line ... <- baz
 The property list \g__hook_xxx_code_prop contains the pairs (without outer
 braces):
diff --git a/base/testfiles-lthooks2/lthooks2-006.tlg b/base/testfiles-lthooks2/lthooks2-006.tlg
index f8a763bc..111223e8 100644
--- a/base/testfiles-lthooks2/lthooks2-006.tlg
+++ b/base/testfiles-lthooks2/lthooks2-006.tlg
@@ -53,14 +53,8 @@ Now there are no code chunks:
 -> The hook 'some-hook-b':
 > The hook is not declared.
 > The hook is empty.
-! LaTeX hooks Error: Cannot remove chunk 'my-package' from hook 'some-hook-a'
+LaTeX hooks Warning: Cannot remove chunk 'my-package' from hook 'some-hook-a'
 (hooks)              because it does not exist in that hook.
-Type <return> to continue.
- ...                                              
-l. ...\RemoveFromHook{some-hook-a}[my-package]
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
 -------------------
 No code:
 -> The hook 'some-hook-a':
@@ -82,14 +76,8 @@ Still no code:
 >     ---
 > Execution order:
 >     my-package.
-! LaTeX hooks Error: Cannot remove chunk 'my-package' from hook 'some-hook-b'
+LaTeX hooks Warning: Cannot remove chunk 'my-package' from hook 'some-hook-b'
 (hooks)              because it does not exist in that hook.
-Type <return> to continue.
- ...                                              
-l. ...\RemoveFromHook{some-hook-b}[my-package]
-LaTeX does not know anything more about this error, sorry.
-Try typing <return> to proceed.
-If that doesn't work, type X <return> to quit.
 -------------------
 No code:
 -> The hook 'some-hook-b':
diff --git a/support/test209.tex b/support/test209.tex
index 69ca4e09..79ff3d93 100644
--- a/support/test209.tex
+++ b/support/test209.tex
@@ -178,9 +178,10 @@
 \ExplSyntaxOn
 \AddToHook{shipout/before}
   {
+    \group_begin:
     \msg_redirect_name:nnn { hooks } { cannot-remove } { none }
     \RemoveFromHook{shipout/firstpage}[l3backend]
-    \msg_redirect_name:nnn { hooks } { cannot-remove } { error }
+    \group_end:
   }
 \ExplSyntaxOff
 % Load expl3 backend if necessary
diff --git a/support/test2e.tex b/support/test2e.tex
index 9f0913ea..402c8e8c 100644
--- a/support/test2e.tex
+++ b/support/test2e.tex
@@ -307,9 +307,10 @@ end
 \ExplSyntaxOn
 \AddToHook{shipout/before}
   {
+    \group_begin:
     \msg_redirect_name:nnn { hooks } { cannot-remove } { none }
     \RemoveFromHook{shipout/firstpage}[l3backend]
-    \msg_redirect_name:nnn { hooks } { cannot-remove } { error }
+    \group_end:
   }
 \ExplSyntaxOff
 % Load expl3 backend if necessary





More information about the latex3-commits mailing list.