Skip to content

Commit

Permalink
fix for #1604
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankMittelbach committed Jan 2, 2025
1 parent 2b9ad8a commit 170d363
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2025-01-02 Frank Mittelbach <[email protected]>

* ltclass.dtx (subsection{Hooks}):
Do not make \AtBeginDocument preamble only (gh/1604)

2024-12-27 Frank Mittelbach <[email protected]>

* ltsockets.dtx:
Expand Down
18 changes: 15 additions & 3 deletions base/ltclass.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltclass.dtx}
[2024/08/28 v1.5m LaTeX Kernel (Class & Package Interface)]
[2025/01/02 v1.5n LaTeX Kernel (Class & Package Interface)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltclass.dtx}
Expand Down Expand Up @@ -2808,8 +2808,20 @@
%<*2ekernel>
% \end{macrocode}
%
% \begin{macrocode}
\@onlypreamble\AtBeginDocument
% In its initial implementation (not using the hook system)
% \cs{AtBeginDocument} was made \cs{@preambleonly} because using it
% later had no effect whatsoever, thus was most certainly an
% unintended programming error. With the reimplementation, using
% the \texttt{begindocument} hook internally, this has changed
% because adding to a onetime hook after it has already been used
% simply executes the additional code immediately. We therefore no
% longer generate an error if it is used inside the document so
% that \verb=\AddToHook{begindocument}= and \cs{AtBeginDocument}
% are truly equivalent (as claimed in the hook documentation).
% \changes{v1.5n}{2025/01/02}{Do not make \cs{AtBeginDocument}
% preamble only (gh/1604)}
% \begin{macrocode}
%\@onlypreamble\AtBeginDocument
% \end{macrocode}
% \end{macro}
% \end{macro}
Expand Down
3 changes: 3 additions & 0 deletions base/testfiles-lthooks/lthooks-034.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
\typeout{====== E}
\UseHook{foo}

\AtBeginDocument{\typeout{--> A (test for gh/1604)}}
\AddToHook{begindocument}{\typeout{--> B (test for gh/1604)}}

\END
2 changes: 2 additions & 0 deletions base/testfiles-lthooks/lthooks-034.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ l. ...\ShowHook{foo}
====== E
pkgb
pkga
--> A (test for gh/1604)
--> B (test for gh/1604)

0 comments on commit 170d363

Please sign in to comment.