[latex3-commits] [git/LaTeX3-latex3-latex3] master: Properly mark renamed primitives as deprecated (ac331a1)
Bruno Le Floch
bruno at le-floch.fr
Sat May 5 14:32:14 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/ac331a12bc4aa30dbf0440a824e9840f00746e31
>---------------------------------------------------------------
commit ac331a12bc4aa30dbf0440a824e9840f00746e31
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Sat May 5 14:32:14 2018 +0200
Properly mark renamed primitives as deprecated
This means \debug_on:n { deprecation } can be used to detect uses
of primitives under their old names in packages.
>---------------------------------------------------------------
ac331a12bc4aa30dbf0440a824e9840f00746e31
l3kernel/l3deprecation.dtx | 64 ++++++++++++++++++++++++
l3kernel/l3names.dtx | 10 ++++
l3kernel/l3obsolete.txt | 7 +++
l3kernel/testfiles/m3deprecation001.luatex.tlg | 47 +++++++++++++++++
l3kernel/testfiles/m3deprecation001.lvt | 9 ++++
l3kernel/testfiles/m3deprecation001.tlg | 47 +++++++++++++++++
l3kernel/testfiles/m3expl001.luatex.tlg | 2 +
l3kernel/testfiles/m3expl001.ptex.tlg | 2 +
l3kernel/testfiles/m3expl001.tlg | 2 +
l3kernel/testfiles/m3expl001.uptex.tlg | 2 +
l3kernel/testfiles/m3expl001.xetex.tlg | 2 +
l3kernel/testfiles/m3expl003.luatex.tlg | 2 +
l3kernel/testfiles/m3expl003.ptex.tlg | 2 +
l3kernel/testfiles/m3expl003.tlg | 2 +
l3kernel/testfiles/m3expl003.uptex.tlg | 2 +
l3kernel/testfiles/m3expl003.xetex.tlg | 2 +
16 files changed, 204 insertions(+)
diff --git a/l3kernel/l3deprecation.dtx b/l3kernel/l3deprecation.dtx
index 72893f5..2e8d69c 100644
--- a/l3kernel/l3deprecation.dtx
+++ b/l3kernel/l3deprecation.dtx
@@ -176,6 +176,70 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[deprecated = 2019-12-31]{\etex_beginL:D}
+% \begin{macro}{\@@_primitive:NN, \@@_primitive:w}
+% We renamed all primitives to \cs[no-index]{tex_\ldots{}:D} so all
+% others are deprecated. In \pkg{l3names}, \cs{__kernel_primitives:}
+% is defined to contain \cs{__kernel_primitive:NN} \cs{beginL}
+% \cs{etex_beginL:D} and so on, one for each deprecated primitive. We
+% apply \cs{exp_not:N} to the second argument of
+% \cs{__kernel_primitive:NN} because it may be outer (both when doing
+% and undoing deprecation actually), then \cs{@@_primitive:NN} uses
+% \cs{tex_let:D} to change the meaning of this potentially outer
+% token. Then, either turn it into an error or make it equal to the
+% primitive~|#1|. To be more precise, |#1| may not be defined, so try
+% a \cs[no-index]{tex_\ldots{}:D} command as well.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_primitive:NN #1#2 { }
+\exp_last_unbraced:NNNNo
+ \cs_new:Npn \@@_primitive:w #1 { \token_to_str:N _ } { }
+\__kernel_deprecation_code:nn
+ {
+ \cs_set_protected:Npn \__kernel_primitive:NN #1
+ {
+ \exp_after:wN \@@_primitive:NN
+ \exp_after:wN #1
+ \exp_not:N
+ }
+ \cs_set_protected:Npn \@@_primitive:NN #1#2
+ {
+ \tex_let:D #2 \scan_stop:
+ \exp_args:NNx \__kernel_deprecation_error:Nnn #2
+ {
+ \iow_char:N \\
+ \cs_if_exist:NTF #1
+ { \cs_to_str:N #1 }
+ {
+ tex_
+ \exp_last_unbraced:Nf
+ \@@_primitive:w { \cs_to_str:N #2 }
+ }
+ }
+ { 2019-12-31 }
+ }
+ \__kernel_primitives:
+ }
+ {
+ \cs_set_protected:Npn \__kernel_primitive:NN #1
+ {
+ \exp_after:wN \@@_primitive:NN
+ \exp_after:wN #1
+ \exp_not:N
+ }
+ \cs_set_protected:Npn \@@_primitive:NN #1#2
+ {
+ \tex_let:D #2 #1
+ \cs_if_exist:cT { tex_ \cs_to_str:N #1 :D }
+ {
+ \exp_args:NNc \cs_set_eq:NN #2
+ { tex_ \cs_to_str:N #1 :D }
+ }
+ }
+ \__kernel_primitives:
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}
diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index 44efbef..2f1365d 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1358,6 +1358,9 @@
% becomes very tricky with multiple parallel engine developments, so has been
% dropped. To cover the transition, we provide the older names here for a
% limited period (until the end of 2019).
+%
+% To allow \cs{debug_on:n} \Arg{deprecation} to work we save the list of
+% primitives into \cs{@@_primitives:}
% \begin{macrocode}
%<*package>
\tex_begingroup:D
@@ -1370,6 +1373,10 @@
\tex_fi:D
\use_none:n { \tex_global:D \tex_let:D #2 #1 }
}
+ \tex_xdef:D \@@_primitives:
+ {
+ \tex_unexpanded:D
+ {
\@@_primitive:NN \beginL \etex_beginL:D
\@@_primitive:NN \beginR \etex_beginR:D
\@@_primitive:NN \botmarks \etex_botmarks:D
@@ -1984,6 +1991,9 @@
\@@_primitive:NN \ucs \uptex_ucs:D
\@@_primitive:NN \uptexrevision \uptex_uptexrevision:D
\@@_primitive:NN \uptexversion \uptex_uptexversion:D
+ }
+ }
+ \@@_primitives:
\tex_endgroup:D
%</package>
% \end{macrocode}
diff --git a/l3kernel/l3obsolete.txt b/l3kernel/l3obsolete.txt
index 85cef93..4d809e0 100644
--- a/l3kernel/l3obsolete.txt
+++ b/l3kernel/l3obsolete.txt
@@ -20,6 +20,7 @@ Function Expires end
\box_resize:Nnn 2018
\box_use_clear:c 2018
\box_use_clear:N 2018
+\etex_....:D 2019
\file_add_path:nN 2018
\file_list: 2018
\file_path_include:n 2018
@@ -29,13 +30,19 @@ Function Expires end
\ior_log_streams: 2018
\iow_list_streams: 2018
\iow_log_streams: 2018
+\luatex_...:D 2019
+\pdftex_...:D 2019
+\ptex_...:D 2019
\sort_ordered: 2018
\sort_reversed: 2018
\tl_show_analysis:N 2019
\tl_show_analysis:n 2019
\token_new:Nn 2018
+\uptex_...:D 2019
+\utex_...:D 2019
Variants of n into N/c 2018
Variants of N into n/o/V/v/f/x 2018
+\xetex_...:D 2019
--------------------------------------
Removed functions and variables
diff --git a/l3kernel/testfiles/m3deprecation001.luatex.tlg b/l3kernel/testfiles/m3deprecation001.luatex.tlg
index 64e5fae..8c34217 100644
--- a/l3kernel/testfiles/m3deprecation001.luatex.tlg
+++ b/l3kernel/testfiles/m3deprecation001.luatex.tlg
@@ -319,3 +319,50 @@ l. ...\tl_to_lowercase:n
| If that doesn't work, type X <return> to quit.
|...............................................
Gg
+\c_backslash_str
+Runaway text?
+! Forbidden control sequence found while scanning text of \tex_message:D.
+<inserted text>
+}
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+I suspect you have forgotten a `}', causing me
+to read past where you wanted me to stop.
+I'll try to recover; but if the error is serious,
+you'd better type `E' or `X' now and fix your file.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ The deprecated command '\etex_unexpanded:D' has been or will be
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/deprecated-command"
+!
+! The deprecated command '\etex_unexpanded:D' has been or will be removed on
+!
+! See the LaTeX3 documentation for further information.
+!
+! Type <return> to continue.
+!...............................................
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| 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.
+|...............................................
+! Extra }, or forgotten \endgroup.
+l. ...... { \etex_unexpanded:D { \c_backslash_str } }
+I've deleted a group-closing symbol because it seems to be
+spurious, as in `$x}$'. But perhaps the } is legitimate and
+you forgot something else, as in `\hbox{$x}'. In such cases
+the way to recover is to insert both the forgotten and the
+deleted material, e.g., by typing `I$}'.
+\c_backslash_str
diff --git a/l3kernel/testfiles/m3deprecation001.lvt b/l3kernel/testfiles/m3deprecation001.lvt
index a40ca44..0963faa 100644
--- a/l3kernel/testfiles/m3deprecation001.lvt
+++ b/l3kernel/testfiles/m3deprecation001.lvt
@@ -27,4 +27,13 @@
\group_end:
\tl_to_lowercase:n { \TYPE { Gg } }
+\hbox_set:Nw \l_tmpa_box % avoid "missing begin document" errors
+ \group_begin:
+ \tex_message:D { \etex_unexpanded:D { \c_backslash_str } }
+ \debug_on:n { deprecation }
+ \tex_message:D { \etex_unexpanded:D { \c_backslash_str } }
+ \group_end:
+ \tex_message:D { \etex_unexpanded:D { \c_backslash_str } }
+\hbox_set_end:
+
\END
diff --git a/l3kernel/testfiles/m3deprecation001.tlg b/l3kernel/testfiles/m3deprecation001.tlg
index 0a1ca02..192333e 100644
--- a/l3kernel/testfiles/m3deprecation001.tlg
+++ b/l3kernel/testfiles/m3deprecation001.tlg
@@ -319,3 +319,50 @@ l. ...\tl_to_lowercase:n
| If that doesn't work, type X <return> to quit.
|...............................................
Gg
+\c_backslash_str
+Runaway text?
+! Forbidden control sequence found while scanning text of \tex_message:D.
+<inserted text>
+ }
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+I suspect you have forgotten a `}', causing me
+to read past where you wanted me to stop.
+I'll try to recover; but if the error is serious,
+you'd better type `E' or `X' now and fix your file.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ The deprecated command '\etex_unexpanded:D' has b...
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/deprecated-command"
+!
+! The deprecated command '\etex_unexpanded:D' has been or will be removed on
+!
+! See the LaTeX3 documentation for further information.
+!
+! Type <return> to continue.
+!...............................................
+l. ... \tex_message:D { \etex_unexpanded:D
+ { \c_backslash_str } }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| 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.
+|...............................................
+! Extra }, or forgotten \endgroup.
+l. ...... \etex_unexpanded:D { \c_backslash_str } }
+I've deleted a group-closing symbol because it seems to be
+spurious, as in `$x}$'. But perhaps the } is legitimate and
+you forgot something else, as in `\hbox{$x}'. In such cases
+the way to recover is to insert both the forgotten and the
+deleted material, e.g., by typing `I$}'.
+\c_backslash_str
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index d1ac3cc..e888370 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5993,6 +5993,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index d565f92..dbcfd89 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5990,6 +5990,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 17623c4..e40a2c4 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6191,6 +6191,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 6335bdf..b671ee9 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6189,6 +6189,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index e461b7a..cb0e879 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5960,6 +5960,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index d1ac3cc..e888370 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5993,6 +5993,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index d565f92..dbcfd89 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5990,6 +5990,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 17623c4..e40a2c4 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6191,6 +6191,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 6335bdf..b671ee9 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6189,6 +6189,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index e461b7a..cb0e879 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5960,6 +5960,8 @@ Defining \peek_N_type:TF on line ...
Defining \peek_N_type:T on line ...
Defining \peek_N_type:F on line ...
Defining \__kernel_deprecation_error:Nnn on line ...
+Defining \__deprecation_primitive:NN on line ...
+Defining \__deprecation_primitive:w on line ...
)
Defining message LaTeX/expl/wrong-driver on line ...
Defining \l__expl_driver_tl on line ...
More information about the latex3-commits
mailing list