summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/filehook
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-01-05 00:23:17 +0000
committerKarl Berry <karl@freefriends.org>2011-01-05 00:23:17 +0000
commitf421a713f2db99addeedb67a3581160f419a5ac3 (patch)
treebc20c6816e6dcb38d95aa58c638ef38727736533 /Master/texmf-dist/tex/latex/filehook
parentbe62fd26ebe0decfe5c8abe5ff1fd2e2b00b7254 (diff)
filehook 0.4 (4jan11)
git-svn-id: svn://tug.org/texlive/trunk@20933 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/filehook')
-rw-r--r--Master/texmf-dist/tex/latex/filehook/filehook-fink.sty73
-rw-r--r--Master/texmf-dist/tex/latex/filehook/filehook-listings.sty45
-rw-r--r--Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty59
-rw-r--r--Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty118
-rw-r--r--Master/texmf-dist/tex/latex/filehook/filehook.sty453
5 files changed, 566 insertions, 182 deletions
diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty b/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty
new file mode 100644
index 00000000000..77e2793d09b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/filehook/filehook-fink.sty
@@ -0,0 +1,73 @@
+%% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de>
+%% -----------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files filehook.dtx, filehook.ins
+%% and the derived file filehook.sty.
+%%
+%% $Id: filehook.dtx 2005 2011-01-03 22:53:56Z martin $
+\ProvidesPackage{filehook-fink}[2011/01/03 v0.1 filehook compatibility code for fink package]
+\RequirePackage{filehook}
+\RequirePackage{currfile}%
+
+\begingroup
+
+\long\def\fink@old@InputIfFileExists#1#2{%
+ \IfFileExists{#1}{%
+ #2\@addtofilelist{#1}%
+ \fink@prepare{#1}%
+ \expandafter\fink@input%
+ \expandafter\fink@restore\expandafter{\finkpath}}%
+}
+
+\long\def\fink@new@InputIfFileExists#1#2{%
+ \IfFileExists{#1}{%
+ #2\@addtofilelist{#1}%
+ \edef\fink@before{\noexpand\fink@input{#1}}%
+ \edef\fink@after{\noexpand\fink@restore{\finkpath}}%
+ \expandafter\fink@before\fink@after}%
+}
+
+\ifcase
+ \ifx\InputIfFileExists\filehook@InputIfFileExists 0\else
+ \ifx\InputIfFileExists\latex@InputIfFileExists 1\else
+ \ifx\InputIfFileExists\fink@new@InputIfFileExists 1\else
+ \ifx\InputIfFileExists\fink@old@InputIfFileExists 1\else
+ 1%
+ \fi\fi\fi\fi
+\relax
+\or
+ \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \PackageInfo{filehook-fink}{Package 'fink' detected and replaced by 'currfile'}%
+\else
+ \iffilehook@force
+ \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \PackageWarning{filehook-fink}{Detected 'fink' package with unknown definition of \string\InputIfFileExists.^^J%
+ The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
+ \else
+ \PackageError{filehook-fink}{Detected 'fink' package with unknown definition of \string\InputIfFileExists.^^J%
+ Use the 'force' option of 'filehook' to overwrite it.}{}%
+ \fi
+\fi
+
+\endgroup
+\endinput
+%%
+%% End of file `filehook-fink.sty'.
diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty b/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty
new file mode 100644
index 00000000000..e6c394e5489
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/filehook/filehook-listings.sty
@@ -0,0 +1,45 @@
+%% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de>
+%% -----------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files filehook.dtx, filehook.ins
+%% and the derived file filehook.sty.
+%%
+%% $Id: filehook.dtx 2005 2011-01-03 22:53:56Z martin $
+\ProvidesPackage{filehook-listings}[2011/01/02 v0.1 Patch for listings to avoid hooks for verbatim input files]
+\begingroup
+
+\long\def\patch#1\def\lst@next#2#3\endpatch{%
+ \toks@{#2}%
+ \edef\@tempa{\the\toks@}%
+ \def\@tempb{\input{####1}}%
+ \ifx\@tempa\@tempb
+ \gdef\lst@InputListing##1{#1\def\lst@next{\@input{##1}}#3}%
+ \else
+ \PackageWarning{filehook-listings}{To-be-patched code in macro \string\lst@InputListing was not found!}%
+ \fi
+}
+
+\@ifundefined{lst@InputListing}{%
+ \PackageWarning{filehook-listings}{To-be-patched Macro \string\lst@InputListing not found!}%
+}{}
+
+\expandafter\patch\lst@InputListing{#1}\endpatch
+
+\endgroup
+\endinput
+%%
+%% End of file `filehook-listings.sty'.
diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty b/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty
new file mode 100644
index 00000000000..3cfae9f348a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/filehook/filehook-memoir.sty
@@ -0,0 +1,59 @@
+%% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de>
+%% -----------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files filehook.dtx, filehook.ins
+%% and the derived file filehook.sty.
+%%
+%% $Id: filehook.dtx 2005 2011-01-03 22:53:56Z martin $
+\ProvidesPackage{filehook-memoir}[2011/01/03 v0.1 filehook patch for memoir class]
+\RequirePackage{filehook}
+\begingroup
+\long\def\memoir@InputIfFileExists#1#2{%
+ \IfFileExists{#1}%
+ {#2\@addtofilelist{#1}\m@matbeginf{#1}%
+ \@@input \@filef@und
+ \m@matendf{#1}%
+ \killm@matf{#1}}%
+}
+\ifcase
+ \ifx\InputIfFileExists\latex@InputIfFileExists 0\else
+ \ifx\InputIfFileExists\memoir@InputIfFileExists 0\else
+ 1%
+ \fi\fi
+\relax
+ \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \filehook@appendwarg\filehook@atbegin{\m@matbeginf{#1}}%
+ \filehook@prefixwarg\filehook@atend{\m@matendf{#1}\killm@matf{#1}}%
+ \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks}
+\else
+ \iffilehook@force
+ \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J%
+ The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
+ \else
+ \PackageError{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J%
+ Use the 'force' option of 'filehook' to overwrite it.}{}%
+ \fi
+\fi
+\endgroup
+\endinput
+%%
+%% End of file `filehook-memoir.sty'.
diff --git a/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty b/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty
new file mode 100644
index 00000000000..03b19800cc2
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/filehook/filehook-scrlfile.sty
@@ -0,0 +1,118 @@
+%% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de>
+%% -----------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3c
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files filehook.dtx, filehook.ins
+%% and the derived file filehook.sty.
+%%
+%% $Id: filehook.dtx 2005 2011-01-03 22:53:56Z martin $
+\ProvidesPackage{filehook-scrlfile}[2011/01/03 v0.1 filehook patch for scrlfile package]
+\RequirePackage{filehook}
+\begingroup
+\long\def\scrlfile@InputIfFileExists#1#2{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \@@input \@filef@und
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\long\def\filehook@scrlfile@InputIfFileExists#1#2{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {\scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \filehook@every@atbegin{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ \filehook@every@atend{#1}%
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\long\def\filehook@@scrlfile@InputIfFileExists#1#2{%
+ \let\InputIfFileExists\filehook@InputIfFileExists
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {\scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\ifcase
+ \ifx\InputIfFileExists\latex@InputIfFileExists 0\else
+ \ifx\InputIfFileExists\scrlfile@InputIfFileExists 0\else
+ 1%
+ \fi\fi
+\relax
+ \global\let\filehook@InputIfFileExists\filehook@scrlfile@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@scrlfile@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}%
+\else
+ \iffilehook@force
+ \global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \global\let\InputIfFileExists\filehook@InputIfFileExists
+ \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
+ The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
+ \else
+ \PackageError{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J%
+ Use the 'force' option of 'filehook' to overwrite it.}{}%
+ \fi
+\fi
+\endgroup
+\endinput
+%%
+%% End of file `filehook-scrlfile.sty'.
diff --git a/Master/texmf-dist/tex/latex/filehook/filehook.sty b/Master/texmf-dist/tex/latex/filehook/filehook.sty
index ba3aee1e82d..9ed1ecb4648 100644
--- a/Master/texmf-dist/tex/latex/filehook/filehook.sty
+++ b/Master/texmf-dist/tex/latex/filehook/filehook.sty
@@ -1,4 +1,4 @@
-%% Copyright (c) 2010 by Martin Scharrer <martin@scharrer-online.de>
+%% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de>
%% -----------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -18,157 +18,58 @@
%% This work consists of the files filehook.dtx, filehook.ins
%% and the derived file filehook.sty.
%%
-%% $Id: filehook.dtx 1926 2010-12-20 23:11:20Z martin $
+%% $Id: filehook.dtx 2005 2011-01-03 22:53:56Z martin $
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{filehook}
- [2010/12/20 v0.3 Hooks for input files]
+ [2011/01/03 v0.4 Hooks for input files]
\newif\iffilehook@force
\DeclareOption{force}{\filehook@forcetrue}
\ProcessOptions\relax
-\let\filehook@orig@@input@\@input@
-\let\filehook@orig@@iinput\@iinput
-\def\@input@#1{%
- \@ifnextchar\clearpage
- {\filehook@include@atbegin{#1}%
- \filehook@orig@@input@{#1}%
- \filehook@include@atend{#1}%
- \clearpage
- \filehook@include@after{#1}%
- \@gobble
- }%
- {\filehook@orig@@input@{#1}}%
-}
-\def\@iinput#1{%
- \filehook@input@atbegin{#1}%
- \filehook@orig@@iinput{#1}%
- \filehook@input@atend{#1}%
-}
-\begingroup
-
-\long\def\latex@InputIfFileExists#1#2{%
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}%
- \@@input\@filef@und
- }%
-}
-\long\def\memoir@InputIfFileExists#1#2{%
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}\m@matbeginf{#1}%
- \@@input \@filef@und
- \m@matendf{#1}%
- \killm@matf{#1}}%
-}
-\long\def\scrlfile@InputIfFileExists#1#2{%
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname #1-@alias\endcsname\relax
- \expandafter\@secondoftwo
- \else
- \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
- \expandafter\@firstoftwo
- \fi
- {%
- \expandafter\InputIfFileExists\expandafter{\csname
- #1-@alias\endcsname}{#2}%
- }%
- {\IfFileExists{#1}{%
- \scr@load@hook{before}{#1}%
- #2\@addtofilelist{#1}%
- \@@input \@filef@und
- \scr@load@hook{after}{#1}%
- }}%
-}
-\ifx\InputIfFileExists\scrlfile@InputIfFileExists
-
-\long\gdef\InputIfFileExists#1#2{%
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname #1-@alias\endcsname\relax
- \expandafter\@secondoftwo
- \else
- \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
- \expandafter\@firstoftwo
- \fi
- {%
- \expandafter\InputIfFileExists\expandafter{\csname
- #1-@alias\endcsname}{#2}%
- }%
- {\IfFileExists{#1}{%
- \scr@load@hook{before}{#1}%
- #2\@addtofilelist{#1}%
- \filehook@atbegin{#1}%
- \@@input \@filef@und
- \filehook@atend{#1}%
- \scr@load@hook{after}{#1}%
- }}%
-}
-
-\PackageInfo{filehook}{Package 'scrlfile' detected and compensated for.}
-
-\else
-
-\ifx\InputIfFileExists\memoir@InputIfFileExists
- \AtEndOfPackage{%
- \AtBeginOfFiles{\m@matbeginf{#1}}%
- \AtEndOfFiles{\m@matendf{#1}\killm@matf{#1}}%
- }
- \PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the 'At...OfFiles' hooks.}
-\else
-\ifx\InputIfFileExists\latex@InputIfFileExists
-\else
- \@ifpackageloaded{scrlfile}{%
- \PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists}%
- }{}%
-
- \@ifclassloaded{memoir}{%
- \PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists}%
- }{}%
-
- \iffilehook@force
- \PackageWarning{filehook}
- {Changed definition of \string\InputIfFileExists\space detected!^^J%
- The 'force' option is in effect and therefore this macros is redefined.
- This might break other packages or code}%
- \else
- \PackageError{filehook}
- {Changed definition of \string\InputIfFileExists\space detected!^^J%
- Use the 'force' option to force the redefinition of this macro.^^J%
- This might break other packages or code}%
- \fi
-\fi
-\fi
-
-\long\gdef\InputIfFileExists#1#2{%
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}%
- \filehook@atbegin{#1}%
- \@@input\@filef@und
- \filehook@atend{#1}%
- }%
-}
-
-\fi
-
-\endgroup
\def\filehook@include@atbegin#1{%
+ \let\InputIfFileExists\filehook@@InputIfFileExists
\@nameuse{\filehook@include@atbegin@#1}%
+ \filehook@include@@atbegin
}
+\def\filehook@include@@atbegin{}
\def\filehook@include@atend#1{%
+ \filehook@include@@atend
\@nameuse{\filehook@include@atend@#1}%
}
+\def\filehook@include@@atend{}
\def\filehook@include@after#1{%
+ \filehook@include@@after
\@nameuse{\filehook@include@after@#1}%
}
+\def\filehook@include@@after{}
\def\filehook@input@atbegin#1{%
- \@nameuse{\filehook@input@atbegin@#1}%
+ \let\InputIfFileExists\filehook@@InputIfFileExists
+ \@nameuse{\filehook@input@atbegin@\filehook@ensureext{#1}}%
+ \filehook@input@@atbegin
}
+\def\filehook@input@@atbegin{}
\def\filehook@input@atend#1{%
- \@nameuse{\filehook@input@atend@#1}%
+ \filehook@input@@atend
+ \@nameuse{\filehook@input@atend@\filehook@ensureext{#1}}%
}
+\def\filehook@input@@atend{}
\def\filehook@atbegin#1{%
- \@nameuse{\filehook@atbegin@#1}%
+ \@nameuse{\filehook@atbegin@\filehook@ensureext{#1}}%
+ \filehook@@atbegin
}
+\def\filehook@@atbegin{}
\def\filehook@atend#1{%
- \@nameuse{\filehook@atend@#1}%
+ \filehook@@atend
+ \@nameuse{\filehook@atend@\filehook@ensureext{#1}}%
}
+\def\filehook@@atend{}
+\def\filehook@every@atbegin#1{%
+ \filehook@every@@atbegin
+}
+\def\filehook@every@@atbegin{}
+\def\filehook@every@atend#1{%
+ \filehook@every@@atend
+}
+\def\filehook@every@@atend{}
\def\filehook@include@atbegin@{filehook@include@atbegin@}
\def\filehook@include@atend@{filehook@include@atend@}
\def\filehook@include@after@{filehook@include@after@}
@@ -201,89 +102,277 @@
\expandafter\gdef\expandafter#1\expandafter##\expandafter1\expandafter{\@tempa}%
\endgroup
}
+\def\filehook@addtohook#1#2#3{%
+ \begingroup
+ \edef\@tempa{#3}%
+ \edef\@tempa{#2\filehook@ensureext{\@tempa}}%
+ \@ifundefined{\@tempa}{\global\@namedef{\@tempa}{}}{}%
+ \expandafter\endgroup
+ \expandafter#1\csname\@tempa\endcsname
+}
\newcommand*\AtBeginOfIncludes{%
- \filehook@appendwarg\filehook@include@atbegin
+ \filehook@append\filehook@include@@atbegin
}
\newcommand*\AtEndOfIncludes{%
- \filehook@prefixwarg\filehook@include@atend
+ \filehook@prefix\filehook@include@@atend
}
\newcommand*\AfterIncludes{%
- \filehook@prefixwarg\filehook@include@after
+ \filehook@prefix\filehook@include@@after
}
\newcommand*\AtBeginOfIncludeFile[1]{%
- \@ifundefined{\filehook@include@atbegin@#1.tex}%
- {\long\global\@namedef{\filehook@include@atbegin@#1.tex}}%
- {\expandafter\filehook@append\csname\filehook@include@atbegin@#1.tex\endcsname}%
+ \filehook@addtohook\filehook@append\filehook@include@atbegin@{\filehook@ensuretex{#1}}%
}
\newcommand*\AtEndOfIncludeFile[1]{%
- \@ifundefined{\filehook@include@atend@#1.tex}%
- {\long\global\@namedef{\filehook@include@atend@#1.tex}}%
- {\expandafter\filehook@prefix\csname\filehook@include@atend@#1.tex\endcsname}%
+ \filehook@addtohook\filehook@prefix\filehook@include@atend@{\filehook@ensuretex{#1}}%
}
-\newcommand*\AfterOfIncludeFile[1]{%
- \@ifundefined{\filehook@include@after@#1.tex}%
- {\long\global\@namedef{\filehook@include@after@#1.tex}}%
- {\expandafter\filehook@prefix\csname\filehook@include@after@#1.tex\endcsname}%
+\newcommand*\AfterIncludeFile[1]{%
+ \filehook@addtohook\filehook@prefix\filehook@include@after@{\filehook@ensuretex{#1}}%
}
\newcommand*\AtBeginOfInputs{%
- \filehook@appendwarg\filehook@input@atbegin
+ \filehook@append\filehook@input@@atbegin
}
\newcommand*\AtEndOfInputs{%
- \filehook@prefixwarg\filehook@input@atend
+ \filehook@prefix\filehook@input@@atend
}
-\newcommand*\AtBeginOfInputFile[1]{%
- \@ifundefined{\filehook@input@atbegin@#1}%
- {\long\global\@namedef{\filehook@input@atbegin@#1}}%
- {\expandafter\filehook@append\csname\filehook@input@atbegin@#1\endcsname}%
+\newcommand*\AtBeginOfInputFile{%
+ \filehook@addtohook\filehook@append\filehook@input@atbegin@
}
-\newcommand*\AtEndOfInputFile[1]{%
- \@ifundefined{\filehook@input@atend@#1}%
- {\long\global\@namedef{\filehook@input@atend@#1}}%
- {\expandafter\filehook@prefix\csname\filehook@input@atend@#1\endcsname}%
+\newcommand*\AtEndOfInputFile{%
+ \filehook@addtohook\filehook@prefix\filehook@input@atend@
}
\newcommand*\AtBeginOfFiles{%
- \filehook@appendwarg\filehook@atbegin
+ \filehook@append\filehook@@atbegin
}
\newcommand*\AtEndOfFiles{%
- \filehook@prefixwarg\filehook@atend
+ \filehook@prefix\filehook@@atend
}
-\newcommand*\AtBeginOfFile[1]{%
- \@ifundefined{\filehook@atbegin@#1}%
- {\long\global\@namedef{\filehook@atbegin@#1}}%
- {\expandafter\filehook@append\csname\filehook@atbegin@#1\endcsname}%
+\newcommand*\AtBeginOfEveryFile{%
+ \filehook@append\filehook@every@@atbegin
}
-\newcommand*\AtEndOfFile[1]{%
- \@ifundefined{\filehook@atend@#1}%
- {\long\global\@namedef{\filehook@atend@#1}}%
- {\expandafter\filehook@prefix\csname\filehook@atend@#1\endcsname}%
+\newcommand*\AtEndOfEveryFile{%
+ \filehook@prefix\filehook@every@@atend
}
-\newcommand*\AtBeginOfPackageFile[1]{%
- \AtBeginOfFile{#1.\@pkgextension}%
+\newcommand*\AtBeginOfFile{%
+ \filehook@addtohook\filehook@append\filehook@atbegin@
}
-\newcommand*\AtEndOfPackageFile{%
- \@ifnextchar*\AtEndOfPackageFile@star\AtEndOfPackageFile@normal
+\newcommand*\AtEndOfFile{%
+ \filehook@addtohook\filehook@prefix\filehook@atend@
+}
+\newcommand*\AtBeginOfClassFile{%
+ \@ifnextchar*
+ {\AtBeginOfXFile@star\@clsextension}%
+ {\AtBeginOfXFile@normal\@clsextension}%
}
-\def\AtEndOfPackageFile@star*#1#2{%
- \@ifpackageloaded{#1}%
- {#2}%
- {\AtEndOfPackageFile@normal{#1}{#2}}%
+\newcommand*\AtBeginOfPackageFile{%
+ \@ifnextchar*
+ {\AtBeginOfXFile@star\@pkgextension}%
+ {\AtBeginOfXFile@normal\@pkgextension}%
}
-\def\AtEndOfPackageFile@normal#1#2{%
- \AtEndOfFile{#1.\@pkgextension}{\AtEndOfPackage{#2}}%
+\def\AtBeginOfXFile@star#1*#2{%
+ \@ifl@aded{#1}{#2}%
+ {\@firstofone}%
+ {\AtBeginOfXFile@normal{#1}{#2}}%
}
-\newcommand*\AtBeginOfClassFile[1]{%
- \AtBeginOfFile{#1.\@clsextension}%
+\def\AtBeginOfXFile@normal#1#2{%
+ \AtBeginOfFile{#2.#1}%
}
\newcommand*\AtEndOfClassFile{%
- \@ifnextchar*\AtEndOfClassFile@star\AtEndOfClassFile@normal
+ \@ifnextchar*
+ {\AtEndOfXFile@star\@clsextension}%
+ {\AtEndOfXFile@normal\@clsextension}%
+}
+\newcommand*\AtEndOfPackageFile{%
+ \@ifnextchar*
+ {\AtEndOfXFile@star\@pkgextension}%
+ {\AtEndOfXFile@normal\@pkgextension}%
+}
+\def\AtEndOfXFile@star#1*#2{%
+ \@ifl@aded{#1}{#2}%
+ {\@firstofone}%
+ {\AtEndOfXFile@normal{#1}{#2}}%
+}
+\def\AtEndOfXFile@normal#1#2#3{%
+ \AtEndOfFile{#2.#1}{\AtEndOfPackage{#3}}%
+}
+\let\filehook@orig@@input@\@input@
+\let\filehook@orig@@iinput\@iinput
+\def\@input@#1{%
+ \@ifnextchar\clearpage
+ {%
+ \filehook@every@atbegin{#1}%
+ \filehook@include@atbegin{#1}%
+ \filehook@orig@@input@{#1}%
+ \filehook@include@atend{#1}%
+ \clearpage
+ \filehook@include@after{#1}%
+ \filehook@every@atend{#1}%
+ \@gobble
+ }%
+ {\filehook@orig@@input@{#1}}%
}
-\def\AtEndOfClassFile@star*#1#2{%
- \@ifclassloaded{#1}%
- {#2}%
- {\AtEndOfClassFile@normal{#1}{#2}}%
+\def\filehook@@iinput#1{%
+ \filehook@every@atbegin{#1}%
+ \filehook@input@atbegin{#1}%
+ \filehook@orig@@iinput{#1}%
+ \filehook@input@atend{#1}%
+ \filehook@every@atend{#1}%
+}
+\let\@iinput\filehook@@iinput
+\def\filehook@swap#1#2{#2#1}
+\def\filehook@ensureext#1{%
+ \expandafter\filehook@@ensureext#1\empty.tex\empty\empty
}
-\def\AtEndOfClassFile@normal#1#2{%
- \AtEndOfFile{#1.\@clsextension}{\AtEndOfClass{#2}}%
+\def\filehook@@ensureext#1.#2\empty#3\empty{#1.#2}
+\def\filehook@ensuretex#1{%
+ \expandafter\filehook@@ensuretex#1\empty.tex\empty\empty
+}
+\def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex}
+\long\def\latex@InputIfFileExists#1#2{%
+ \IfFileExists{#1}%
+ {#2\@addtofilelist{#1}%
+ \@@input\@filef@und
+ }%
+}
+\long\gdef\filehook@default@InputIfFileExists#1#2{%
+ \IfFileExists{#1}%
+ {\expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {#2\@addtofilelist{#1}%
+ \filehook@every@atbegin{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ \filehook@every@atend{#1}%
+ }%
+}
+\long\gdef\filehook@@default@InputIfFileExists#1#2{%
+ \let\InputIfFileExists\filehook@InputIfFileExists
+ \IfFileExists{#1}%
+ {\expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {#2\@addtofilelist{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ }%
+}
+\long\def\scrlfile@InputIfFileExists#1#2{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \@@input \@filef@und
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\long\def\filehook@scrlfile@InputIfFileExists#1#2{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {\scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \filehook@every@atbegin{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ \filehook@every@atend{#1}%
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\long\def\filehook@@scrlfile@InputIfFileExists#1#2{%
+ \let\InputIfFileExists\filehook@InputIfFileExists
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname #1-@alias\endcsname\relax
+ \expandafter\@secondoftwo
+ \else
+ \scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}%
+ \expandafter\@firstoftwo
+ \fi
+ {%
+ \expandafter\InputIfFileExists\expandafter{\csname
+ #1-@alias\endcsname}{#2}%
+ }%
+ {\IfFileExists{#1}{%
+ \expandafter\filehook@swap
+ \expandafter{\@filef@und}%
+ {\scr@load@hook{before}{#1}%
+ #2\@addtofilelist{#1}%
+ \filehook@atbegin{#1}%
+ \@@input}%
+ \filehook@atend{#1}%
+ \scr@load@hook{after}{#1}%
+ }}%
+}
+\AtBeginOfPackageFile*{scrlfile}{%
+ \let\InputIfFileExists\latex@InputIfFileExists
+}%
+\AtEndOfPackageFile*{scrlfile}{%
+ \RequirePackage{filehook-scrlfile}%
+}%
+\AtBeginOfPackageFile*{fink}{%
+ \RequirePackage{kvoptions}%
+ \begingroup
+ \let\InputIfFileExists\latex@InputIfFileExists
+}%
+\AtEndOfPackageFile*{fink}{%
+ \edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk@mainext,maindir=\fnk@maindir}{currfile}}%
+ \expandafter\endgroup\@tempa
+ \RequirePackage{filehook-fink}%
+}%
+\AtBeginOfClassFile*{memoir}{%
+ \let\filehook@@InputIfFileExists\latex@InputIfFileExists
+ \let\InputIfFileExists\latex@InputIfFileExists
+ \let\@iinput\filehook@orig@@iinput
+}%
+\AtEndOfClassFile*{memoir}{%
+ \let\@iinput\filehook@@iinput
+ \RequirePackage{filehook-memoir}%
+}%
+\ifcase
+ \ifx\InputIfFileExists\filehook@InputIfFileExists 0\else
+ \ifx\InputIfFileExists\latex@InputIfFileExists 1\else
+ \iffilehook@force 1\else
+ 9%
+ \fi\fi\fi
+\relax% 0
+\or% 1
+ \let\filehook@InputIfFileExists\filehook@default@InputIfFileExists
+ \let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists
+ \let\InputIfFileExists\filehook@InputIfFileExists
+ \iffilehook@force
+ \PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
+ The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}%
+ \fi
+\else
+ \PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J%
+ Use the 'force' option of 'filehook' to overwrite it.}{}%
+\fi
+\AtBeginDocument{%
+ \ifx\InputIfFileExists\filehook@InputIfFileExists\else
+ \PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J%
+ Certain file hooks might now be dysfunctional!}
+ \fi
}
\endinput
%%