[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: Make non-expandable macros \protected (341206c3)
PhelypeOleinik
phelype.oleinik at latex-project.org
Sun Sep 20 19:03:29 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/341206c3cb8326d6406db133e6ee47b73e30a356
>---------------------------------------------------------------
commit 341206c3cb8326d6406db133e6ee47b73e30a356
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Sun Sep 20 14:03:29 2020 -0300
Make non-expandable macros \protected
>---------------------------------------------------------------
341206c3cb8326d6406db133e6ee47b73e30a356
base/ltshipout.dtx | 79 +++++++++++++++++++++++++-----------------------------
1 file changed, 37 insertions(+), 42 deletions(-)
diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx
index ed23c5e1..e0a38fc3 100644
--- a/base/ltshipout.dtx
+++ b/base/ltshipout.dtx
@@ -32,7 +32,7 @@
%
% \begin{macrocode}
\providecommand\ltshipoutversion{v1.0b}
-\providecommand\ltshipoutdate{2020/09/13}
+\providecommand\ltshipoutdate{2020/09/20}
% \end{macrocode}
%
%<*driver>
@@ -233,7 +233,7 @@
% \cs{AtBeginDvi} is the existing \LaTeXe{} interface to fill the
% \hook{shipout/firstpage} hook. This is not really a good name
% as it is not just supporting \texttt{.dvi} but also \texttt{.pdf}
-% output or \texttt{.dvx}.
+% output or \texttt{.xdv}.
%
% \cs{AtEndDvi} is the counterpart that was not available in the
% kernel but only through the package \pkg{atenddvi}. It fills the
@@ -531,11 +531,11 @@
% The box filled with the page to be shipped out (both L3 and
% \LaTeXe{} name).
% \begin{macrocode}
-\box_new:N \l_shipout_box
+\box_new:N \l_shipout_box
% \end{macrocode}
%
% \begin{macrocode}
-\cs_set_eq:NN \ShipoutBox \l_shipout_box
+\cs_new_eq:NN \ShipoutBox \l_shipout_box
% \end{macrocode}
% \end{macro}
%
@@ -547,7 +547,7 @@
% follows closely the ideas from \pkg{atbegshi}, so not
% documenting that here for now.
% \begin{macrocode}
-\cs_set:Npn\@@_execute: {
+\cs_new_protected:Npn \@@_execute: {
\tl_set:Nx \l_@@_group_level_tl
{ \int_value:w \tex_currentgrouplevel:D }
\tex_afterassignment:D \@@_execute_test_level:
@@ -572,14 +572,13 @@
% \end{macrocode}
% \end{macro}
%
-
%
% \begin{macro}{\@@_execute_test_level:}
% If the group level has changed then we are still constructing
% \cs{l_shipout_box} and to continue we need to wait until the
% current group has finished, hence the \cs{tex_aftergroup:D}.
% \begin{macrocode}
-\cs_new:Npn \@@_execute_test_level: {
+\cs_new_protected:Npn \@@_execute_test_level: {
\int_compare:nNnT
\l_@@_group_level_tl < \tex_currentgrouplevel:D
\tex_aftergroup:D
@@ -601,7 +600,7 @@
% case we don't reset the deadcyles, that would be up to the OR
% processing logic to do.}
% \begin{macrocode}
-\cs_new:Npn \@@_execute_cont: {
+\cs_new_protected:Npn \@@_execute_cont: {
\box_if_empty:NTF \l_shipout_box
{ \PackageWarning{ltshipout}{Ignoring~ void~ shipout~ box} }
{
@@ -786,7 +785,7 @@
% very beginning of the first box shipped out. After that we
% redefine it to do nothing on later pages.
% \begin{macrocode}
-\cs_new:Npn \@@_execute_firstpage_hook: {
+\cs_new_protected:Npn \@@_execute_firstpage_hook: {
% \end{macrocode}
% Adding something to the beginning means adding it to the
% background as that layer is done first in the output. Of course
@@ -801,7 +800,7 @@
% is never used again.
% \begin{macrocode}
\cs_gset_eq:NN \@@_execute_firstpage_hook: \prg_do_nothing:
- \cs_gset:Npn \@@_add_firstpage_material:Nn ##1 ##2 {
+ \cs_gset_protected:Npn \@@_add_firstpage_material:Nn ##1 ##2 {
\@latex at warning{
First~ page~ is~ already~ shipped~ out,~ ignoring\MessageBreak
\string##1 }
@@ -829,9 +828,8 @@
% once we are passed the first page it can be used to generate a
% warning message mentioning the right user command.
% \begin{macrocode}
-\cs_new:Npn \@@_add_firstpage_material:Nn #1#2 {
- \AddToHook{shipout/firstpage}{#2}
-}
+\cs_new_protected:Npn \@@_add_firstpage_material:Nn #1#2
+ { \AddToHook{shipout/firstpage}{#2} }
% \end{macrocode}
% \end{macro}
%
@@ -846,7 +844,7 @@
% \fmi{This could/should perhaps be generalized to set height depth and
% width given an arbitrary box.}
% \begin{macrocode}
-\cs_new:Npn \@@_get_box_size:N #1 {
+\cs_new_protected:Npn \@@_get_box_size:N #1 {
\dim_set:Nn \l_shipout_box_ht_dim { \box_ht:N #1 }
\dim_set:Nn \l_shipout_box_dp_dim { \box_dp:N #1 }
\dim_set:Nn \l_shipout_box_wd_dim { \box_wd:N #1 }
@@ -897,7 +895,7 @@
% here we are allow for other usage as well, in case some package
% has its own output routine.
% \begin{macrocode}
-\cs_new:Npn \@@_add_background_box:n #1
+\cs_new_protected:Npn \@@_add_background_box:n #1
{ \@@_get_box_size:N \l_shipout_box
% \end{macrocode}
% But we start testing for a vertical box as that should be the
@@ -990,7 +988,7 @@
% Foreground boxes are done in the same way, only the order and
% placement of boxes has to be done differently.
% \begin{macrocode}
-\cs_new:Npn \@@_add_foreground_box:n #1
+\cs_new_protected:Npn \@@_add_foreground_box:n #1
{
\box_if_vertical:NTF \l_shipout_box
{
@@ -1059,7 +1057,7 @@
% there might be updates in the preamble or even in the
% \hook{begindocument} hook that affects their setup.
% \begin{macrocode}
-\cs_new:Npn \@@_init_page_origins: {
+\cs_new_protected:Npn \@@_init_page_origins: {
\tl_const:Nx \c_@@_horigin_tl
{
\cs_if_exist_use:NTF \pdfvariable { horigin }
@@ -1087,7 +1085,7 @@
% \fmi{Could perhaps be generalized as it might be useful elsewhere. For
% now it is not.}
% \begin{macrocode}
-\cs_new:Npn \@@_picture_overlay:n #1 {
+\cs_new_protected:Npn \@@_picture_overlay:n #1 {
% \end{macrocode}
% The very first time this is executed we have ot initializes (and
% freeze) the origins.
@@ -1124,9 +1122,8 @@
% with its reference point in the top-left corner.
%
% \begin{macrocode}
-\cs_new:Npn \@@_add_background_picture:n #1 {
- \@@_add_background_box:n { \@@_picture_overlay:n {#1} }
-}
+\cs_new_protected:Npn \@@_add_background_picture:n #1
+ { \@@_add_background_box:n { \@@_picture_overlay:n {#1} } }
% \end{macrocode}
% \end{macro}
%
@@ -1137,9 +1134,8 @@
% Put a \texttt{picture} env in the foreground of the shipout box
% with its reference point in the top-left corner.
% \begin{macrocode}
-\cs_new:Npn \@@_add_foreground_picture:n #1 {
- \@@_add_foreground_box:n { \@@_picture_overlay:n {#1} }
-}
+\cs_new_protected:Npn \@@_add_foreground_picture:n #1
+ { \@@_add_foreground_box:n { \@@_picture_overlay:n {#1} } }
% \end{macrocode}
% \end{macro}
%
@@ -1151,9 +1147,8 @@
% (in case \LaTeX{} looks ahead and is not using the position for
% on the next page).
% \begin{macrocode}
-\cs_new:Npn \shipout_discard: {
- \bool_gset_true:N \g_@@_discard_bool
-}
+\cs_new_protected:Npn \shipout_discard:
+ { \bool_gset_true:N \g_@@_discard_bool }
% \end{macrocode}
% \end{macro}
%
@@ -1235,7 +1230,7 @@
%
% \begin{macro}{\@kernel at after@enddocument}
% \begin{macrocode}
-\g at addto@macro \@kernel at after@enddocument {
+\tl_gput_right:Nn \@kernel at after@enddocument {
\int_compare:nNnT \@abspage at last = \maxdimen
{
% \end{macrocode}
@@ -1253,7 +1248,7 @@
% that in the \texttt{.aux} file for the next run.
%
% \begin{macrocode}
-\g at addto@macro \@kernel at after@enddocument at afterlastpage {
+\tl_gput_right:Nn \@kernel at after@enddocument at afterlastpage {
% \end{macrocode}
% There is one special case: If no output is produced then there is
% no point in a) recording the number as 0 will never match the
@@ -1324,7 +1319,7 @@
% \begin{macro}{\@@_excuse_extra_page:}
% Say mea culpa \ldots
% \begin{macrocode}
-\cs_new:Npn \@@_excuse_extra_page: {
+\cs_new_protected:Npn \@@_excuse_extra_page: {
\vfil
\begin{center}
\bfseries Temporary~ page!
@@ -1379,7 +1374,7 @@
% \begin{macro}{\AtBeginDvi}
%
% \begin{macrocode}
-\DeclareRobustCommand \AtBeginDvi {\@@_add_firstpage_material:Nn \AtBeginDvi}
+\cs_new_protected:Npn \AtBeginDvi { \@@_add_firstpage_material:Nn \AtBeginDvi }
% \end{macrocode}
% \end{macro}
%
@@ -1409,27 +1404,27 @@
% Some internals needed elsewhere.
%
% \begin{macrocode}
-\cs_set_eq:NN \@expl@@@shipout at add@firstpage at material@@Nn
+\cs_new_eq:NN \@expl@@@shipout at add@firstpage at material@@Nn
\__shipout_add_firstpage_material:Nn
% \end{macrocode}
%
% \begin{macrocode}
-\cs_set_eq:NN \@expl@@@shipout at add@background at box@@n
+\cs_new_eq:NN \@expl@@@shipout at add@background at box@@n
\__shipout_add_background_box:n
% \end{macrocode}
%
% \begin{macrocode}
-\cs_set_eq:NN \@expl@@@shipout at add@foreground at box@@n
+\cs_new_eq:NN \@expl@@@shipout at add@foreground at box@@n
\__shipout_add_foreground_box:n
% \end{macrocode}
%
% \begin{macrocode}
-\cs_set_eq:NN \@expl@@@shipout at add@background at picture@@n
+\cs_new_eq:NN \@expl@@@shipout at add@background at picture@@n
\__shipout_add_background_picture:n
% \end{macrocode}
%
% \begin{macrocode}
-\cs_set_eq:NN \@expl@@@shipout at add@foreground at picture@@n
+\cs_new_eq:NN \@expl@@@shipout at add@foreground at picture@@n
\__shipout_add_foreground_picture:n
% \end{macrocode}
% \end{macro}
@@ -1530,7 +1525,7 @@
%<latexrelease>\IncludeInRelease{2020/10/01}%
%<latexrelease> {\AtEndDvi}{atenddvi emulation}%
\ExplSyntaxOn
-\cs_new:Npn \AtEndDvi {\AddToHook{shipout/lastpage}}
+\cs_new_protected:Npn \AtEndDvi {\AddToHook{shipout/lastpage}}
\ExplSyntaxOff
% \end{macrocode}
% As the package is integrate we prevent loading (no need to roll that back):
@@ -1597,8 +1592,8 @@
% \begin{macro}{\AtBeginShipout,\AtBeginShipoutNext}
% Filling hooks
% \begin{macrocode}
-\def \AtBeginShipout {\AddToHook{shipout/before}}
-\def \AtBeginShipoutNext {\AddToHookNext{shipout/before}}
+\protected \def \AtBeginShipout {\AddToHook{shipout/before}}
+\protected \def \AtBeginShipoutNext {\AddToHookNext{shipout/before}}
% \end{macrocode}
% \end{macro}
%
@@ -1607,7 +1602,7 @@
% Slightly more complex as we need to know the name of the command under which the
% \hook{shipout/firstpage} hook is filled.
% \begin{macrocode}
-\def \AtBeginShipoutFirst
+\protected \def \AtBeginShipoutFirst
{\@expl@@@shipout at add@firstpage at material@@Nn \AtBeginShipoutFirst}
% \end{macrocode}
% \end{macro}
@@ -1687,8 +1682,8 @@
% \begin{macro}{\EveryShipout,\AtNextShipout}
% This package has only two public commands so simulating it is easy:
% \begin{macrocode}
-\def \EveryShipout {\AddToHook{shipout/before}}
-\def \AtNextShipout {\AddToHookNext{shipout/before}}
+\protected \def \EveryShipout {\AddToHook{shipout/before}}
+\protected \def \AtNextShipout {\AddToHookNext{shipout/before}}
% \end{macrocode}
% \end{macro}
%
More information about the latex3-commits
mailing list.