summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fink/fink.dtx
blob: 0c74adfb7e66bc1d5291ea1ae8076792bab3bf79 (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
% \iffalse                                                 -*- mode: LaTeX -*-
%
% fink.dtx --- Doc file for the FiNK package (code and documentation)
%
% Copyright (C) 1999, 2000, 2001, 2002, 2007 Didier Verna.
%
% Author:        Didier Verna <didier@lrde.epita.fr>
% Maintainer:    Didier Verna <didier@lrde.epita.fr>
% Created:       Thu Sep 23 18:23:48 1999
% Last Revision: Mon Jun 11 10:59:19 2007
%
% This file is part of FiNK.
%
% FiNK may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.1
% 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.1 or later is part of all distributions of LaTeX
% version 1999/06/01 or later.
%
% FiNK consists of all files listed in the file `README'.
%
%
% Commentary:
%
% Contents management by FCM version 0.1.
%
%
% Code:
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
% \OnlyDescription
% \CodelineIndex
% \RecordChanges
\newcommand{\fink}{%
  \mbox{\fontfamily{ptm}\fontseries{b}\fontshape{it}\selectfont%
    F\hspace{-.4ex}\protect\raisebox{-.5ex}{\textmd{i}}\hspace{0.2ex}NK}%
  }
\begin{document}
\DocInput{fink.dtx}
\end{document}
%</driver>
%
% \fi
%
% \catcode`\¡=14
% ^^A\CheckSum{152}
%% \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         \~}
%
% \newcommand{\version}{2.0}
% \newcommand{\releasedate}{2007/06/11}
% \newcommand{\packagecopyright}{Copyright \copyright{} 1999, 2000, 2001, 2002, 2007 Didier Verna}
% \newcommand{\auctex}{AUC-\TeX}
% \MakeShortVerb{\|}
% \date{\today}
% \title{\fink{} -- the \LaTeXe{} \textbf{Fi}le \textbf{N}ame \textbf{K}eeper
% \thanks{This document describes \fink{} \version, release date
% \releasedate.}}
% \author{Didier Verna\\
% \texttt{mailto:didier@lrde.epita.fr}\\
% \texttt{http://www.lrde.epita.fr/\~{}didier/}}
% \maketitle
%
% \section{Description}
% This package is a real fink indeed: it looks over your shoulder and keeps
% track of files |\input|'ed (the \LaTeX{} way) or |\include|'ed in your
% document. You then have a permanent access to the directory, name and
% extension of the file currently being processed through several macros. Dis
% packache fas orichinally a hack dat I used somefere elss, but since it might
% be off a cheneral interest, I'fe decided to make it a separate
% fink\ldots\par
% The \fink{} package is \packagecopyright{}, and distributed under the terms
% of the LPPL license.
%
% \section{User Interface}
% To use the package, simply say |\usepackage[|\meta{options}|]{fink}| in the
% preamble of your document. This will do everything for you. Available
% options will be described when appropriate.
%
% \subsection{Retrieving the current file's name components}
% \begin{macro}{\finkdir}
%   \begin{macro}{\finkbase}
%     \begin{macro}{\finkext}
%       The file currently being processed is described by the macros
%       |\finkdir|, |\finkbase| and |\finkext| which expand (as you may have
%       guessed) to the directory, base name (sans extension), and extension
%       of the file.
%     \end{macro}
%   \end{macro}
% \end{macro}
% \begin{macro}{\finkfile}
%   \begin{macro}{\finkpath}
%     Additionally, the macro |\finkfile| is defined to be
%     |\finkbase|.|\finkext| (as in previous versions), and the macro
%     |\finkpath| (new in version 2.0) is defined to be |\finkdir\finkfile|.
%     Feel free to use these macros in your sources.
%   \end{macro}
% \end{macro}
%
% \subsection{Main file's name components}
% \begin{macro}{maindir}
%   \begin{macro}{mainext}
%     Because there's no way \TeX{} can give you back information about the
%     file being processed (apart from its base name), \fink{} provides the
%     options |maindir| (defaults to |./|) and |mainext| (defaults to |tex|)
%     for changing the directory and the extension of the main source file.
%     For instance, suppose your source file is in |src/foo.ltx| and you are
%     compiling in |pdf/|. You can then use the package as follows:
% \begin{verbatim}
% \usepackage[maindir=../src,mainext=ltx]{fink}
% \end{verbatim}
%   \end{macro}
% \end{macro}
%
% \section{\auctex{} support}
% \auctex{} is a powerful major mode for editing \TeX{} documents in
% \textsf{Emacs} or \textsf{XEmacs}. In particular, it provides automatic
% completion of macro names once they are known. \fink{} supports \auctex{}
% by providing a style file named \texttt{fink.el} which contains \auctex{}
% definitions for the relevant macros. This file should be installed to a
% location where \auctex{} can find it (usually in a subdirectory of your
% \LaTeX{} styles directory). Please refer to the \auctex{} documentation for
% more information on this.
%
% \section{Caveat}
% \fink{} cannot follow files included with the \TeX{} |\input| primitive.
% That's because \TeX{} has a very insensible way of defining primitives whose
% argument parsing syntax is not available for macros. As a consequence, it's
% almost impossible to redefine the |\input| primitive without breaking its
% syntax (one would have to parse the characters one by one, and I'm not ready
% to do so\ldots). \fink{} currently does not follow auxiliary files either.
%
% \section{Changes}
% \begin{itemize}
% \item[v2.0] New macros |\finkdir|, |\finkbase|, |\finkext| and |\finkpath|
%   suggested by Alain Schremmer\\
%   New options |mainext| and |maindir|, use |kvoptions| for options
%   management
% \item[v1.2] Fixed conflict with |\includegraphics|, reported by Jim Crumley
% \item[v1.1] Fixed missing 3rd arg to |\PackageError| call from
%   |\finkextension|
% \end{itemize}
%
% \StopEventually{\par Well, I think that's it. Enjoy using \fink{}!
%   \vfill\hfill\small \packagecopyright{}.}
%
% \section{The Code}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fink}[2007/06/11 2.0
                       Keep track of the current filename]

\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=fnk,prefix=fnk@}

%    \end{macrocode}
%
% \subsection{Main file initial settings}
% \DescribeEnv{maindir}
% \DescribeEnv{mainext}
%    \begin{macrocode}
\DeclareStringOption[\@currdir]{maindir}
\DeclareStringOption[tex]{mainext}

%    \end{macrocode}
% The following is for backward compatibility only (not documented anymore).
% It provides support for the old |tex| and |ltx| options (still functionnal),
% and for the |\finkextension| macro. However, this macro is now defined to
% trigger an error, begging the user to use the new option instead.
%    \begin{macrocode}
\newcommand*\@fink@mainext[1]{\setkeys{fnk}{mainext={#1}}}
\newcommand*\fink@mainext{%
  \expandafter\@fink@mainext\expandafter{\CurrentOption}}
\DeclareVoidOption{tex}{\fink@mainext}
\DeclareVoidOption{ltx}{\fink@mainext}

\newcommand*\finkextension[1]{%
  \PackageError{FiNK}{%
    \protect\finkextension\space shouldn't be used anymore.\MessageBreak
    Please use the `mainext' package option instead.}{%
    No big deal right ?\MessageBreak
    Type X to quit and modify your source.}}
\@onlypreamble\finkextension

\ProcessKeyvalOptions*

%    \end{macrocode}
%
% \subsection{File's name components macros}
% \begin{macro}{\finkdir}
%   \begin{macro}{\finkbase}
%     \begin{macro}{\finkext}
%       \begin{macro}{\finkfile}
%         \begin{macro}{\finkpath}
%           We declare the user-level macros here. |\fink@file| is used to
%           compute file names, possibly with no extension.
%       \end{macro}
%       \end{macro}
%     \end{macro}
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\finkdir{\fnk@maindir}
\newcommand*\finkbase{\jobname}
\newcommand*\finkext{\fnk@mainext}

\newcommand*\finkfile{}
\newcommand*\fink@file[2]{#1\ifx\\#2\\\else.#2\fi}
\xdef\finkfile{\fink@file{\jobname}{\fnk@mainext}}

\newcommand*\finkpath{}
\xdef\finkpath{\finkdir\finkfile}

\PackageInfo{FiNK}{main file set to "\finkpath"}

%    \end{macrocode}
%
% \subsection{Commands overriding}
% \begin{macro}{\fink@prepare}
%   This macro prepares the name of next file to be input. We arrange to setup
%   a complete filename, including directory and extension.
%
%   As of version 1.2, this macro performs in a group of its own. This fixes a
%   problem that appeared when using |\includegraphics| with a filename with an
%   explicit extension. |\includegraphics| calls |\filename@parse| itself, so
%   it is important that the same call in |\fink@prepare| only have a local
%   effect, just the time to compute the new values for the |\fink@next*|
%   macros.
% \end{macro}
%    \begin{macrocode}
\newcommand*\fink@prepare[1]{%
  {\filename@parse{#1}%
    \xdef\fink@nextdir{%
      \ifx\filename@area\@empty%
        \fnk@maindir%
      \else%
        \fnk@maindir\filename@area%
      \fi}%
    \xdef\fink@nextbase{\filename@base}%
    \xdef\fink@nextext{\ifx\filename@ext\relax tex\else\filename@ext\fi}%
    \xdef\fink@nextfile{\fink@file{\fink@nextbase}{\fink@nextext}}%
    \xdef\fink@nextpath{\fink@nextdir\fink@nextfile}}}

%    \end{macrocode}
% \begin{macro}{\fink@input}
%   \begin{macro}{\fink@restore}
%     These macros are defined for a convenient use of |\expandafter|. They
%     save and restore the current filename. Remember that |\@@input| is
%     \LaTeX's redefinition of the \TeX{} input primitive.
%   \end{macro}
% \end{macro}
%    \begin{macrocode}
\newcommand*\fink@input{%
  \xdef\finkdir{\fink@nextdir}%
  \xdef\finkbase{\fink@nextbase}%
  \xdef\finkext{\fink@nextext}%
  \xdef\finkfile{\fink@nextfile}%
  \xdef\finkpath{\fink@nextpath}%
  \@@input\@filef@und}
\newcommand*\fink@restore[1]{%
  {\filename@parse{#1}%
    \xdef\finkdir{\filename@area}%
    \xdef\finkbase{\filename@base}%
    \xdef\finkext{\filename@ext}%
    \xdef\finkfile{\fink@file{\finkbase}{\finkext}}
    \xdef\finkpath{\finkdir\finkfile}}}

%    \end{macrocode}
% Note: in earlier versions, we redefined |\IfFileExists| to prepare the
% name of the next file, but this is bad because it can be used outside of
% \fink{}'s scope. We also redefined |\@input|, but neither |\include| nor
% |\input| use it.
% \begin{macro}{\InputIfFileExists}
%   \LaTeX's |\input| and |\include| commands use |\InputIfFileExists|, so
%   let's redefine it here:
% \end{macro}
%    \begin{macrocode}
\long\def\InputIfFileExists#1#2{%
  \IfFileExists{#1}{%
    #2\@addtofilelist{#1}%
    \fink@prepare{#1}%
    \expandafter\fink@input%
    \expandafter\fink@restore\expandafter{\finkpath}}}

%    \end{macrocode}
%
% ^^A \PrintChanges
% ^^A \PrintIndex
% \Finale
%
% ^^A fink.dtx ends here.