[latex3-commits] [git/LaTeX3-latex3-latex2e] lthooks2: integrating/emulating everyshi and atenddvi (674f72d8)

Frank Mittelbach frank.mittelbach at latex-project.org
Mon Aug 17 00:23:42 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : lthooks2
Link       : https://github.com/latex3/latex2e/commit/674f72d8eba0a9445fbe54d2655be6ca820187f9

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

commit 674f72d8eba0a9445fbe54d2655be6ca820187f9
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Mon Aug 17 00:23:42 2020 +0200

    integrating/emulating everyshi and atenddvi


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

674f72d8eba0a9445fbe54d2655be6ca820187f9
 base/ltfilehook.dtx                                | 16 +++++
 base/ltfinal.dtx                                   | 18 +++--
 base/lthooks.dtx                                   |  3 +-
 base/lthooks.ins                                   |  5 +-
 base/ltshipout.dtx                                 | 82 ++++++++++++++++------
 base/source2edoc.cls                               | 14 ++--
 base/testfiles-lthooks/shipout-000.lvt             |  1 -
 base/testfiles-lthooks2/shipout-emulations.lvt     | 47 +++++++++++++
 .../shipout-emulations.tlg}                        | 28 +++++++-
 9 files changed, 174 insertions(+), 40 deletions(-)

diff --git a/base/ltfilehook.dtx b/base/ltfilehook.dtx
index fe08ab4f..8375a9a6 100644
--- a/base/ltfilehook.dtx
+++ b/base/ltfilehook.dtx
@@ -1400,6 +1400,22 @@
 %    kernel will not provide any.
 %
 %
+%    Only temp before integration
+%    \begin{macrocode}
+\disable at package@load{atenddvi}
+   {\PackageWarning{atenddvi}
+     {Functionality of this package is already\MessageBreak
+      provided by LaTeX.\MessageBreak\MessageBreak
+      It is there no longer necessary to load it\MessageBreak
+      and you can safely remove it.\MessageBreak
+      Found on}}
+%    \end{macrocode}
+%
+%    Only temp before integration
+%    \begin{macrocode}
+\declare at file@substitution{everyshi.sty}{everyshi-ltx.sty}
+%    \end{macrocode}
+%
 %
 %    \begin{macrocode}
 %</2ekernel>
diff --git a/base/ltfinal.dtx b/base/ltfinal.dtx
index 5a01f852..e3b8cbf9 100644
--- a/base/ltfinal.dtx
+++ b/base/ltfinal.dtx
@@ -1256,12 +1256,22 @@
 %<latexrelease>
 %<latexrelease>\expandafter\let\csname ver at atbegshi.sty\endcsname \@undefined
 %<latexrelease>
-%<latexrelease>\let \EveryShipout \@undefined
-%<latexrelease>\let \AtNextShipout \@undefined
-%<latexrelease>\expandafter \let \csname ver at everyshi.sty\endcsname \@undefined
+%<latexrelease>
+%    \end{macrocode}
+%    We do not undo a substitution when rolling back. As the file
+%    support gets undone the underlying data is no longer (and
+%    sufficiently obscure that should not interfer with existing
+%    commands and properly removing it would mean we need to make the
+%    \cs{unclare at ...} and its support macros available in all earlier
+%    kernel releases which is pointless (and actually worse).
+%    \begin{macrocode}
+%\undeclare at file@substitution{everyshi.sty}{everyshi-ltx.sty}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
 %<latexrelease>
 %<latexrelease>\let  \AtEndDvi \@undefined
-%<latexrelease>\expandafter\let \csname ver at atenddvi.sty\endcsname \@undefined
+%<latexrelease>\enable at package@load{atenddvi}
 %<latexrelease>
 %<latexrelease>\AtBeginDocument{\reinstall at nfss@defs\init at series@setup}
 %<latexrelease>
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 233c7c1b..bf7c8149 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -3725,7 +3725,7 @@
 \newcommand\AtVeryEndDocument {\AddToHook{enddocument/afteraux}}
 %    \end{macrocode}
 %    Next one is a bit of a fake, but the result should normally be as
-%    expected. If not one needs to add a rule to sort the code chunks
+%    expected. If not, one needs to add a rule to sort the code chunks
 %    in \hook{enddocument/info}.
 %    \begin{macrocode}
 \newcommand\AtEndAfterFileList{\AddToHook{enddocument/info}}
@@ -3753,6 +3753,7 @@
 %    \end{macrocode}
 %  \end{macro}
 %
+%
 %    \begin{macrocode}
 %</2ekernel>
 %    \end{macrocode}
diff --git a/base/lthooks.ins b/base/lthooks.ins
index c1816324..fcb7b4ce 100644
--- a/base/lthooks.ins
+++ b/base/lthooks.ins
@@ -62,10 +62,11 @@ where one can also log issues in case there are any.
 
 \generate{\file{lthooks.ltx}{\from{lthooks.dtx}{2ekernel}}}       % only for lthooks.sty
 \generate{\file{ltshipout.ltx}{\from{ltshipout.dtx}{2ekernel}}}   % only for lthooks.sty
+\generate{\file{ltfilehook.ltx}{\from{ltfilehook.dtx}{2ekernel}}}
 
-\generate{\file{atenddvi-integrated.sty}{\from{ltshipout.dtx}{atenddvi}}}
 
-\generate{\file{ltfilehook.ltx}{\from{ltfilehook.dtx}{2ekernel}}}
+\generate{\file{everyshi-ltx.sty}{\from{ltshipout.dtx}{everyshi-ltx}}} % emulating everyshi
+
 
 
 \generate{\file{structuredlog.sty}{\from{ltfilehook.dtx}{structuredlog}}}
diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx
index 533b20ff..629d9d26 100644
--- a/base/ltshipout.dtx
+++ b/base/ltshipout.dtx
@@ -736,7 +736,7 @@
 %    \begin{macrocode}
   \cs_gset_eq:NN \@@_execute_firstpage_hook: \prg_do_nothing:
   \cs_gset:Npn \@@_add_firstpage_material:Nn ##1 ##2 {
-    \PackageWarning{ltshipout}{
+    \@latex at warning{
         First~ page~ is~ already~ shipped~ out,~ ignoring\MessageBreak
         \string##1 }
   }
@@ -1287,7 +1287,7 @@
 %  \begin{macro}{\AtBeginDvi}
 %    
 %    \begin{macrocode}
-\newcommand \AtBeginDvi {\@@_add_firstpage_material:Nn \AtBeginDvi}
+\DeclareRobustCommand \AtBeginDvi {\@@_add_firstpage_material:Nn \AtBeginDvi}
 %    \end{macrocode}
 %  \end{macro}
 
@@ -1391,23 +1391,7 @@
 %    \begin{macrocode}
 \@namedef {ver at atbegshi.sty}{2020/10/01}
 %    \end{macrocode}
-
-
-
-% \subsection{Package \pkg{everyshi} emulation}
-%
-%  \begin{macro}{\EveryShipout,\AtNextShipout}
-%    This package has only two public commands to simulating it is easy:
-%    \begin{macrocode}
-\cs_new_eq:NN\EveryShipout\AtBeginShipout
-\cs_new_eq:NN\AtNextShipout\AtBeginShipoutNext
-%    \end{macrocode}
-%  \end{macro}
 %
-%    \begin{macrocode}
-\expandafter\cs_set_eq:NN\csname ver at everyshi.sty\endcsname\fmtversion
-\@namedef {ver at everyshi.sty}{2020/10/01}
-%    \end{macrocode}
 %
 %
 % \subsection{Package \pkg{atenddvi} emulation}
@@ -1423,9 +1407,10 @@
 %
 %
 %    \begin{macrocode}
-%\disable at packageload{atenddvi}
-   {\PackageWarning{atenddvi}{Functionality provided by LaTeX.
-       Package is no longer necessary}}
+%\disable at package@load{atenddvi}
+%   {\PackageWarning{atenddvi}{Functionality already provided by
+%          LaTeX.\Messagebreak
+%         Package is no longer necessary, you can safely remove it}}
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -1434,6 +1419,61 @@
 %    \end{macrocode}
 %
 %
+% \subsection{Package \pkg{everyshi} emulation}
+%
+%  \begin{macro}{\EveryShipout,\AtNextShipout}
+%    This package has only two public commands so simulating it is easy:
+%    \begin{macrocode}
+%<*everyshi-ltx>
+\ProvidesPackage{everyshi}
+   [2020/08/16 v1.0a
+    Emulation of the original everyshi package^^Jwith kernel methods]
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\let\EveryShipout\AtBeginShipout
+\let\AtNextShipout\AtBeginShipoutNext
+%    \end{macrocode}
+%    This is one difference between \pkg{everyshi} and the kernel
+%    implementation, the latter does not directly use box 255.
+%
+%    For usage by ordinary users this makes no difference but of a
+%    package use complicated code together with \pkg{everyshi} and
+%    directly manipulates box 255 then this package needs updating.
+%    In most cases the updates are simple because the kernel offers
+%    hooks that makes such complicated code unnecessary.
+%
+%    We therefore add a little file into the adjusted package
+%    \begin{macrocode}
+%%
+%%   In normal circumstances the above emulation is sufficient and in
+%%   all known packages (we know of) that use everyshi it either works or
+%%   the packages have been adjusted. 
+%%
+%%   Code that directly manipulates box 255, however, might fail. 
+%%   If that is the case look at the shipout hooks offered now as
+%%   they are normally sufficienct to avoid such minpulations (or
+%%   replace box 255 with \ShipoutBox in the code.
+%%
+%</everyshi-ltx>
+%    \end{macrocode}
+%    
+%  \end{macro}
+%
+%    \begin{macrocode}
+%<*2ekernel>
+\PackageWarning{everyshi}{Functionality~ provided~ by~ LaTeX.~
+                          Package~ is~ no~ longer~ necessary~ and~
+                          you~ can~ safely~ remove~ it}
+%</2ekernel>
+%    \end{macrocode}
+
+%    \begin{macrocode}
+%\declare at file@substitution{everyshi.sty}{everyshi-ltx.sty}
+%    \end{macrocode}
+%
+%
+%
 %    Rather important :-)
 %    \begin{macrocode}
 %<@@=>
diff --git a/base/source2edoc.cls b/base/source2edoc.cls
index 00574952..f9b1dd6a 100644
--- a/base/source2edoc.cls
+++ b/base/source2edoc.cls
@@ -1,19 +1,17 @@
 
 % This class is buggy and needs fixing
 
-%\ProvidesClass{source2edoc}
-%              [2020/08/16 v0.1 Quick hack to typeset source2.tex
-%               (not usable for anything else and buggy -- will vanish again)!]
+\ProvidesClass{source2edoc}
+              [2020/08/16 v0.1 Quick hack to typeset source2.tex
+               (not usable for anything else and buggy -- will vanish again)!]
 
 \LoadClass{l3doc}
 
-\RemoveFromHook{begindocument}[l3doc]
-\AddToHook{begindocument}{\MakeShortVerb \|}
+\RemoveFromHook{begindocument}[l3doc]          % drop the standard setting  making " a shortverb
+\AddToHook{begindocument}{\MakeShortVerb \|}   % but readd | as one
 
 %\ShowHook{begindocument}
 
-\typeout{========== catcode of @:\the\catcode`\@ }   % why is @ catcode 12?
-\makeatletter
 
 \def\partname{File}
 \renewcommand*{\DocInclude}[1]{%
@@ -198,7 +196,5 @@ Bug reports can be opened (category \texttt{#1}) at\\%
                      *************************************}}
            {}
 
-%\errorstopmode
-\batchmode
 
 \endinput
diff --git a/base/testfiles-lthooks/shipout-000.lvt b/base/testfiles-lthooks/shipout-000.lvt
index 5804c7b7..bd2bda8d 100644
--- a/base/testfiles-lthooks/shipout-000.lvt
+++ b/base/testfiles-lthooks/shipout-000.lvt
@@ -13,6 +13,5 @@
 \START
 
 \usepackage{atbegshi}
-\usepackage{everyshi}
 
 \END
diff --git a/base/testfiles-lthooks2/shipout-emulations.lvt b/base/testfiles-lthooks2/shipout-emulations.lvt
new file mode 100644
index 00000000..2a64b9a5
--- /dev/null
+++ b/base/testfiles-lthooks2/shipout-emulations.lvt
@@ -0,0 +1,47 @@
+% testing atbegshi etc emulation
+
+\RequirePackage[enable-debug]{expl3}
+
+\documentclass{article}
+
+\input{regression-test}
+
+% dummies for the regression test suite (not search the tree
+\begin{filecontents}{everyshi.sty}
+\typeout{Only a dumy for everyshi}
+\end{filecontents}
+
+\begin{filecontents}{atenddvi.sty}
+\typeout{Only a dumy for atenddvi}
+\end{filecontents}
+
+\DebugShipoutsOn
+
+\START
+
+\usepackage{everyshi}   % should substitude silently
+\usepackage{atenddvi}   % should give warning
+
+\EveryShipout{\typeout{Shown on every page}}
+
+\AtBeginDvi{\typeout{Does this typeout show up at the beginning?}}
+\AtEndDvi  {\typeout{Does this typeout show up at the end?}}
+
+\begin{document}
+
+Page 1
+
+\newpage
+
+\AtBeginDvi{\typeout{And what about this? It should not!}}
+\AtNextShipout{\typeout{Shown on the next page only}}
+
+Page 2
+
+\newpage
+
+Page 3
+
+\newpage
+
+\end{document}
diff --git a/base/testfiles-disabled/lthooks2-003.tlg b/base/testfiles-lthooks2/shipout-emulations.tlg
similarity index 51%
copy from base/testfiles-disabled/lthooks2-003.tlg
copy to base/testfiles-lthooks2/shipout-emulations.tlg
index 3e824a24..fe7a54c4 100644
--- a/base/testfiles-disabled/lthooks2-003.tlg
+++ b/base/testfiles-lthooks2/shipout-emulations.tlg
@@ -1,6 +1,16 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
-(lthooks2-003.aux)
+(everyshi-ltx.sty
+Package: everyshi ....-..-.. v... Emulation of the original everyshi package
+with kernel methods
+)
+Package atenddvi Warning: Functionality of this package is already
+(atenddvi)                provided by LaTeX.
+(atenddvi)                
+(atenddvi)                It is there no longer necessary to load it
+(atenddvi)                and you can safely remove it.
+(atenddvi)                Found on on input line ....
+(shipout-emulations.aux)
 LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line ....
 LaTeX Font Info:    ... okay on input line ....
 LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line ....
@@ -15,5 +25,19 @@ LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line ....
 LaTeX Font Info:    ... okay on input line ....
 LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line ....
 LaTeX Font Info:    ... okay on input line ....
+Shown on every page
+Absolute page = 1 (target: 3)
+Does this typeout show up at the beginning?
 [1
-] (lthooks2-003.aux)
+]
+LaTeX Warning: First page is already shipped out, ignoring
+               \AtBeginDvi on input line ....
+Shown on every page
+Shown on the next page only
+Absolute page = 2 (target: 3)
+[2]
+Shown on every page
+Absolute page = 3 (target: 3)
+Executing lastpage hook on page 3
+Does this typeout show up at the end?
+[3] (shipout-emulations.aux)





More information about the latex3-commits mailing list.