\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ltj-latex}[2012/04/21 LuaLaTeX-ja]
-\def\ltj@pkgpatchlist{}
-\def\ltj@pkgpatch#1{
- \@ifpackageloaded{#1}{\usepackage{lltjp-#1}}{
- \@ifpackageloaded{filehook}{\AtEndOfPackageFile*{#1}{\usepackage{lltjp-#1}}}{}
- }
- \ifx\ltj@pkgpatchlist\@empty
- \gdef\ltj@pkgpatchlist{#1}
- \else
- \xdef\ltj@pkgpatchlist{\ltj@pkgpatchlist, #1}
- \fi
-}
+% Globally add to the head of a macro (cf. LaTeX2e's \g@addto@macro)
+\long\def\ltj@g@addto@macro#1#2{
+ \begingroup
+ \def\ltj@tmpa{#2}
+ \toks@\expandafter\expandafter\expandafter{\expandafter\ltj@tmpa#1}
+ \xdef#1{\the\toks@}
+ \endgroup}
+
+\def\ltj@AtBeginDocument{\ltj@g@addto@macro\@begindocumenthook}
+
+\def\ltj@pkgpatch#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\usepackage{lltjp-#1}}{}}}
% similar to \ltj@pkgpatch, but this is used .sty which
% can be reloaded inside the document by \input.
-\def\ltj@pkgpatchA#1{
- \@ifpackageloaded{#1}{\input{lltjp-#1.sty}}{
- \@ifpackageloaded{filehook}{\AtEndOfFile{#1.sty}{\input{lltjp-#1.sty}}}{}
- }
- \ifx\ltj@pkgpatchlist\@empty
- \gdef\ltj@pkgpatchlist{#1}
- \else
- \xdef\ltj@pkgpatchlist{\ltj@pkgpatchlist, #1}
- \fi
-}
+\def\ltj@pkgpatchA#1{\ltj@AtBeginDocument{\@ifpackageloaded{#1}{\input{lltjp-#1.sty}}{}}}
\endlinechar=13
\expandafter\let\csname JY3/mc/m/n/10\endcsname\relax
%%% patch for packages
-\IfFileExists{filehook.sty}{\usepackage{filehook}}{}
\ltj@pkgpatch{listings}
\ltj@pkgpatch{unicode-math}
\ltj@pkgpatch{xunicode}
-\@ifpackageloaded{filehook}{}{%
- \@PackageWarningNoLine{ltj-latex}{
- LuaTeX-ja uses filehook package to apply patches to the following packages:\MessageBreak
- \ltj@pkgpatchlist.\MessageBreak
- But your TeX system does not have the filehook package.\MessageBreak
- Therefore problems may occur if you load the above packages after this message}%
-}
+
%%------------------ all done
\ltj@latex@AtEnd