% \iffalse^^A meta-comment
% ======================================================================
% scrlfile.dtx
% Copyright (c) Markus Kohm, 2002-2023
%
% This file is part of the work `scrlfile' which is part of the LaTeX2e
% KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% 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 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
%%% From File: $Id: scrlfile.dtx 4032 2023-04-17 09:45:11Z kohm $
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
  \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
  \filedate$Date: 2023-04-17 11:45:11 +0200 (Mo, 17. Apr 2023) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 4032 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrlfile.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script package source
  }%
\reserved@a
%</dtx>
%<package>\ProvidesPackage{scrlfile}[%
%!KOMAScriptVersion
%<package>  package 
  (file load hooks)]
%<*dtx>
\ifx\documentclass\undefined
  \input scrdocstrip.tex
  \@@input scrkernel-version.dtx
  \@@input scrstrip.inc
  \KOMAdefVariable{COPYRIGHTFROM}{2002}
  \generate{\usepreamble\defaultpreamble
    \file{scrlfile.sty}{%
      \from{scrlfile.dtx}{package}%
      \from{scrlogo.dtx}{logo}%
    }%
  }
  \batchinput{scrlfile-hook.dtx}
  \batchinput{scrlfile-patcholdlatex.dtx}
  \@@input scrstrop.inc
\else
  \let\endbatchfile\relax
\fi
\endbatchfile
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{1}
\begin{document}
  \DocInput{scrlfile.dtx}
\end{document}
%</dtx>
% \fi^^A meta-comment
%
% \changes{v2.95}{2002/06/11}{First version split from hugh scrclass.dtx}
% \changes{v3.24}{2017/05/06}{standalone manual removed}
% \changes{v3.32}{2020/09/11}{new implementation based on
%   \pkg*{scrlfile-hook} and \pkg*{scrlfile-patcholdlatex}}
% \changes{v3.36}{2022/02/03}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/03}{using \file{scrlogo.dtx} to define the logo}
% \changes{v3.40}{2023/04/17}{guide names changed}
%
% \GetFileInfo{scrlfile.dtx}
% \title{File Loading Hooks with \href{https://komascript.de}{\KOMAScript}
%   Package \pkg*{scrlfile}}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   This package is the compatibility layer over \texttt{scrlfile-hook} and
%   \texttt{scrlfile-patcholdlatex}. It provides package and class hook
%   handling independent from the used \LaTeX{} release.
% \end{abstract}
% \tableofcontents
%
%
% \section{User Manual}
%
% You can find the user manual of \pkg*{scrlfile} in the \KOMAScript{} manual,
% either the German \file{scrguide-de.pdf} or the English
% \file{scrguide-en.pdf}.
%
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of \pkg*{scrlfile}}
%
% We need to load one of the packages \pkg*{scrlfile-hook},
% \pkg*{scrlfile-kook-3.34}, \pkg*{scrlfile-patcholdlatex}.
% \changes{v3.33}{2021/02/09}{do not test for existence of \cs{AddToHook} any
% longer, but \cs{IfFormatAtLeastTF} and the format version}%
% We cannot do the decision by testing the existence of macro \cs{AddToHook},
% because package \pkg{latexrelease} does not rollback to prior format
% versions good enough. Instead of undefining the macro and so really
% reverting to the definition of \LaTeX{} kernels prior to 2020/10/01 it only
% redefines it to a do-nothing macro. Because of this and similar issues with
% \pkg{latexrelease} cannot (or only with provision) be used to simulate a
% real old \LaTeX{} kernel, i.e. for testing. So the only valid test for the
% existence of the wanted \cs{AddToHook} would be to test the definite
% definition of \cs{AddToHook} and the existence of the hooks we are
% using. But, because this is to much effort, we simply test the format
% version. Nevertheless, we know, this may fail!
%    \begin{macrocode}
\@ifundefined{IfFormatAtLeastTF}{%
  \RequirePackage{scrlfile-patcholdlatex}%
  \RequirePackage{xparse}%
%    \end{macrocode}
% \changes{v3.33}{2021/02/16}{workaround for \pkg{latexrelease} bug}
% Explicitly switch of \pkg{expl3} syntax because of a
% \pkg{latexrelease} bug related to the usage of \pkg{xparse-2020-10-01} in
% version 2020-02-02.
% \changes{v3.35}{2021/10/31}{new variant because of \LaTeX{} kernel change}
%    \begin{macrocode}
  \ExplSyntaxOff
}{%
  \IfFormatAtLeastTF{2020/10/01}{%
    \IfFormatAtLeastTF{2021/11/15}{%
      \RequirePackage{scrlfile-hook}%
    }{%
      \RequirePackage{scrlfile-hook-3.34}%
    }%
  }{%
    \RequirePackage{scrlfile-patcholdlatex}%
    \RequirePackage{xparse}%
%    \end{macrocode}
% Explicitly switch of \pkg{expl3} syntax because of a
% \pkg{latexrelease} bug in version 2020-02-02.
%    \begin{macrocode}
    \ExplSyntaxOff
  }%
}
%    \end{macrocode}
%
% \begin{option}{withdeprecated}
% \changes{v3.32}{2020/09/11}{added}
% Depending on this option we implement addition deprecated commands.
%    \begin{macrocode}
\DeclareOption{withdeprecated}{%
%    \end{macrocode}
%
% \begin{command}[noindex]{\AfterClass+,\AfterClass!}
% \cs{scrlfile@AfterClass} is used in the sub-packages to store the original
% \cs{AfterClass} and can be used to redefine \cs{AfterClass} to handle the
% plus and the exclamation mark variant.
%    \begin{macrocode}
  \RenewDocumentCommand\AfterClass{}{%
%    \end{macrocode}
%^^A Hack for correct line numbers in the index:
%^^A - end environment,
%^^A - do index entries
%^^A - fix vertical spaces
%^^A - restart environment without printing and indexing
% \end{command}
% \SpecialMainCommandIndex{\AfterClass+}
% \SpecialMainCommandIndex{\AfterClass\quotechar!}
% \vskip-\dimexpr 2.2\baselineskip+\parskip\relax
% \begin{command}[noindex,noprint]{\AfterClass+,\AfterClass!}
%    \begin{macrocode}
    \kernel@ifnextchar +%
      {\scrlfile@emulatedeprecated{Class}}%
      {%
        \kernel@ifnextchar !%
          {\scrlfile@emulatedeprecated{Class}}%
          \scrlfile@AfterClass
      }%
  }
%    \end{macrocode}
% \end{command}
%
% \begin{command}[noindex]{\AfterPackage+,\AfterPackage!}
% \cs{scrlfile@AfterPackage} is used in the sub-packages to store the original
% \cs{AfterPackage} and can be used to redefine \cs{AfterPackage} to handle
% the plus and the exclamation mark variant.
%    \begin{macrocode}
  \RenewDocumentCommand\AfterPackage{}{%
%    \end{macrocode}
%^^A Hack for correct line numbers in the index:
%^^A - end environment,
%^^A - do index entries
%^^A - fix vertical spaces
%^^A - restart environment without printing and indexing
% \end{command}
% \SpecialMainCommandIndex{\AfterPackage+}
% \SpecialMainCommandIndex{\AfterPackage\quotechar!}
% \vskip-\dimexpr 2.2\baselineskip+\parskip\relax
% \begin{command}[noindex,noprint]{\AfterPackage+,\AfterPackage!}
%    \begin{macrocode}
    \kernel@ifnextchar +%
      {\scrlfile@emulatedeprecated{Package}}%
      {%
        \kernel@ifnextchar !%
          {\scrlfile@emulatedeprecated{Package}}%
          \scrlfile@AfterPackage
      }%
  }
%    \end{macrocode}
% \end{command}
%
% \begin{macro}{\scrlfile@emulatedeprecated}
% \changes{v3.32}{2020/09/11}{added}
% This emulates \cs{AfterClass+}, \cs{AfterPackage+}, \cs{AfterClass!} and
% \cs{AfterPackage!} using \cs{AfterAtEndOfClass} or
% \cs{AfterAtEndOfPackage}. Note, that both, the plus and the exclamation mark
% variants, are emulated by the star variant of \cs{AfterAtEndOfClass}
% resp. \cs{AfterAtEndOfPackage}. So the emulation is not perfect.
%    \begin{macrocode}
  \newcommand*{\scrlfile@emulatedeprecated}[2]{%
    \PackageWarning{scrlfile}{%
      emulating deprecated \expandafter\string\csname After#1#2\endcsname
      \space by\MessageBreak
      \expandafter\string\csname AfterAtEndOf#1*\endcsname.\MessageBreak
      Note, this may fail, so you should not use\MessageBreak
      \expandafter\string\csname After#1#2\endcsname
    }%
    \csname AfterAtEndOf#1\endcsname*%
  }
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{option}
%
% Now, we just have to execute and process the options.
%    \begin{macrocode}
\ExecuteOptions{}
\ProcessOptions\relax
%    \end{macrocode}
%
% \Finale
% \PrintChanges
% 
% \endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End: