diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/currfile/currfile.pdf | bin | 179660 -> 197187 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/currfile/currfile.dtx | 107 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/currfile/currfile.sty | 34 |
3 files changed, 127 insertions, 14 deletions
diff --git a/Master/texmf-dist/doc/latex/currfile/currfile.pdf b/Master/texmf-dist/doc/latex/currfile/currfile.pdf Binary files differindex 080de190a11..98c06af72d5 100644 --- a/Master/texmf-dist/doc/latex/currfile/currfile.pdf +++ b/Master/texmf-dist/doc/latex/currfile/currfile.pdf diff --git a/Master/texmf-dist/source/latex/currfile/currfile.dtx b/Master/texmf-dist/source/latex/currfile/currfile.dtx index c5e3a3f7dab..a1c159a4d53 100644 --- a/Master/texmf-dist/source/latex/currfile/currfile.dtx +++ b/Master/texmf-dist/source/latex/currfile/currfile.dtx @@ -19,7 +19,7 @@ %% This work consists of the files currfile.dtx, currfile.ins %% and the derived file currfile.sty. %% -%% $Id: currfile.dtx 2006 2011-01-03 22:54:46Z martin $ +%% $Id: currfile.dtx 2036 2011-01-09 17:51:42Z martin $ % \fi % % \iffalse @@ -29,12 +29,12 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{currfile} %<*package> - [2011/01/03 v0.3 Current input file name and path] + [2011/01/09 v0.4 Current input file name and path] %</package> % %<*driver> -\documentclass{ydoc}[2011/01/03] -\usepackage{currfile}[2011/01/03] +\documentclass{ydoc}[2011/01/09] +\usepackage{currfile}[2011/01/09] \usepackage{ifpdf} \usepackage{booktabs} \usepackage{hyperref} @@ -52,7 +52,7 @@ %</driver> % \fi % -% \CheckSum{201} +% \CheckSum{258} % % \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 @@ -76,6 +76,7 @@ % Added package option 'fink' to define the same macros as the 'fink' package. % } % \changes{v0.3}{2011/01/03}{Update to use new version of filehook.} +% \changes{v0.4}{2011/01/09}{Added if-macros and sanitized currfile macros.} % % \GetFileInfo{currfile.dtx} % @@ -119,22 +120,45 @@ % \DescribeMacro{\currfilepath} % The directory, base (name without extension), extension (without dot), name (=base+`|.|'+ext) and path (=dir+name) of the current file are provided by these macros. % This means that the macros returns the file information of the file they are used in. All macros are fully expanded, i.e.\ only hold -% text and not further macros. +% text and not further macros. They are also ``sanitized'' to ensure that all characters, especially special ones like `|_|', are taken verbatim. +% However this special characters might not be displayed correctly in all fonts. A good font is text-type (\Macro\ttfamily, \Macro\texttt{\ldots}), +% but other fonts can be used using the \pkg{url} package, e.g.: |\urlstyle{rm}\expandafter\nolinkurl\expandafter{\currfilename}|. +% % Special care is taken to keep the file information of \Macro\included files till the final \Macro\clearpage command, so that page header and footer of the last page % will hold the correct data. % % Since v0.2 all files are are taken into account, i.e.\ files read using \Macro\input, \Macro\include, \Macro\InputIfFileExists, \Macro\usepackage, \Macro\RequirePackage and even % \Macro\LoadClass and similar macros. Before v0.2 only \Macro\input or \Macro\include and the main file were taken into account. % +% % This package uses the \pkg{filehook} package written by the same author. See there for possible incompatibilities with classes or other packages. % % More detailed information can be found in the implementation section \ref{sec:impl} if required. % +% \DescribeMacro{\ifcurrfiledir}{<text>}{<true>}{<false>} +% \DescribeMacro{\ifcurrfilebase}{<text>}{<true>}{<false>} +% \DescribeMacro{\ifcurrfileext}{<text>}{<true>}{<false>} +% \DescribeMacro{\ifcurrfilename}{<text>}{<true>}{<false>} +% \DescribeMacro{\ifcurrfilepath}{<text>}{<true>}{<false>} +% This\marginpar{\raggedright New in v0.4 from 2011/01/09} if-macros allow the comparison of \meta{text} with the current file directory, base, extension, name and path, respectively. +% The \meta{text} is fully expanded and sanitized for the comparison. Example: |\ifcurrfileext{cfg}{I'm in a config file}{No config file!}| +% +% \DescribeMacro{\ifcurrfile}{<currfile macro or text>}{<text>}{<true>}{<false>} +% Compares the given \meta{currfile macro or text} with \meta{text}. Both are taken as file name parts and are fully expanded and sanitized before the comparison. +% This general macro is a little slower then the specialised macros above but might be useful to compare different file names/paths where non of the two is the current file. +% Note that the all comparisons are done insensitive to the catcodes of the texts, which is what users want. Different comparision macros (|\ifx|, \pkg{ifthenelse}) might not do this. +% % \subsection*{Package Options} % The package provides two options \opt{mainext} and \opt{maindir} which can be used to provide the extension and directory of the main file. % This is required if the above macros should be used for the main file itself and if this does has a file extension other than `|.tex|' (e.g.\ a |.dtx| file) % or is not located in the current directory. To provide support for the macros defined by the \pkg{fink} package (see section~\ref{sec:fink}) a \pkg{fink} option exists. % +% \section{Usage inside file hooks} +% This package uses the `EveryFile' hooks of the \pkg{filehook} package to update its macros. +% Special care is taken to do this in a way so that the macros can be used safely inside other hook code, including other `EveryFile' hooks. +% Please note that the `AtEndOfPackageFile' and `AtEndOfClassFile' hooks are executed after `AtEndOfEveryFile' +% and therefore the |currfile| macros will hold the values of the parent file, not of that package or class file. +% % \section{Compatibility with the \texttt{fink} package}\label{sec:fink} % The \pkg{fink} package (\emph{fi}le \emph{n}ame \emph{k}eeper) provides a similar functionality. It has inspired this package in several points (e.g.\ package % options). However, it does not exclude package and other preamble files and does not take care to change the filename \emph{after} the \Macro\clearpage of @@ -192,7 +216,7 @@ \DeclareBoolOption[false]{fink}% }% \DeclareVoidOption{force}{\PassOptionsToPackage{force}{filehook}} -\RequirePackage{filehook}[2011/01/03] +\RequirePackage{filehook}[2011/01/09] \ProcessKeyvalOptions*\relax \begingroup @@ -230,7 +254,9 @@ % \begin{macrocode} \def\currfile@set#1{% \begingroup - \filename@parse{#1}% + \edef\@tempa{#1}% + \@onelevel@sanitize\@tempa + \expandafter\filename@parse\expandafter{\@tempa}% \global\let\currfiledir\filename@area \global\let\currfilebase\filename@base \xdef\currfileext{\ifx\filename@ext\relax tex\else\filename@ext\fi}% @@ -311,6 +337,69 @@ % \end{macro} % % +% \subsection{If Macros} +% \begin{macro}{\ifcurrfilename} +% \begin{macrocode} +\newcommand*\ifcurrfilename{\begingroup\currfile@if\currfilename} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifcurrfilebase} +% \begin{macrocode} +\newcommand*\ifcurrfilebase{\begingroup\currfile@if\currfilebase} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifcurrfileext} +% \begin{macrocode} +\newcommand*\ifcurrfileext{\begingroup\currfile@if\currfileext} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifcurrfiledir} +% \begin{macrocode} +\newcommand*\ifcurrfiledir{\begingroup\currfile@if\currfiledir} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifcurrfilepath} +% \begin{macrocode} +\newcommand*\ifcurrfilepath{\begingroup\currfile@if\currfilepath} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ifcurrfile}[1]{currfile macro or text} +% Expands and sanitizes the first argument and then calls the internal if-macro +% with the result. +% \begin{macrocode} +\newcommand*\ifcurrfile[1]{% + \begingroup + \edef\@tempb{#1}% + \@onelevel@sanitize\@tempb + \currfile@if\@tempb +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\currfile@if}[2]{currfile macro to compare}{compare text} +% Expands the text and sanitize it to ensure correct neutral catcodes. +% Then it temp macro is compared to the given currfile macro. +% \begin{macrocode} +\def\currfile@if#1#2{% + \edef\@tempa{#2}% + \@onelevel@sanitize\@tempa + \ifx\@tempa#1% + \endgroup + \expandafter\@firstoftwo + \else + \endgroup + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% % \subsection{Fink Macros} % % The \pkg{fink} option defines all \pkg{fink} package macros to use the ones provided @@ -332,7 +421,7 @@ \@ifpackageloaded{fink}{% \def\fink@restore#1{}% }{% - \@namedef{ver@fink.sty}{2011/01/03}% + \@namedef{ver@fink.sty}{2011/01/09}% \expandafter\edef\csname opt@fink.sty\endcsname{% maindir=\currfile@maindir,mainext=\currfile@mainext }% diff --git a/Master/texmf-dist/tex/latex/currfile/currfile.sty b/Master/texmf-dist/tex/latex/currfile/currfile.sty index cc76c8bf2c3..e686b93fe32 100644 --- a/Master/texmf-dist/tex/latex/currfile/currfile.sty +++ b/Master/texmf-dist/tex/latex/currfile/currfile.sty @@ -18,10 +18,10 @@ %% This work consists of the files currfile.dtx, currfile.ins %% and the derived file currfile.sty. %% -%% $Id: currfile.dtx 2006 2011-01-03 22:54:46Z martin $ +%% $Id: currfile.dtx 2036 2011-01-09 17:51:42Z martin $ \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{currfile} - [2011/01/03 v0.3 Current input file name and path] + [2011/01/09 v0.4 Current input file name and path] \RequirePackage{kvoptions} \SetupKeyvalOptions{family=currfile,prefix=currfile@} @@ -39,7 +39,7 @@ \DeclareBoolOption[false]{fink}% }% \DeclareVoidOption{force}{\PassOptionsToPackage{force}{filehook}} -\RequirePackage{filehook}[2011/01/03] +\RequirePackage{filehook}[2011/01/09] \ProcessKeyvalOptions*\relax \begingroup @@ -59,7 +59,9 @@ } \def\currfile@set#1{% \begingroup - \filename@parse{#1}% + \edef\@tempa{#1}% + \@onelevel@sanitize\@tempa + \expandafter\filename@parse\expandafter{\@tempa}% \global\let\currfiledir\filename@area \global\let\currfilebase\filename@base \xdef\currfileext{\ifx\filename@ext\relax tex\else\filename@ext\fi}% @@ -95,6 +97,28 @@ \currfile@set{\currfile@maindir\jobname.\currfile@mainext} \currfile@push \let\currfile@stackinit\currfile@stack +\newcommand*\ifcurrfilename{\begingroup\currfile@if\currfilename} +\newcommand*\ifcurrfilebase{\begingroup\currfile@if\currfilebase} +\newcommand*\ifcurrfileext{\begingroup\currfile@if\currfileext} +\newcommand*\ifcurrfiledir{\begingroup\currfile@if\currfiledir} +\newcommand*\ifcurrfilepath{\begingroup\currfile@if\currfilepath} +\newcommand*\ifcurrfile[1]{% + \begingroup + \edef\@tempb{#1}% + \@onelevel@sanitize\@tempb + \currfile@if\@tempb +} +\def\currfile@if#1#2{% + \edef\@tempa{#2}% + \@onelevel@sanitize\@tempa + \ifx\@tempa#1% + \endgroup + \expandafter\@firstoftwo + \else + \endgroup + \expandafter\@secondoftwo + \fi +} \ifcurrfile@fink \def\finkfile{\currfilename}% \def\finkdir{\currfiledir}% @@ -104,7 +128,7 @@ \@ifpackageloaded{fink}{% \def\fink@restore#1{}% }{% - \@namedef{ver@fink.sty}{2011/01/03}% + \@namedef{ver@fink.sty}{2011/01/09}% \expandafter\edef\csname opt@fink.sty\endcsname{% maindir=\currfile@maindir,mainext=\currfile@mainext }% |