summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/srcltx/srcltx.dtx
blob: 83a2d48975093d9b0c1b4f3242c42009240cbd55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
% \iffalse meta-comment
% This package is in the public domain. It comes with no guarantees
% and no reserved rights. You can use or modify this package at your
% own risk.
%
% Originally written by: Aleksander Simonic
% Currently maintained by: Stefan Ulrich <stefanulrich@users.sourceforge.net>
% \fi
%
% \iffalse
%<*package>
%<latex>\NeedsTeXFormat{LaTeX2e}
%<latex>\ProvidesPackage{srcltx}[2006/11/12 v1.6 Source specials for inverse search in DVI files]
%</package>
%
%<*driver>
\ProvidesFile{srcltx.drv}[2001/04/01 v1.0 Driver for srcltx package]
\documentclass{ltxdoc}
\usepackage{tabularx,calc}
\IfFileExists{url.sty}{\RequirePackage{url}}{\newcommand\url{\texttt}}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\usepackage[inactive]{srcltx}
\def\MainFile{srcltx.dtx}
\newcommand\package{\textsf}
\newcommand\file{\texttt}
\renewcommand\topfraction{.85}
\renewcommand\textfraction{.15}
\renewcommand\floatpagefraction{.66}
\newenvironment{descr}{%
  \renewcommand\descriptionlabel[1]{\hspace\labelsep\normalfont##1}
  \begin{description}
}{%
  \end{description}
}
\DeclareRobustCommand\Com[1]{\texttt{\bslash #1}}
\pagestyle{headings}
\frenchspacing
\usepackage[
pdftitle={Documentation for the srcltx package},
pdfauthor={Stefan Ulrich},
pdfsubject={srcltx},
pdfcreator={LaTeX/hyperref package},
colorlinks=true,
% change ghastly default link colors
linkcolor=blue,citecolor=blue,filecolor=blue,menucolor=blue,pagecolor=blue,urlcolor=blue,
pdfpagemode=None,
]{hyperref}
% get rid of cheesy font settings ...
\let\sldefault\itdefault
\let\MakeUppercase\relax

\OnlyDescription

\begin{document}
\DocInput{srcltx.dtx}
\end{document}
%</driver>
%
% \fi
%
%
% \CheckSum{394}
% 
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% 
% \GetFileInfo{srcltx.sty}
% 
% \title{\package{srcltx.sty} $\cdot$ \package{srctex.sty}}
% \author{\normalsize Originally written by Aleksander Simonic\\
% 	    \normalsize Currenlty maintained by\\ \normalsize Stefan Ulrich \href{mailto:stefanulrich@users.sourceforge.net}{\texttt{<stefanulrich@users.sourceforge.net>}}}
% \date{\fileversion, \filedate}
% \maketitle
% 
% \begin{abstract}\noindent
% This package provides source special insertion into DVI files,
% allowing to jump from the DVI file to the \file{.tex} source
% and back (given a DVI viewer that supports this).  Additionally,
% it provides hooks for error tracking from the \file{.log} file
% for the WinEdt shell.
% \end{abstract}
% 
% \tableofcontents
% 
% \section{Warning}
% 
% \textbf{Source specials may alter the paragraph spacing
% in your document. Always process the final version of your document with
% this package commented out, or deactivated:}
% |\usepackage[inactive]{srcltx}|.
% 
% \section{Usage}
% To use the package with \LaTeX, put the line
% 
% |\usepackage{srcltx}|
% 
% \noindent
% into the preamble of your document.  For \TeX, use
% 
% |\input srctex.sty|
% 
% \noindent
% instead.  This will insert source specials at every
% start of a paragraph of your document and at every math environment
% (see the `Options' section below for how to customize this).  A source
% special is only inserted if there hasn't already been one on the same
% source input line.
% 
% For editors and DVI viewers that support it, source specials can be used for
% `inverse search' between the (La)\TeX\ source and the DVI file:
% The \file{.dvi} viewer can open a text editor with the file
% (and line) of the corresponding place in the \file{.tex} source
% (also called `reverse search'), and the editor can invoke the previewer
% with the corresponding place in the \file{.dvi} file (`forward search').
% Examples for DVI previewers supporting this are: The Windows viewers YAP and Dviwin,
% and the Unix viewers xdvi(k) (versions $\geq$ 22.38) and KDVI (KDE $\geq$ 3.0).
% Editors supporting inverse search are e.g. WinEdt, (X)Emacs, nedit and vim.
% 
% The package was originally written for use with the WinEdt shell, and
% it offers some special features to customize WinEdt's error
% tracking. These are shown in the example in figure~\ref{ex} on page~\pageref{ex}.
% 
% The specials inserted by this package have the following format, which should
% be compatible with all DVI viewers:
% 
% \begin{tabular}{@{}l@{}}
% |\special{src:|\textit{line-number}\textvisiblespace\textit{filename}|}|
% \end{tabular}
% 
% 
% \subsection{Options}
% 
% The following options are only available for the \LaTeX2e\ version of
% this package. Unless noted otherwise, the Plain \TeX\ version \package{srctex.sty}
% has a command |\SRC|$\langle$\texttt{foo}$\rangle$ for each option
% $\langle$\texttt{foo}$\rangle$, e.g. |\SRCnopar| replaces the
% `\texttt{nopar}' option.
% \begin{descr}
% 
% \item[\texttt{active}\slash\texttt{inactive}]
% 	  With the \texttt{inactive} option, source specials are disabled, but
% 	  the source file tracking for WinEdt is still active.
% 	  
% 	  The \texttt{active} option is only useful to override
% 	  a global \texttt{inactive} option.
% 
% 	  For \package{srctex.sty}, use \Com{SRCOKtrue} and \Com{SRCOKfalse}
% 	  instead.
% 
% \item[\texttt{nowinedt}] Turn off the source file tracking used by WinEdt (the
% 	  |:<+ |\texttt{\textit{filename}} line in the output every time
% 	  an input file is opened, and the |:<-| line when it's closed again).
% 
% \item[\texttt{dviwin}] Use specials in a format suitable for dviwin
% 	   (without a space between the line number and the filename).
% 
% \item[\texttt{debug}] Print debugging information on current
% 	  input file and the input file stack.
% \end{descr}
% The following options can be used to turn off source specials for certain
% environments; try these options if you encounter problems with the default behaviour:
% \begin{descr}
% \item[\texttt{nopar}] Don't hook into |\everypar|.
% 
% \item[\texttt{nomath}] Don't hook into |\everymath|.
% 
% %BROKEN \item[\texttt{nodisplay}] Don't hook into |\everydisplay|.
% 
% \end{descr}
% 
% \begin{figure}
% \hrulefill
% \footnotesize\begin{verbatim}
% \documentclass{report}
% \usepackage{srcltx}
%  %
%  % ... Preamble ...
%  %
% \begin{document}
%  %
%  % ... Title, Author etc. ...
%  %
% \WinEdt{?0000} % Do not process any errors (overful/underful boxes)
%  % ... Preface etc. ...
% \WinEdt{?1111} % Process all types of errors from here on
% \include{chapter1}
% \include{chapter2}
% \include{chapter3}
% \bibliographystyle{plain}
% \bibliography{xbib}
% \end{document}
% \end{verbatim}
% \hrulefill
% \caption{Example for using \package{srcltx.sty} with the WinEdt error tracking features.}\label{ex}
% \end{figure}
% 
% \subsection{Commands}
% \begin{descr}
% 
% \item[\Com{Input}\marg{filename}] In order to keep track
% 	   of the current filename, the \LaTeX\ commands
% 	   \Com{include}\marg{filename} and \Com{input}\marg{filename}
% 	   are overloaded (note the braces enclosing the filename argument).  The
% 	   \Com{input} command where the filename can be specified
% 	   without any delimiters is a \TeX\ primitive command that can
% 	   not be overloaded easily.  Therefore the package provides an
% 	   alternative command |\Input| which you should use in Plain
% 	   \TeX\ instead of \Com{input} if you want the specials in such
% 	   files to point to the correct filename.  For \LaTeX, you
% 	   should always use the version with braces:
% 	   \Com{input}\marg{filename}.  \emph{Note}: For Winedt, you will
% 	   also need to specify the file name extension (e.g.
% 	   \file{.tex}) in the argument of this command.
% 
% \item[\Com{MainFile}] Usually the \TeX\ primitive |\jobname| contains the name of the
% 	   ``main'' TeX file, without the filename extension `\file{.tex}'.
% 	   Accordingly, |\MainFile| is defined as |\jobname.tex|. 
% 	   If you have a very awkward \TeX\ implementation that already adds the extension
% 	   to |\jobname|, you compensate for this by redefining this command as follows
%          (after loading \package{srcltx.sty}):
% 
% 	   \noindent\begin{tabular}{@{}l@{}}
% 	   |\def\MainFile{\jobname}|
% 	   \end{tabular}
%
% \item[\Com{srcIncludeHook}] This is a hook that is called by the \Com{include}
%          command. It takes the argument of that command and sets \Com{CurrentInput}
%	   to that argument (or a modified version thereof); the content of \Com{CurrentInput}
%	   is used as file name in the source specials. This hook can be used
%          to write a customized file name into the source specials. For example,
%          if the \file{.tex} source file is automatically generated from some
%          master document, the source specials in the DVI file could point
%          to that master document instead of the generated \file{.tex} file.
%
%          Its default definition is:
%
% 	   \noindent\begin{tabular}{@{}l@{}}
%               |\newcommand*\srcIncludeHook[1]{% |\\
%               |    \protected@xdef\CurrentInput{#1.tex}}|
% 	   \end{tabular}
%
%	   \noindent
%	   (for \LaTeX, similar with \Com{def} for \TeX).
%
% \item[\Com{srcInputHook}] This is similar to \Com{srcIncludeHook}, but for the \Com{input}
%	   command.
%
%          Its default definition is:
%
% 	   \noindent\begin{tabular}{@{}l@{}}
%               |\newcommand*\srcInputHook[1]{\src@getfilename@with@ext{#1}}|
% 	   \end{tabular}
%
%	   \noindent
%	   (for \LaTeX, similar with \Com{def} for \TeX); \Com{src@getfilename@with@ext}
%	   will append a `.tex' extension to the filename if it doesn't already end
%	   with `.tex'.
%
% \item[\Com{SRCOKtrue}, \Com{SRCOKfalse}] You can use these commands to
% 	   activate\slash deactivate source specials at any place in your
% 	   document, e.g. when you experience problems with some special
% 	   constructions (see also `Bugs and Restrictions' in section
% 	   \ref{sec:bugs}).
% 	   
% \end{descr}
% 
% \section{Bugs and Restrictions}\label{sec:bugs}
% 
% Since this macro package overloads some internal \LaTeX\ commands, it
% is not as robust as one might wish, and might interact badly with other
% packages. Furthermore, the spacing might be altered by using the
% package; for example, with the \file{amsmath} documentation \file{amsldoc.tex},
% the bibliography is shifted from the bottom of page 31 to page 32.
% Therefore you should comment out the package or disable it with the
% \texttt{inactive} option when preparing the final version of your document.
% 
% A somewhat more robust method of inserting source specials is to use \TeX\
% (the program) instead of a macro solution. Some \TeX\ implementations
% provide a command line option for this.\footnote{%
% E.g. a `\file{-src}' option is available in Mik\TeX\ from version 1.20 upwards,
% or in te\TeX\ from version beta-20011103 or teTeX-2.0 upwards. See the manual of your
% \TeX\ implementation for details on this.}
% You can still load \package{srcltx.sty} with the `\texttt{inactive}' option to enable
% the WinEdt error tracking features when needed.
% 
% This section lists known incompatibilities with other packages and workarounds for these.
% If you know of any other problems, please send a bug report to
% \href{mailto:stefanulrich@users.sourceforge.net}{\texttt{<stefanulrich@users.sourceforge.net>}}.
% \begin{description}
% \item[{\normalfont\package{soul.sty}:}] Active source specials inside
% 	  the soul tokenization routine may lead to a `reconstruction failed'
% 	  error. As a workaround, the internal command |\SOUL@| is overloaded
% 	  by \package{srcltx}. With the Plain \TeX\ version, \package{srctex.sty}
% 	  needs to be loaded \emph{after} \package{soul.sty} to make this work.
% \item[{\normalfont\package{syntax.sty}:}] This style does extensive parsing
% 	  of the input inside its `grammar' environment, which is incompatible
% 	  with \package{srcltx.sty}.
% \end{description}
% 
% \section{Related Packages}
% 
% Heiko Oberdiek's \package{vpe.sty} provides source specials for
% forward search in PDF files. To our knowledge there exists no
% implementation for reverse search with PDF viewers, or inverse search
% in Postscript documents.
% 
% \section{History}
% 
% This package was originally written by A.~Simonic, the author of the WinEdt Shell,
% to implement source file tracking and DVI source specials
% for \TeX. D.~P.~Carlisle and B.~K.~Horn have contributed bug
% fixes. Further changes and conversion to \file{ltxdoc} format by S.~Ulrich.
% Thanks for patches and suggestions to: A.~Cherepanov, J.~Rawnsley, D.~Kastrup,
% D.~Arseneau, M.~S.~Gr\o nsleth and R.~Hemmecke.
% 
%
% \StopEventually{}
% \section{Implementation}
%
% \changes{v1.6}{2006/11/12}{Provide \Com{srcInputHook} and \Com{srcIncludeHook} for changing
%		the input filename on-the-fly,
%               as requested by Ralf Hemmecke for his Axiom and ALLPROSE packages.
%               Also fixed \Com{src@getfilename@with@ext} so that it doesn't append `.tex' any
%               more in cases where the filename had a complex extension (e.g. `foo.bar.tex')
%               with the last element `.tex'.}
% \changes{v1.5}{2004/10/05}{Fixed version number in documentation, and made \Com{input} append .tex
%		extension if not yet present (feature requested by Martin Sigurd Gr\o nsleth).}
% \changes{v1.4}{2004/05/15}{Fixed \Com{everypar} hook, as suggested by David Kastrup in comp.text.tex,
%		for compatibility with chapterbib.sty}
% \changes{v1.3}{2003/03/10}{Also hook into \Com{everydisplay}; unreleased since this change broke
%		regression for gentle.tex}
% \changes{v1.2c}{2002/03/01}{Added the `nowinedt' option}
% \changes{v1.2b}{2002/01/23}{Fixed spurious space introduced by uncommented linebreak}
% \changes{v1.2}{2002/01/21}{Replace stack by macro solution, as suggested by
%               Alexander Cherepanov (cherepan at mccme.ru).
%               Also overload LaTeX's \Com{input} command.}
% \changes{v1.1a}{2001/07/14}{Minor fixes in the documentation.}
% \changes{v1.1}{2001/03/31}{SU: converted to ltxdoc format, changed the
%                            push\slash pop commands to use a `real' stack,
%                            other minor modifications}
% \changes{v1.002}{1999/09/03}{modified to change \Com{everypar}, by David Carlisle}
% \changes{v1.001}{1998/12/23}{modified to change \Com{output}, by Berthold Horn}
%
%
%    \begin{macrocode}
%<*package>
%<tex>\catcode`\@=11
\newif\ifSRCOK \SRCOKtrue
\newif\ifsrc@debug@
\newif\ifsrc@dviwin@
\newif\ifsrc@winedt@\src@winedt@true
\newif\ifsrc@everypar@\src@everypar@true
\newif\ifsrc@everymath@\src@everymath@true
%<*latex>
\RequirePackage{ifthen}
\DeclareOption{active}{\SRCOKtrue}
\DeclareOption{inactive}{\SRCOKfalse}
\DeclareOption{nowinedt}{\src@winedt@false}
\DeclareOption{debug}{\src@debug@true}
\DeclareOption{nopar}{\global\src@everypar@false}
\DeclareOption{nomath}{\global\src@everymath@false}
%</latex>
%<*tex>
\def\SRCdebug{\src@debug@true}
\def\SRCnopar{\src@everypar@false}
\def\SRCnomath{\src@everymath@false}
\def\typeout#1{{\newlinechar`\^^J\message{#1^^J}}}
\def\AtBeginDocument#1{#1}
%</tex>
%<latex>\newcommand*\src@maybe@space{}
\let\src@maybe@space\space
%<latex>\DeclareOption{dviwin}{\let\src@maybe@space\relax}
%    \end{macrocode}
%    SU: Originally the default was |\ExecuteOptions{inactive}|, but this
%    was rather unintuitive, so I changed it.
%    \begin{macrocode}
%<latex>\ExecuteOptions{active}
%<latex>\ProcessOptions
\newcount\src@lastline
\global\src@lastline=-1
%<latex>\newcommand*\src@debug{}
\def\src@debug#1{\ifsrc@debug@\typeout{DBG: |#1|}\fi}
%    \end{macrocode}
%    \begin{macro}{\MainFile}
%    This is for compatibility with \TeX\ implementations that add already
%    the `\file{.tex}' extension to \Com{jobname} (very rare):
%    \begin{macrocode}
%<latex>\newcommand*\MainFile{}
\def\MainFile{\jobname.tex}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\CurrentInput}
%    Used to keep track of current input file name:
%    \begin{macrocode}
%<latex>\newcommand*\CurrentInput{}
\gdef\CurrentInput{\MainFile}
%    \end{macrocode}
%    \end{macro}
%    Command to customize WinEdt's log mode, and enable its input file
%    tracking. This is switched off when the option \texttt{nowinedt} is
%    selected.
%    \begin{macrocode}
%<latex>\newcommand*\WinEdt{}
\def\WinEdt#1{\ifsrc@winedt@\typeout{:#1}\fi}
%    \end{macrocode}
%    A hook for \package{soul}, which might otherwise break with
%    a `reconstruction failed' error:
%    \begin{macrocode}
%<latex>\newcommand\src@AfterFi{}
\def\src@AfterFi#1\fi{\fi#1}
\AtBeginDocument{%
%<latex>    \@ifpackageloaded{soul}{%
%<tex>\ifx\SOUL@\relax
%<tex>\else
        \let\src@SOUL@\SOUL@
        \def\SOUL@#1{%
            \ifSRCOK
                \SRCOKfalse\src@SOUL@{#1}\SRCOKtrue
            \else
                \src@AfterFi\src@SOUL@{#1}%
            \fi
        }%
%<tex>\fi
%<latex>    }{}%
}
%    \end{macrocode}
%    \begin{macro}{\srcIncludeHook}
%    Hook to set the name of the current input file (\Com{CurrentInput}) for the \Com{include} command.
%    \begin{macrocode}
%<latex>\newcommand*\srcIncludeHook[1]{\protected@xdef\CurrentInput{#1.tex}}
%<tex>\def\srcIncludeHook#1{\xdef\CurrentInput{#1.tex}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\srcInputHook}
%    Hook to set the name of the current input file (\Com{CurrentInput}) for the \Com{Input} command.
%    \begin{macrocode}
%<latex>\newcommand*\srcInputHook[1]{%
%<tex>\def\srcInputHook#1{%
    \src@getfilename@with@ext{#1}%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\src@spec}
%    Macro that actually inserts the special.
%    \begin{macrocode}
%<latex>\newcommand*\src@spec{}
\def\src@spec{%
    \ifSRCOK
        \ifnum\inputlineno>\src@lastline
            \global\src@lastline=\inputlineno
            \src@debug{%
                src:\the\inputlineno\src@maybe@space\CurrentInput}%
            \special{src:\the\inputlineno\src@maybe@space\CurrentInput}%
        \fi
    \fi
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\src@before@file@hook}
%    \begin{macro}{\src@after@file@hook}
%    Hooks executed before and after a level of input happens:
%    \begin{macrocode}
%<latex>\newcommand\src@before@file@hook{}
%<latex>\newcommand\src@after@file@hook{}
\def\src@before@file@hook{%
    \WinEdt{<+ \CurrentInput}%
    \global\src@lastline=0
    \ifSRCOK\special{src:1\src@maybe@space\CurrentInput}\fi
}
\def\src@after@file@hook#1{%
    \WinEdt{<-}%
    \global\src@lastline=\inputlineno
    \global\advance\src@lastline by -1%
    \gdef\CurrentInput{#1}%
    \src@spec
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\src@getfilename@with@ext}
%    Check if \verb+#1+ has the extension `.tex', and if not, append it, saving the
%    result to \Com{CurrentInput}. \emph{Warning:} This does not completely mimick
%    the behaviour of \Com{input}, since it also expands a filename `foo.sty' to
%    `foo.sty.tex' even if `foo.sty' exists. However in the context of this
%    package that doesn't matter much since we assume that files that don't have
%    a `.tex' extension won't create any content in the DVI file.
%
%    The command \Com{src@extensions@path} is similar to \Com{filename@parse}
%    from \file{latex.ltx}.
%    \begin{macrocode}
%<*latex>
\newcommand*\src@fname{}%
\newcommand*\src@tempa{}%
\newcommand*\src@extensions@path{}%
\newcommand*\src@getfilename@with@ext{}%
%</latex>
%<*tex>
\def\src@tempa{}%
%</tex>
\def\src@extensions@path#1.#2\end{%
%<*latex>
   \ifthenelse{\equal{#2}{}}{%
       \protected@edef\src@extensions@last{#1}%
       \let\src@tempa\relax
   }{%
       \def\src@tempa{\src@extensions@path#2\end}%
   }%
%</latex>
%<*tex>
   \ifx\\#2\\
       \edef\src@extensions@last{#1}%
       \let\src@tempa\relax
   \else
       \def\src@tempa{\src@extensions@path#2\end}%
   \fi
%</tex>
   \src@tempa
}
\def\src@getfilename@with@ext#1{%
    \expandafter\src@extensions@path#1.\end
%<*latex>
    \ifthenelse{\equal{\src@extensions@last}{tex}}{%
        \protected@xdef\CurrentInput{#1}%
    }{%
        \protected@xdef\CurrentInput{#1.tex}%
    }%
    \PackageInfo{srcltx}{Expanded filename `#1' to `\CurrentInput'}%
%</latex>
%<*tex>
    \def\src@tempa{tex}%
    \ifx\src@extensions@last\src@tempa
        \xdef\CurrentInput{#1}%
    \else
        \xdef\CurrentInput{#1.tex}%
    \fi
%</tex>
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\include}
%    Redefine the original \Com{include} command. This is done for LaTeX only.
%    The \file{.tex} extension is added to the argument.
%    \begin{macrocode}
%<*latex>
\newcommand*\src@include{}
\newcommand*\src@@include{}
\let\src@include\include
\def\include#1{%
    \src@spec
    \clearpage
    \expandafter\src@@include\expandafter{\CurrentInput}{#1}%
}%
\def\src@@include#1#2{%
    \srcIncludeHook{#2}%
    \src@before@file@hook
    \src@include{#2}%
    \src@after@file@hook{#1}%
}
%</latex>
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\input}
%    For \Com{input}, we can only overload the LaTeX syntax, i.e. the usage
%    with the argument in braces. For plain \TeX, we provide an alternative command
%    \Com{Input} that can be used instead of \Com{input}. We can't redefine
%    \Com{input}, since that is a \TeX\ primitive with a different way of parsing
%    the argument line.
%
%    A \file{.tex} extension is added to the argument if it's not already present.
%    \begin{macrocode}
%<*latex>
\newcommand*\src@input{}
\newcommand*\src@@input{}
\newcommand*\src@@@input{}
%</latex>
\let\src@input\input
%<*latex>
\def\input{\src@spec\@ifnextchar\bgroup\src@@input\@@input}%
%    \end{macrocode}
%    \Com{@@input} is \LaTeX's alias for \TeX's \Com{input} command.
%    \begin{macrocode}
\def\src@@input#1{%
    \expandafter\src@@@input\expandafter{\CurrentInput}{#1}%
}
\def\src@@@input#1#2{%
    \srcInputHook{#2}%
    \src@before@file@hook
    \src@input{#2}%
    \src@after@file@hook{#1}%
}
%</latex>
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\Input}
%    \begin{macrocode}
%<*tex>
\def\Input#1{%
    \expandafter\src@Input\expandafter{\CurrentInput}{#1}%
}
\def\src@Input#1#2{%
    \srcInputHook{#2}%
    \src@before@file@hook
    \src@input #2
    \src@after@file@hook{#1}%
}
%</tex>
%    \end{macrocode}
%    For \LaTeX, \Com{Input} is just an alias for \Com{input}:
%    \begin{macrocode}
%<*latex>
\newcommand\Input{}
\let\Input\input
%</latex>
%    \end{macrocode}
%    \end{macro}
%    Hook into `everypar'. This should concatenate the \Com{src@spec} with
%    whatever those token lists contained before, just in case they were not
%    empty token lists (hoping that later hooks will do the same). David Kastrup
%    writes in \url{<x5ekpmxh2j.fsf@lola.goethe.zz>}:
%    \begin{quote}
%    You need \emph{two} new tokens
%    for a proper subversion.  One to save the old meaning in when the
%    package is loaded, and one to refer to [\dots] the old meaning at
%    the time the package is running, even if somebody else subverts the
%    \Com{everypar} token again.
%    \end{quote}
%    \begin{macrocode}
\ifsrc@everypar@
%<latex>    \newcommand*\src@old@everypar{}
    \let\src@old@everypar\everypar
    \newtoks\src@new@everypar
    \let\everypar\src@new@everypar
    \everypar\expandafter{\the\src@old@everypar}
    \src@old@everypar{\the\src@new@everypar\src@spec}
\fi
%    \end{macrocode}
%    Use the `nomath' option to disable the following:
%    \begin{macrocode}
\ifsrc@everymath@
%<*latex>
    \def\@tempa#1\the\everymath#2\delimiter{{#1\src@spec\the\everymath#2}}
    \frozen@everymath=\expandafter\@tempa\the\frozen@everymath\delimiter
%</latex>
%<*tex>
    \everymath\expandafter{\the\everymath\src@spec}
%</tex>
\fi
%    \end{macrocode}
%    \begin{macro}{\bibliography}
%    Hook into the \Com{bibliography} command:
%    \begin{macrocode}
%<*latex>
\newcommand*\src@bibliography{}
\newcommand*\src@@bibliography{}
\let\src@bibliography\bibliography
\def\bibliography#1{%
    \expandafter\src@@bibliography\expandafter{\CurrentInput}{#1}%
}
\def\src@@bibliography#1#2{%
%<latex>    \protected@xdef\CurrentInput{\jobname.bbl}%
%<tex>    \xdef\CurrentInput{\jobname.bbl}%
    \src@before@file@hook
    \src@bibliography{#2}%
    \src@after@file@hook{#1}%
}
%</latex>
%    \end{macrocode}
%    \end{macro}
%    Hook into output routine to turn off \Com{src@spec} while \Com{output} is active:
%    \begin{macrocode}
%<latex>\newcommand*\src@old@output{}
\let\src@old@output\output
\newtoks\src@new@output
\let\output\src@new@output
\output\expandafter{\the\src@old@output}
\src@old@output{\SRCOKfalse\the\src@new@output}
%<tex>\catcode`\@=12
%</package>
%    \end{macrocode}
% \Finale
\endinput