summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fink/fink.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/fink/fink.dtx')
-rw-r--r--Master/texmf-dist/source/latex/fink/fink.dtx300
1 files changed, 159 insertions, 141 deletions
diff --git a/Master/texmf-dist/source/latex/fink/fink.dtx b/Master/texmf-dist/source/latex/fink/fink.dtx
index 04f51e5684c..0c74adfb7e6 100644
--- a/Master/texmf-dist/source/latex/fink/fink.dtx
+++ b/Master/texmf-dist/source/latex/fink/fink.dtx
@@ -1,15 +1,13 @@
% \iffalse -*- mode: LaTeX -*-
%
-% fink.dtx --- Doc file for FiNK
+% fink.dtx --- Doc file for the FiNK package (code and documentation)
%
-% Copyright (C) 1999-2001 Didier Verna.
+% Copyright (C) 1999, 2000, 2001, 2002, 2007 Didier Verna.
%
-% PRCS: $Id: fink.dtx 1.21 Wed, 03 Apr 2002 12:51:24 +0200 didier $
-%
-% Author: Didier Verna <didier@epita.fr>
-% Maintainer: Didier Verna <didier@epita.fr>
+% 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 Mar 26 16:35:16 2001
+% Last Revision: Mon Jun 11 10:59:19 2007
%
% This file is part of FiNK.
%
@@ -48,7 +46,7 @@
% \fi
%
% \catcode`\¡=14
-% \CheckSum{106}
+% ^^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
@@ -65,12 +63,9 @@
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%
-% ^^A $Format: "% \\newcommand{\\version}{v$Version$}"$
-% \newcommand{\version}{v1.2}
-% ^^A $Format: "% \\newcommand{\\releasedate}{$ReleaseDate$}"$
-% \newcommand{\releasedate}{2002/04/03}
-% ^^A $Format: "% \\newcommand{\\packagecopyright}{$LaTeXCopyright$}"$
-% \newcommand{\packagecopyright}{Copyright \copyright{} 1999--2002 Didier Verna}
+% \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}
@@ -85,50 +80,53 @@
% \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 name of the file currently
-% being processed through the macro |\finkfile|. Dis packache fas orichinally
-% a hack dat I used somefere elss, but since it might be of a cheneral
-% interest, I'fe decided to make it a separate fink\ldots\par
+% 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. Now,
+% preamble of your document. This will do everything for you. Available
+% options will be described when appropriate.
%
-% \subsection{Available Options}
-% \DescribeEnv{tex}\DescribeEnv{ltx}
-% Because there's no way \TeX{} can give you back the extension of the main
-% file being processed, it is not possible to determine it automatically if
-% it's not just |tex|. To cope with this problem, these two options are
-% provided in order for you to specify the initial file's extension. For
-% instance, if you're processing a file named |foo.ltx|, you would say
-% |\usepackage[ltx]{fink}| in the preamble of your document. By default, the
-% |tex| extension is assumed.
+% \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{Available Macros}
-% \DescribeMacro{\finkextension}
-% This macro is another way of specifying the main file's extension. It takes
-% one argument, the extension of your main file. This can be useful if you
-% happen to process a file with a rilly rilly weird extension, or without any
-% extension at all. However, be cautious: if you're using this macro instead
-% of one of the options, \textbf{you must give the dot explicitly}. For
-% instance, to process a file named |foo.doh|, say this:
+% \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{fink}
-% \finkextension{.doh}
+% \usepackage[maindir=../src,mainext=ltx]{fink}
% \end{verbatim}
-% Similarly, just say |\finkextension{}| for files without any extension.
-% This macro can only be used once, in the preamble of your document. If you
-% have to use it, do so just after the package inclusion, otherwise you might
-% get a wrong filename for a while.\par
-% \DescribeMacro{\finkfile}
-% The name of the file currently being processed is kept in the |\finkfile|
-% macro. Feel free to use it in your sources. Also, remember that this macro
-% might expand to something wrong from time to time, when files are included
-% with the \TeX{} (not \LaTeX) primitive. \fink{} won't notice the inclusion
-% of these files. See the ``Caveat'' section below for more information on
-% this problem.
+% \end{macro}
+% \end{macro}
%
% \section{\auctex{} support}
% \auctex{} is a powerful major mode for editing \TeX{} documents in
@@ -141,18 +139,22 @@
% more information on this.
%
% \section{Caveat}
-% As said before, \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{} 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[v1.2] Fixed conflict with |\includegraphics|,\\
-% reported by Jim Crumley |<crumley@belka.space.umn.edu>|
-% \item[v1.1] Fixed missing 3rd arg to |\PackageError| call from |\finkextension|
+% \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{}!
@@ -161,124 +163,140 @@
% \section{The Code}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-¡ $Format: "\\ProvidesPackage{fink}[$ReleaseDate$ v$Version$"$
-\ProvidesPackage{fink}[2002/04/03 v1.2
+\ProvidesPackage{fink}[2007/06/11 2.0
Keep track of the current filename]
-% \end{macrocode}
-% \subsection{Filename macros}
-% \begin{macro}{\finkfile}
-% \begin{macro}{\finkextentsion}
-% Macros for dealing with the name of the main file:
-% ^^A \changes{v1.1}{2000/12/20}{Fix missing 3rd arg in call to
-% ^^A `PackageError}
-% \end{macro}
-% \end{macro}
-% \begin{macrocode}
-\newcommand\finkfile{}
-\def\fink@extension#1{\xdef\finkfile{\jobname#1}}
-\newcommand\finkextension[1]{
- \fink@extension{#1}
- \PackageInfo{FiNK}{main filename switched to `\finkfile'}
- \renewcommand\finkextension[1]{
- \PackageError{FiNK}{\protect\finkextension\space can only be used once}{%
- You seem to have called \protect\finkextension\space twice.\MessageBreak
- Type X to quit, remove spurious call(s) and rerun LaTeX.}}}
-\@onlypreamble\finkextension
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{family=fnk,prefix=fnk@}
% \end{macrocode}
-% \subsection{Options processing}
-% \DescribeEnv{tex}
-% \DescribeEnv{ltx}
-% These options define common extensions:
+%
+% \subsection{Main file initial settings}
+% \DescribeEnv{maindir}
+% \DescribeEnv{mainext}
% \begin{macrocode}
-\DeclareOption{tex}{\fink@extension{.tex}}
-\DeclareOption{ltx}{\fink@extension{.ltx}}
+\DeclareStringOption[\@currdir]{maindir}
+\DeclareStringOption[tex]{mainext}
+
% \end{macrocode}
-% Delaying the following message permits to emit it somewhat closer to a
-% similar one which might be generated by a call to |\finkextension|
-% afterwards.
+% 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}
-\AtEndOfPackage{\PackageInfo{FiNK}{main filename is `\finkfile'}}
+\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}
-% Let's process the options. By default, the main file's extension is `tex'.
+%
+% \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}
-\ExecuteOptions{tex}
-\ProcessOptions*
+\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}{\@finkfile}
-% \begin{macro}{\fink@setnewfile}
-% This macro prepares the name of next file to be input, and ensures we
-% get the proper extension in all cases:
-% \end{macro}
-% ^^A \changes{v1.2}{2002/03/26}{Fix conflict with |\includegraphics|
-% ^^A reported by |Jim Crumley <crumley@belka.space.umn.edu>|}
-% 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 itself |\filename@parse|, so it
-% is important that the same call in |\fink@setnewfile| only have a local
-% effect, just the time to compute the new value of |\@finkfile|.
+% \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}
-\def\fink@setnewfile#1{%
+\newcommand*\fink@prepare[1]{%
{\filename@parse{#1}%
- \xdef\@finkfile{%
- \filename@base.\ifx\filename@ext\relax tex\else\filename@ext\fi}}}
+ \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{} primitive.
+% \LaTeX's redefinition of the \TeX{} input primitive.
% \end{macro}
% \end{macro}
% \begin{macrocode}
-\def\fink@input{%
- \xdef\finkfile{\@finkfile}%
+\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}
-\def\fink@restore{\xdef\finkfile}
-
-% \end{macrocode}
-% \begin{macro}{\IfFileExists}
-% The following macro is redefined only to let \fink{} update its filename.
-% \end{macro}
-% \begin{macrocode}
-\long\def\IfFileExists#1#2#3{%
- \openin\@inputcheck#1 %
- \ifeof\@inputcheck
- \ifx\input@path\@undefined
- \def\reserved@a{#3}%
- \else
- \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
- \fi
- \else
- \closein\@inputcheck
- \edef\@filef@und{#1 }%
- \fink@setnewfile{#1}%
- \def\reserved@a{#2}%
- \fi
- \reserved@a}
+\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}
-% And finally, let's redefine the \LaTeX{} file inclusion macros:
+% \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{\finkfile}}}
-\def\@input#1{%
- \IfFileExists{#1}{%
- \expandafter\fink@input%
- \expandafter\fink@restore\expandafter{\finkfile}}{%
- %% else
- \GenericWarning{}{no file #1.}}}
+ \expandafter\fink@restore\expandafter{\finkpath}}}
% \end{macrocode}
%