Skip to content

Commit

Permalink
Gh1604 (#1605)
Browse files Browse the repository at this point in the history
* fix for #1604

* fix a test

* typo
  • Loading branch information
FrankMittelbach authored Jan 3, 2025
1 parent 2b9ad8a commit 818bc13
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 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{@onlypreamble} 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)
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Don't change this file in any respect.
---------------------------------------
\And -> \DOTSB \tmspace +\thickmuskip {.2777em}\mathchar "3026 \tmspace +\thickmuskip {.2777em}{foo}{bar}{baz}
---------------------------------------
\AtBeginDocument -> \GenericError { }{LaTeX Error: Can be used only in preamble}{See the LaTeX manual or LaTeX Companion for explanation.}{Your command was ignored.\MessageBreak Type I <command> <return> to replace it with another command,\MessageBreak or <return> to continue without it.}{foo}{bar}{baz}
\AtBeginDocument -> \AtBeginDocument {foo}{bar}{baz}
---------------------------------------
\Bar -> \bar {foo}{bar}{baz}
---------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion required/amsmath/testfiles/github-amsrobust-0123.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Don't change this file in any respect.
---------------------------------------
\And -> \DOTSB \tmspace +\thickmuskip {.2777em}\mathchar "3026 \tmspace +\thickmuskip {.2777em}{foo}{bar}{baz}
---------------------------------------
\AtBeginDocument -> \GenericError { }{LaTeX Error: Can be used only in preamble}{See the LaTeX manual or LaTeX Companion for explanation.}{Your command was ignored.\MessageBreak Type I <command> <return> to replace it with another command,\MessageBreak or <return> to continue without it.}{foo}{bar}{baz}
\AtBeginDocument -> \AtBeginDocument {foo}{bar}{baz}
---------------------------------------
\Bar -> \bar {foo}{bar}{baz}
---------------------------------------
Expand Down

0 comments on commit 818bc13

Please sign in to comment.