Debian Codegraph @

texmf-dist/tex/latex/koma-script/scrlfile-hook.sty

raw
1 %%
2 %% This is file `scrlfile-hook.sty',
3 %% generated with the docstrip utility, extended by scrdocstrip.
4 %%
5 %% The original source files were:
6 %%
7 %% scrlfile-hook.dtx (with options: `package,current')
8 %% scrlogo.dtx (with options: `logo')
9 %%
10 %% Copyright (c) 2002-2026 Markus Kohm [komascript at gmx info]
11 %%
12 %% This file was generated from file(s) of the KOMA-Script bundle.
13 %% ---------------------------------------------------------------
14 %%
15 %% It may be distributed under the conditions of the
16 %% LaTeX Project Public License in the version distributed together
17 %% with KOMA-Script, see file `lppl.txt' or `lppl-de.txt'.
18 %%
19 %% This file may only be distributed together with a copy of the
20 %% KOMA-Script bundle. You may however distribute the
21 %% KOMA-Script bundle without all such generated files. See also
22 %% `lppl.txt' or `lppl-de.txt' for additional information.
23 %%
24 %% The list of files belonging to KOMA-Script distribution is given in
25 %% the file `MANIFEST.md'. See also `lppl.txt' or `lppl-de.txt' for
26 %% additional information.
27 %%
28 %% If this file is a beta version, you may not be allowed to distribute
29 %% it. Look at the comments below to see if this is the case.
30 %%
31 %% English and German manuals are part of KOMA-Script bundle.
32 %% ----------------------------------------------------------
33 %%
34 %% See `README'.
35 %%
36 %% The KOMA-Script bundle (but maybe not this file) was based upon the
37 %% LaTeX 2.09 Script family created by Frank Neukam 1993 and the LaTeX2e
38 %% standard classes created by The LaTeX3 Project 1994-1996. You can
39 %% find a complete unmodified copy of LaTeX2e at
40 %% <http://mirror.ctan.org/tex-archive/macros/latex/base/>.
41 %%
42 %%% From File: $Id: scrlfile-hook.dtx$
43 \ProvidesPackage{scrlfile-hook}[%
44 2026/02/02 v3.49.2 KOMA-Script
45 package
46 (using LaTeX hooks)]
47 \@ifundefined{IfFormatAtLeastTF}{%
48 \PackageError{scrlfile-hook}{not recommended usage of package}{%
49 It seems this package has been loaded directly using a LaTeX
50 version\MessageBreak
51 prior to 2020-10-01. This is not recommended. Please always load
52 package\MessageBreak
53 scrlfile instead of scrlfile-hook.\MessageBreak
54 If you would continue, I will try to load scrlfile-patcholdlatex%
55 }%
56 \RequirePackage{scrlfile-patcholdlatex}\endinput
57 }{%
58 \IfFormatAtLeastTF{2020/10/01}{%
59 \IfFormatAtLeastTF{2021/11/15}{%
60 }{%
61 \PackageError{scrlfile-hook}{LaTeX too old for this package}{%
62 It seems this package has been loaded directly using LaTeX
63 version\MessageBreak
64 prior to 2021-11-15. This is not recommended. Please always load
65 package\MessageBreak
66 scrlfile instead of scrlfile-hook.\MessageBreak
67 If you would continue, I will try to load scrlfile-hook-3.34%
68 }%
69 \RequirePackage{scrlfile-hook-3.34}\endinput
70 }%
71 }{%
72 \PackageError{scrlfile-hook}{LaTeX too old for this package}{%
73 It seems this package has been loaded directly using a LaTeX
74 version\MessageBreak
75 prior to 2020-10-01. This is not recommended. Please always load
76 package\MessageBreak
77 scrlfile instead of scrlfile-hook.\MessageBreak
78 If you would continue, I will try to load scrlfile-patcholdlatex%
79 }%
80 \RequirePackage{scrlfile-patcholdlatex}\endinput
81 }%
82 }
83 \ExplSyntaxOn
84 \NewDocumentCommand \BeforeFile { m }
85 {
86 \AddToHook { file / #1 / before }
87 }
88 \NewDocumentCommand \AfterFile { m }
89 {
90 \AddToHook { file / #1 / after }
91 }
92 \NewDocumentCommand \BeforeClass { m }
93 {
94 \BeforeFile { #1.\@clsextension }
95 }
96 \NewDocumentCommand \BeforePackage { m }
97 {
98 \BeforeFile { #1.\@pkgextension }
99 }
100 \NewDocumentCommand \AfterAtEndOfClass { s m o +m }
101 {
102 \IfBooleanTF { #1 }
103 {
104 \scrlfile_if_class_loaded:nTF { #2 }
105 { #4 }
106 { \hook_gput_code:nnn { class / #2 / after } { #3 } { #4 } }
107 }
108 {
109 \scrlfile_if_class_loaded:nF
110 { #2 }
111 { \hook_gput_code:nnn { class / #2 / after } { #3 } { #4 } }
112 }
113 }
114 \NewDocumentCommand \AfterAtEndOfPackage { s m o +m }
115 {
116 \IfBooleanTF { #1 }
117 {
118 \scrlfile_if_package_loaded:nTF { #2 }
119 { #4 }
120 { \hook_gput_code:nnn { package / #2 / after } { #3 } { #4 } }
121 }
122 {
123 \scrlfile_if_package_loaded:nF
124 { #2 }
125 { \hook_gput_code:nnn { package / #2 / after } { #3 } { #4 } }
126 }
127 }
128 \seq_new:N \g__scrlfile_input_file_seq
129 \hook_gput_code:nnn { file / before } { . }
130 { \seq_gpush:Nx \g__scrlfile_input_file_seq { \CurrentFile } }
131 \msg_new:nnn { scrlfile-hook } { too-many-pops }
132 {
133 More~file~names~popped~from~stack~than~put~to.~
134 This~should~never~happen.~
135 However,~it~could~happen~if~scrlfile-hook~is~loaded~by~another~
136 package~or~class.~In~this~case~some~packages~or~classes~are~not~
137 recognised~correctly.
138 }
139 \hook_gput_code:nnn { file / after } { . }
140 {
141 \seq_gpop:NNF \g__scrlfile_input_file_seq \l_tmpa_seq
142 {
143 \msg_warning:nn { scrlfile-hook } { too-many-pops }
144 }
145 }
146 \cs_if_exist:NTF \g__filehook_input_file_seq
147 {
148 \seq_map_inline:Nn \g__filehook_input_file_seq
149 {
150 \seq_gput_right:Nx \g__scrlfile_input_file_seq
151 { \tl_item:nn { #1 } { 2 } }
152 }
153 }
154 {
155 \seq_gpush:Nx \g__scrlfile_input_file_seq { }
156 \cs_if_exist:NTF \CurrentFileUsed
157 { \seq_gpush:Nx \g__scrlfile_input_file_seq { \CurrentFileUsed } }
158 { \seq_gpush:Nx \g__scrlfile_input_file_seq { \CurrentFile } }
159 }
160 \prg_new_protected_conditional:Npnn \__scrlfile_if_loading:n #1 { T, F, TF }
161 {
162 \str_set:Nx \l_tmpa_str { #1 }
163 \seq_if_in:NxTF \g__scrlfile_input_file_seq { \str_use:N \l_tmpa_str }
164 { \prg_return_true: }
165 { \prg_return_false: }
166 }
167 \prg_new_protected_conditional:Npnn \scrlfile_if_class_loaded:n #1 { T, F, TF }
168 {
169 \@ifclassloaded { #1 }
170 {
171 \__scrlfile_if_loading:nTF { #1.\@clsextension }
172 { \prg_return_false: }
173 { \prg_return_true: }
174 }
175 {
176 \prg_return_false:
177 }
178 }
179 \prg_new_protected_conditional:Npnn \scrlfile_if_package_loaded:n #1 { T, F, TF }
180 {
181 \@ifpackageloaded { #1 }
182 {
183 \__scrlfile_if_loading:nTF { #1.\@pkgextension }
184 { \prg_return_false: }
185 { \prg_return_true: }
186 }
187 {
188 \prg_return_false:
189 }
190 }
191 \NewDocumentCommand \scrlfile@AfterClass { s m o +m }
192 {
193 \IfBooleanTF { #1 }
194 {
195 \@ifclassloaded{ #2 }
196 { #4 }
197 {
198 \hook_gput_code:nnn
199 { file / #2.\@clsextension / after }
200 { #3 }
201 { #4 }
202 }
203 }
204 {
205 \hook_gput_code:nnn { file / #2.\@clsextension / after } { #3 } { #4 }
206 }
207 }
208 \NewDocumentCommand \AfterClass { } { \scrlfile@AfterClass }
209 \NewDocumentCommand \scrlfile@AfterPackage { s m o +m }
210 {
211 \IfBooleanTF { #1 }
212 {
213 \@ifpackageloaded{ #2 }
214 { #4 }
215 {
216 \hook_gput_code:nnn
217 { file / #2.\@pkgextension / after }
218 { #3 }
219 { #4 }
220 }
221 }
222 {
223 \hook_gput_code:nnn { file / #2.\@pkgextension / after } { #3 } { #4 }
224 }
225 }
226 \NewDocumentCommand \AfterPackage { } { \scrlfile@AfterPackage }
227 \NewDocumentCommand{\ReplaceInput}{}{\declare@file@substitution}
228 \NewDocumentCommand\ReplaceClass{mm}{%
229 \declare@file@substitution{#1.\@clsextension}{#2.\@clsextension}%
230 }
231 \NewDocumentCommand\ReplacePackage{mm}{%
232 \declare@file@substitution{#1.\@pkgextension}{#2.\@pkgextension}%
233 }
234 \NewDocumentCommand{\UnReplaceInput}{}{\undeclare@file@substitution}
235 \NewDocumentCommand\UnReplaceClass{m}{%
236 \undeclare@file@substitution{#1.\@clsextension}%
237 }
238 \NewDocumentCommand\UnReplacePackage{mm}{%
239 \undeclare@file@substitution{#1.\@pkgextension}%
240 }
241 \clist_new:N \g__scrlfile_prevent_clist
242 \NewDocumentCommand \PreventPackageFromLoading { s +o m }
243 {
244 \clist_set:Nx \l__scrlfile_package_clist { #3 }
245 \clist_map_inline:Nn \l__scrlfile_package_clist
246 {
247 \@ifpackageloaded { ##1 }
248 {
249 \IfBooleanTF { #1 } { \msg_info:nnn } { \msg_warning:nnn }
250 { scrlfile } { no-prevent-for-already-loaded } { ##1 }
251 }
252 {
253 \clist_if_in:NnF \g__scrlfile_prevent_clist { ##1 }
254 { \clist_gput_right:Nn \g__scrlfile_prevent_clist { ##1 } }
255 \tl_if_exist:cF { g__scrlfile_exclude_package_##1_tl }
256 {
257 \tl_new:c { g__scrlfile_exclude_package_##1_tl }
258 }
259 \IfValueT { #2 }
260 {
261 \tl_gput_right:cn { g__scrlfile_exclude_package_##1_tl } { #2 }
262 }
263 \disable@package@load { ##1 }
264 { \tl_use:c { g__scrlfile_exclude_package_##1_tl } }
265 }
266 }
267 \clist_clear:N \l__scrlfile_package_clist
268 }
269 \clist_new:N \l__scrlfile_package_clist
270 \msg_new:nnn { scrlfile } { no-prevent-for-already-loaded }
271 {
272 Cannot~prevent~package~`#1'~from~being~loaded,~
273 because~it~has~been~loaded~already~before~line~\msg_line_number:
274 }
275 \NewDocumentCommand \StorePreventPackageFromLoading { m }
276 { \edef #1 { \clist_use:Nn \g__scrlfile_prevent_clist { , } } }
277 \NewDocumentCommand \ResetPreventPackageFromLoading {}
278 {
279 \clist_map_function:NN \g__scrlfile_prevent_clist \reenable@package@load
280 \clist_gclear:N \g__scrlfile_prevent_clist
281 }
282 \NewDocumentCommand \UnPreventPackageFromLoading { s m }
283 {
284 \clist_set:Nx \l__scrlfile_package_clist { #2 }
285 \clist_map_inline:Nn \l__scrlfile_package_clist
286 {
287 \clist_if_in:NnT \g__scrlfile_prevent_clist { ##1 }
288 {
289 \clist_gremove_all:Nn \g__scrlfile_prevent_clist { ##1 }
290 \reenable@package@load { ##1 }
291 \IfBooleanT { #1 }
292 { \cs_undefine:c { g__scrlfile_exclude_package_##1_tl } }
293 }
294 }
295 }
296 \NewDocumentCommand \BeforeClosingMainAux { o m }
297 {
298 \hook_gput_code:nnn { enddocument / afterlastpage } { #1 }
299 {
300 \debug_suspend:
301 \RenewDocumentCommand \BeforeClosingMainAux { m } { ##1 }
302 \cs_set_eq:NN \__scrlfile_protected@write:Nnn \protected@write
303 \cs_set_eq:NN \protected@write \protected@immediate@write
304 #2
305 \cs_set_eq:NN \protected@write \__scrlfile_protected@write:Nnn
306 \debug_resume:
307 }
308 }
309 \NewDocumentCommand \AfterReadingMainAux { o m }
310 {
311 \hook_gput_code:nnn { enddocument / afteraux } { #1 }
312 {
313 \debug_suspend:
314 \RenewDocumentCommand \AfterReadingMainAux { m } { ##1 }
315 \cs_set_eq:NN \__scrlfile_protected@write:Nnn \protected@write
316 \cs_set_eq:NN \protected@write \protected@immediate@write
317 #2
318 \cs_set_eq:NN \protected@write \__scrlfile_protected@write:Nnn
319 \debug_resume:
320 }
321 }
322 \ExplSyntaxOff
323 \ProvideDocumentCommand\protected@immediate@write{m+m+m}
324 {%
325 \begingroup
326 #2%
327 \let\protect\@unexpandable@protect
328 \edef\reserved@a{\immediate\write#1{#3}}%
329 \reserved@a
330 \endgroup
331 \if@nobreak\ifvmode\nobreak\fi\fi
332 }
333 %%% From File: $Id: scrlogo.dtx 4032 2023-04-17 09:45:11Z kohm $
334 \RequirePackage{scrlogo}
335 \endinput
336 %%
337 %% End of file `scrlfile-hook.sty'.