[latex3-commits] [git/LaTeX3-latex3-latex3] master: Use deprecation system for \__prg_break: etc. (e68a578)
Bruno Le Floch
bruno at le-floch.fr
Sat Mar 31 20:40:41 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/e68a5783259bc7c58b3da8bb16b271a2f89108e8
>---------------------------------------------------------------
commit e68a5783259bc7c58b3da8bb16b271a2f89108e8
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Sat Mar 31 14:30:17 2018 -0400
Use deprecation system for \__prg_break: etc.
>---------------------------------------------------------------
e68a5783259bc7c58b3da8bb16b271a2f89108e8
l3kernel/l3basics.dtx | 34 ++++++++++++++++++++++++++++------
l3kernel/l3prg.dtx | 35 ++++++++++++++++++++++++-----------
2 files changed, 52 insertions(+), 17 deletions(-)
diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx
index 58d99c9..22d1525 100644
--- a/l3kernel/l3basics.dtx
+++ b/l3kernel/l3basics.dtx
@@ -2115,14 +2115,15 @@
%
% \begin{macro}{\__kernel_patch_deprecation:nnNNpn}
% \begin{macro}{\@@_deprecation_aux:nnNnn}
-% Grab a definition (at present, must be \cs{cs_new_protected:Npn}).
+% Grab a definition (at present, must be \cs{cs_new_protected:Npn} or \cs{cs_new:Npn}).
% Add to \cs{g_@@_deprecation_on_tl} some code that makes the
% defined macro |#3| outer (and defines it as an error). Add to
% \cs{g_@@_deprecation_off_tl} the definition itself. In both
% cases we undefine the token with \cs{tex_let:D} to avoid taking a
% potentially outer macro as the argument of some \pkg{expl3}
-% function. Finally define the macro itself to produce a warning then
-% redefine and call itself. The macro initially takes no parameters:
+% function. Finally, define the macro itself: if it is protected,
+% make it produce a warning then redefine and call itself. The macro
+% initially takes no parameters:
% together with the \texttt{x}-expanding assignment and \cs{exp_not:n}
% this gives a convenient way of storing the macro's definition in
% itself in order to only produce the warning once for each macro.
@@ -2134,11 +2135,18 @@
\cs_set_protected:Npn \__kernel_patch_deprecation:nnNNpn #1#2#3#4#5#
{
\if_meaning:w \cs_new_protected:Npn #3
+ \exp_after:wN \use_i:nn
\else:
- \__kernel_msg_error:nnx { kernel } { debug-unpatchable }
- { \token_to_str:N #3 ~(for~deprecation) }
+ \if_meaning:w \cs_new:Npn #3
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn
+ \else:
+ \__kernel_msg_error:nnx { kernel } { debug-unpatchable }
+ { \token_to_str:N #3 ~(for~deprecation) }
+ \exp_after:wN \exp_after:wN \exp_after:wN \use_none:nn
+ \fi:
\fi:
- \@@_deprecation_aux:nnNnn {#1} {#2} #4 {#5}
+ { \@@_deprecation_aux:nnNnn {#1} {#2} #4 {#5} }
+ { \@@_deprecation_expandable:nnNnn {#1} {#2} #4 {#5} }
}
\cs_set_protected:Npn \@@_deprecation_aux:nnNnn #1#2#3#4#5
{
@@ -2161,6 +2169,20 @@
\exp_not:N #3
}
}
+ \cs_set_protected:Npn \@@_deprecation_expandable:nnNnn #1#2#3#4#5
+ {
+ \tl_gput_right:Nn \g_@@_deprecation_on_tl
+ {
+ \tex_let:D #3 \scan_stop:
+ \__deprecation_error:Nnn #3 {#2} {#1}
+ }
+ \tl_gput_right:Nn \g_@@_deprecation_off_tl
+ {
+ \tex_let:D #3 \scan_stop:
+ \cs_set:Npn #3 #4 {#5}
+ }
+ \cs_new:Npn #3 #4 {#5}
+ }
}
{ \cs_set_protected:Npn \__kernel_patch_deprecation:nnNNpn #1#2 { } }
% \end{macrocode}
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index cecbd98..9cf39ce 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -1570,19 +1570,32 @@
% \begin{macro}[deprecated = 2019-12-31]{\@@_map_break:Nn}
% \begin{macro}[deprecated = 2019-12-31]{\@@_break:}
% \begin{macro}[deprecated = 2019-12-31]{\@@_break:n}
-% Made public, but used by a few third-parties.
+% Made public, but used by a few third-parties. It's not possible to
+% perfectly support a mixture of \cs{@@_map_break:Nn} and
+% \cs{prg_map_break:Nn} because they use different delimiters. The
+% following code only breaks if someone tries to break from two
+% \enquote{old-style} \cs{@@_map_break:Nn} \ldots{}
+% \cs{@@_break_point:Nn} mappings in one go. Basically, the
+% \cs{@@_map_break:Nn} converts a single \cs{@@_break_point:Nn} to
+% \cs{prg_break_point:Nn}, and that delimiter had better be the right
+% one. Then we call \cs{prg_map_break:Nn} which may end up breaking
+% intermediate looks in the (unbraced) argument |#1|. It is essential
+% to define the |break_point| functions before the corresponding
+% |break| functions: otherwise \cs{debug_on:n} |{deprecation}|
+% \cs{debug_off:n} |{deprecation}| would break when trying to restore
+% the definitions because they would involve deprecated commands whose
+% definition has not yet been restored.
% \begin{macrocode}
-\cs_new_eq:NN \@@_break_point:Nn \prg_break_point:Nn
+\__kernel_patch_deprecation:nnNNpn { 2019-12-31 } { \prg_break_point:Nn }
+\cs_new:Npn \@@_break_point:Nn { \prg_break_point:Nn }
+\__kernel_patch_deprecation:nnNNpn { 2019-12-31 } { \prg_break_point: }
\cs_new:Npn \@@_break_point: { \prg_break_point: }
-\cs_new:Npn \@@_map_break:Nn #1#2#3 \@@_break_point:Nn #4#5
- {
- #5
- \if_meaning:w #1 #4
- \exp_after:wN \use_iii:nnn
- \fi:
- \@@_map_break:Nn #1 {#2}
- }
-\cs_new:Npn \@@_break: { \prg_break: }
+\__kernel_patch_deprecation:nnNNpn { 2019-12-31 } { \prg_map_break:Nn }
+\cs_new:Npn \@@_map_break:Nn #1 \@@_break_point:Nn
+ { \prg_map_break:Nn #1 \prg_break_point:Nn }
+\__kernel_patch_deprecation:nnNNpn { 2019-12-31 } { \prg_break: }
+\cs_new:Npn \@@_break: #1 \@@_break_point: { }
+\__kernel_patch_deprecation:nnNNpn { 2019-12-31 } { \prg_break:n }
\cs_new:Npn \@@_break:n #1#2 \@@_break_point: {#1}
% \end{macrocode}
% \end{macro}
More information about the latex3-commits
mailing list