[latex3-commits] [git/LaTeX3-latex3-latex2e] firstaid: readd filehook-ltx for now (e33442eb)

Frank Mittelbach frank.mittelbach at latex-project.org
Tue Sep 29 15:19:19 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : firstaid
Link       : https://github.com/latex3/latex2e/commit/e33442eb1735df9c95b8cfc642e33ba08af0a75a

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

commit e33442eb1735df9c95b8cfc642e33ba08af0a75a
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Tue Sep 29 15:19:19 2020 +0200

    readd filehook-ltx for now


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

e33442eb1735df9c95b8cfc642e33ba08af0a75a
 base/testfiles-lthooks/filehook-001.lvt            |   5 +-
 base/testfiles-lthooks/filehook-001.tlg            |   7 ++
 .../latex2e-first-aid-for-external-files.dtx       | 139 +++++++++++++++++++++
 3 files changed, 150 insertions(+), 1 deletion(-)

diff --git a/base/testfiles-lthooks/filehook-001.lvt b/base/testfiles-lthooks/filehook-001.lvt
index dc073319..58ec9735 100644
--- a/base/testfiles-lthooks/filehook-001.lvt
+++ b/base/testfiles-lthooks/filehook-001.lvt
@@ -5,8 +5,11 @@
 \makeatletter
 \declare at file@substitution{filehook.sty}{filehook-ltx.sty}
 \makeatother
+
+\START
 \RequirePackage{filehook}
 
+\OMIT
 \def\Hook#1{\ifx#1\undefined
    \typeout{Not defined: \string#1}%
  \else #1{\typeout{\string#1 - code (for \CurrentFile)}}\fi}
@@ -37,7 +40,7 @@
 \includeonly{\jobname-x,baz with.tex and spaces,bar}  % baz excluded
 
 
-\START
+\TIMO
 
 \Hook\AtBeginOfEveryFile
 \Hook\AtEndOfEveryFile
diff --git a/base/testfiles-lthooks/filehook-001.tlg b/base/testfiles-lthooks/filehook-001.tlg
index 21c78460..4516877d 100644
--- a/base/testfiles-lthooks/filehook-001.tlg
+++ b/base/testfiles-lthooks/filehook-001.tlg
@@ -1,5 +1,12 @@
 This is a generated file for the l3build validation system.
 Don't change this file in any respect.
+(filehook-ltx.sty
+LaTeX3 Info: Defining command \AtBeginOfPackageFile with sig. 'smm' on line
+(LaTeX3)     64.
+LaTeX3 Info: Defining command \AtEndOfPackageFile with sig. 'smm' on line ...
+LaTeX3 Info: Defining command \AtBeginOfClassFile with sig. 'smm' on line ...
+LaTeX3 Info: Defining command \AtEndOfClassFile with sig. 'smm' on line ...
+)
 Not defined: \AtBeginOfFiles
 Not defined: \AtEndOfFiles
 Not defined: \AtBeginOfInputs
diff --git a/required/firstaid/latex2e-first-aid-for-external-files.dtx b/required/firstaid/latex2e-first-aid-for-external-files.dtx
index e8c23d2b..e722438f 100644
--- a/required/firstaid/latex2e-first-aid-for-external-files.dtx
+++ b/required/firstaid/latex2e-first-aid-for-external-files.dtx
@@ -128,11 +128,150 @@
 %    \end{macrocode}
 %  \end{macro}
 %    
+%    \begin{macrocode}
+%</kernel>
+%    \end{macrocode}
+%
+%
+% \subsection{The \pkg{filehook} package first aid}
+%     
+%    The \pkg{filehook} package implements hooks into file loading
+%    commands. These days this is already provided by the kernel
+%    albeit not with the same user interface. Until that package gets
+%    updated (to use the kernel interfaces) we provide a
+%    substitution. This does not offer all hooks from \pkg{filehook}
+%    but all that have been used in packages available in \TeX{} Live.
+%
+%    Note that this doesn't fix \pkg{currfile} because that package
+%    uses \pkg{filehook} but relies on the internals of the old
+%    implementation.
+%
+%    The package has now got an update so we aren't activating the
+%    first aid. However, it basically bypasses the new hook mechanism
+%    and puts the old hooks in thereby disabling, for example, the
+%    possibility to reorder code through rules.
+%
+%    We therefore keep \texttt{filehook-ltx.sty} around as a guideline
+%    for further updates.
 %
 %    \begin{macrocode}
+%<*kernel>
+%\declare at file@substitution{filehook.sty}{filehook-ltx.sty}
 %</kernel>
+%    \End{macrocode}
+%
+%    If a new filehook package becomes available it can be tested
+%    simply by  undoing the above substitution via
+%    \begin{verbatim}
+%  \undeclare at file@substitution{filehook.sty}
+%    \end{verbatim}
+%    Once ready this will then taken out of the first aid file.
+%
+%    What follows is a partial implementation of the  \pkg{filehook}
+%    interfaces.
+%
+%    Not implemented are:
+%\begin{verbatim}
+%  \AtBeginOfFiles
+%  \AtEndOfFiles
+%  \AtBeginOfInputs
+%  \AtEndOfInputs
+%  \AtBeginOfInputFile
+%  \AtEndOfInputFile
+%\end{verbatim}
+%
+%    \begin{macrocode}
+%<*filehook>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\newcommand\AtBeginOfEveryFile [1]
+  {\AddToHook{file/before}{#1}}
+\newcommand\AtEndOfEveryFile [1]
+  {\AddToHook{file/after}{#1}}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\newcommand\AtBeginOfIncludes [1]
+  {\AddToHook{include/before}{#1}}
+\newcommand\AtEndOfIncludes [1]
+  {\AddToHook{include/end}{#1}}
+\newcommand\AfterIncludes [1]
+  {\AddToHook{include/after}{#1}}
 %    \end{macrocode}
 %    
+%    \begin{macrocode}
+\newcommand\AtBeginOfPackages [1]
+  {\AddToHook{package/before}{#1}}
+\newcommand\AtEndOfPackages [1]
+  {\AddToHook{package/after}{#1}}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\newcommand\AtBeginOfClasses [1]
+  {\AddToHook{class/before}{#1}}
+\newcommand\AtEndOfClasses [1]
+  {\AddToHook{class/after}{#1}}
+%    \end{macrocode}
+%
+%    For normal files we drop the \texttt{.tex} extension for now:
+%    \begin{macrocode}
+\newcommand\AtBeginOfFile [2]
+  {\AddToHook{file/before/#1}{#2}}
+\newcommand\AtEndOfFile [2]
+  {\AddToHook{file/after/#1}{#2}}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\DeclareDocumentCommand \AtBeginOfPackageFile {smm}
+   {\IfBooleanTF{#1}%
+     {\@ifpackageloaded{#2}%
+         {#3}%
+         {\AddToHook{package/before/#2}{#3}}}%
+     {\AddToHook{package/before/#2}{#3}}%
+   }
+\DeclareDocumentCommand \AtEndOfPackageFile {smm}
+   {\IfBooleanTF{#1}%
+     {\@ifpackageloaded{#2}%
+         {#3}%
+         {\AddToHook{package/after/#2}{#3}}}%
+     {\AddToHook{package/after/#2}{#3}}%
+   }
+%    \end{macrocode}
+%
+%    Are the * forms here of any use? I know they are use 3--4 times
+%    on CTAN but I wonder if those are real or mistaken usages.  
+%    \begin{macrocode}
+\DeclareDocumentCommand \AtBeginOfClassFile {smm}
+   {\IfBooleanTF{#1}%
+     {\@ifclassloaded{#2}%
+         {#3}%
+         {\AddToHook{class/before/#2}{#3}}}%
+     {\AddToHook{class/before/#2}{#3}}%
+   }
+\DeclareDocumentCommand \AtEndOfClassFile {smm}
+   {\IfBooleanTF{#1}%
+     {\@ifclassloaded{#2}%
+         {#3}%
+         {\AddToHook{class/after/#2}{#3}}}%
+     {\AddToHook{class/after/#2}{#3}}%
+   }
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\newcommand\AtBeginOfIncludeFile [2]
+  {\AddToHook{include/before/#1}{#2}}
+\newcommand\AtEndOfIncludeFile [2]
+  {\AddToHook{include/end/#1}{#2}}
+\newcommand\AfterIncludeFile [2]
+  {\AddToHook{include/after/#1}{#2}}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%</filehook>
+%    \end{macrocode}
+%
+%
 %
 %
 % \subsection{The \pkg{bidi} package first aid}





More information about the latex3-commits mailing list.