texlive[53932] Master/texmf-dist: import (26feb20)

commits+karl at tug.org commits+karl at tug.org
Wed Feb 26 23:10:13 CET 2020


Revision: 53932
          http://tug.org/svn/texlive?view=revision&revision=53932
Author:   karl
Date:     2020-02-26 23:10:12 +0100 (Wed, 26 Feb 2020)
Log Message:
-----------
import (26feb20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/import/import.pdf
    trunk/Master/texmf-dist/doc/latex/import/import.tex
    trunk/Master/texmf-dist/tex/latex/import/import.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/import/README

Added: trunk/Master/texmf-dist/doc/latex/import/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/import/README	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/import/README	2020-02-26 22:10:12 UTC (rev 53932)
@@ -0,0 +1,15 @@
+import.sty    Version 6.0    22-Jan-2020  
+Donald Arseneau  (asnd at triumf.ca)  Vancouver, Canada.
+
+This software is in the public domain; free of any restrictions.
+All right are waived. No obligations are acknowleged.
+
+Two new LaTeX commands, "\import {<full-path>} {<file>}" and 
+"\subimport {<path-extension>} {<file>}" are defined to input 
+a file from another directory, allowing that file to find its 
+own inputs (using \input, \includegraphics etc.) in that directory.
+Alias command names are "\inputfrom" and "\subinputfrom".
+
+Also provided are \includefrom and \subincludefrom, which are
+based on the \include command, rather than \input.
+


Property changes on: trunk/Master/texmf-dist/doc/latex/import/README
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/import/import.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/import/import.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/import/import.tex	2020-02-26 22:09:56 UTC (rev 53931)
+++ trunk/Master/texmf-dist/doc/latex/import/import.tex	2020-02-26 22:10:12 UTC (rev 53932)
@@ -8,7 +8,7 @@
 \usepackage{textcomp}
 \usepackage{booktabs}
 \usepackage{microtype}
-\usepackage{hyperref}
+%\usepackage{hyperref}
 
 \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
 \newcommand*{\pkg}[1]{\textsf{#1}}
@@ -22,21 +22,15 @@
 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
 \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
 \newcommand*{\oarg}[1]{\texttt{[}\meta{#1}\texttt{]}}
-\newcommand*{\BibTeX}{Bib\kern-0.08em\TeX\@\xspace}
-\newcommand*{\BigTeX}{Big\kern-0.08em\TeX\@\xspace}
+\renewcommand{\^}{\nolinebreak[2]}
+%\addtokomafont{title}{\rmfamily}
 
-\pdfstringdefDisableCommands{%
-  \def\BibTeX{BibTeX\xspace}%
-  \def\BigTeX{BigTeX\space}%
-}
+\title{The import package}
+\author{Donald Arseneau  (\texttt{asnd at triumf.ca})}
+\date{Version 6.0, \quad 22--Jan--2020}
+\setlength{\parskip}{3pt plus 2pt}
 
-\addtokomafont{title}{\rmfamily}
 
-\title{The \pkg{import} package\thanks{This manual corresponds to \pkg{import}~v5.1, dated~23--Mar--2009.}}
-\author{Donald Arseneau  (\mail{asnd at triumf.ca})}
-\date{23--Mar--2009}
-
-
 \begin{document}
 
 \maketitle
@@ -43,60 +37,84 @@
 
 This software is in the public domain; free of any restrictions.
 
-Two new \LaTeX\ commands, ``\cmd{\import}\marg{full\_path}\marg{file}''\\ and
-``\cmd{\subimport}\-\marg{path\_extension}\marg{file}'' are defined to input a file 
-from another directory, allowing that file to find its own inputs
-(using ``\cmd{\input}'', ``\cmd{\includegraphics}'' etc.)\ in that directory.
+\medskip
 
+Two new \LaTeX\ commands:
+\begin{verse}
+ \cmd{\import} \marg{full-path} \marg{file}\hspace{8em} and\\[2pt]
+ \cmd{\subimport} \marg{path-extension} \marg{file}
+\end{verse}
+are defined to input a file from another directory, allowing that file
+to find its own inputs (using \cmd{\input}, \cmd{\includegraphics}
+etc.\@) in that directory.
+
 Alias command names are ``\cmd{\inputfrom}'' and ``\cmd{\subinputfrom}''.
+(If \cmd{\import} was defined previously, it will not be redefined.)
+Also provided are the similar commands ``\cmd{\includefrom}'' and
+``\cmd{\subincludefrom}'', which are based on the \cmd{\include} command,
+rather than \cmd{\input}. 
 
-Also provided are ``\cmd{\includefrom}'' and ``\cmd{\subincludefrom}'', which are
-based on the ``\cmd{\include}'' command, rather than ``\cmd{\input}''.  There are
-also ``\texttt{*}'' variants described below.
-
-For example, if a remote file ``\texttt{/usr5/friend/work/report.tex}'' has contents:
+For example, if a remote file \texttt{/user/friend/work/report.tex} has
+contents:
 %
 \begin{verbatim}
-My graph: \includegraphics{picture}
-\input{explanation}
+     My graph: \includegraphics{picture}
+     \input{explanation}
 \end{verbatim}
 %
-then you can safely input that file in your own document with the command
-``\verb+\import{/usr5/friend/work/}{report}+''; the explanation and picture will 
-be taken from the ``\texttt{/usr5/friend/work/}'' directory.
+then you can input that file to a document with 
+\verb+\import{/user/friend/+\^\verb+work/}+\^\verb+{report}+ 
+so that both the explanation and picture will be taken from the 
+\texttt{/user/friend/\^work/} directory.
 
-The ``\cmd{\subimport}'' command takes a relative path instead of a full absolute
-file path, and it allows imported files to import files themselves, using
-their own directory as the root of another ``\meta{path\_extension}''. Do not use
-both ``\cmd{\import}'' and ``\cmd{\subimport}'' in the same file.
-
+The \meta{full-path} argument for \cmd{\import} can be a full absolute path
+or a relative path starting from the main working directory for the document.
+The \cmd{\subimport} command facilitates nesting of file imports. It takes a
+relative \meta{path-extension} based on the location of the current imported file.
 For example, if a file is imported (using either command) from directory
-``\texttt{abc/}'' and that file contains the command ``\verb+\subimport{lmn/}{xyz}+'' then
-file ``\texttt{abc/lmn/xyz.tex}'' is input, and any ``\cmd{\input}'' commands in that file
-will read files from directory ``\texttt{abc/lmn/}''. 
+\texttt{abc/} and that file contains the command \verb+\subimport{lmn/}{xyz}+ then
+file \texttt{abc/lmn/xyz.tex} is input, and any \cmd{\input} commands in that file
+will read files from directory \texttt{abc/lmn/}.\footnote{~Note that the sub-import
+  path is merely appended to the current import path.  Syntactical mistakes from this
+  method may be corrected by \cmd{\import at path@fix}.}
 
-Note that the sub-import path is merely appended to the current import
-path.  Mistakes from this method must be rectified by ``\cmd{\import at path@fix}''.
+Depending on on how your \TeX\ system is configured, if a file does not
+exist in the specified import directory, it will be looked for in previous
+import directories (when nesting \cmd{\subimport} files), then in any
+directory listed in the pre-existing \cmd{\input at path}, then in the current 
+working directory, and finally in the \texttt{TEXINPUTS} path. Therefore, for 
+\cmd{\import} and for other \cmd{\input} used within an imported file,
+a file found on the path of import(s) will be read in preference to others with
+the same name located elsewhere. So here is the real behavior of the previous
+example: Given the nested sequence:
+\begin{verse}
+\verb+\import{abc/}{one}+\quad (in main document);\\
+\verb+\subimport{lmn/uvw/}{two}+\quad (in file \texttt{abc/one.tex});\\
+\verb+\input{three}+\quad (in file \texttt{abc/lmn/uvw/two.tex});
+\end{verse}
+\LaTeX\ first looks for \texttt{abc/lmn/uvw/three} (or \texttt{abc/lmn/uvw/three.tex});\\
+if not found, it tries \texttt{abc/three} (or \texttt{abc/three.tex});\\
+if still not found, it looks in the \cmd{\input at path}, if there was one defined;\\
+if \cmd{\input at path} was not defined, or if the file was not found on it,
+\LaTeX\ then tries to open \texttt{three} in the main document directory;\\
+finally, if still not found, it searches the \texttt{TEXINPUTS} search path.
 
-Depending on on how your \TeX\ system is configured, if a file with the 
-same name as the import file exists in the current directory or in the 
-\texttt{TEXINPUTS} path, that other file will be read in preference to one in the 
-import directory.  So here is the real behavior of the previous example:
-Given the sequence ``\verb+\import{abc/}{one}+'', ``\verb+\subimport{lmn/uvw/}{two}+'' (in
-file \texttt{one}), ``\verb+\input{three}+'' (in file \texttt{two}), \LaTeX\ first looks for \texttt{three.tex}
-in the \texttt{TEXINPUTS} search path; if not found, it tries ``\texttt{abc/lmn/uvw/three}'';
-if that doesn't exist, it tries ``\texttt{abc/three}''; if still not found, it tries
-the defined ``\cmd{\input at path}'', if there is one.
+Historically, `star' versions of the commands were defined (to avoid searching
+the \texttt{TEXINPUTS} path) but now the ``$*$'' is ignored.
 
-To avoid searching the \texttt{TEXINPUTS} path when importing files, use the `star'
-versions of the commands: ``\cmd{\import*}'' and ``\cmd{\subimport*}''.
 
-A hook ``\cmd{\import at path@fix}'' is provided to reformat the import path
+A command  ``\cmd{\import at path@fix}'' is provided to reformat the import path
 to fit the syntax of a particular operating system.  It \emph{could} be
-defined to convert unix-style path names to the local format, but 
-all it does now is remove ``\texttt{][}'' from VMS sub-import directories.
+defined to convert unix-style path names to the local format. The default
+definition ensures paths end with ``\texttt{/}'' on most systems, but
+removes ``\texttt{]\hspace{-2pt}[}'' from within sub-import directory paths
+on VMS systems.
 
-Presently, the paths are defined ``locally'' so input files must have 
+Note that the import package works by manipulating the internal `commands'
+\cmd{\input at path} and \cmd{\Ginput at path}, so may behave badly if you
+redefine them manually, or via another package, within the document.
+
+Presently, the paths are defined `locally' so input files must have 
 balanced grouping.
 
 \end{document}

Modified: trunk/Master/texmf-dist/tex/latex/import/import.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/import/import.sty	2020-02-26 22:09:56 UTC (rev 53931)
+++ trunk/Master/texmf-dist/tex/latex/import/import.sty	2020-02-26 22:10:12 UTC (rev 53932)
@@ -1,63 +1,48 @@
-% import.sty  Ver 5.1  23-Mar-2009  Donald Arseneau  (asnd at triumf.ca)
+% import.sty  Ver 6.0  22-Jan-2020  Donald Arseneau  (asnd at triumf.ca)
 %
 % This software is in the public domain; free of any restrictions.
 %
-% Two new \LaTeX\ commands, "\import {full_path} {file}" and 
-% "\subimport {path_extension} {file}" are defined to input a file 
+% Two new \LaTeX\ commands, "\import {<full-path>} {<file>}" and 
+% "\subimport {<path-extension>} {<file>}" are defined to input a file 
 % from another directory, allowing that file to find its own inputs
 % (using "\input", "\includegraphics" etc.) in that directory.
-% 
 % Alias command names are "\inputfrom" and "\subinputfrom".
 %
 % Also provided are "\includefrom" and "\subincludefrom", which are
-% based on the "\include" command, rather than "\input".  There are
-% also "*" variants described below.
+% based on the "\include" command, rather than "\input".
 %
-% For example, if a remote file "/usr5/friend/work/report.tex" has contents:
+% For example, if a remote file "/user/friend/work/report.tex" has contents:
 %
 %      My graph: \includegraphics{picture}
 %      \input{explanation}
 %
 % then you can safely input that file in your own document with the command
-% "\import{/usr5/friend/work/}{report}"; the explanation and picture will 
-% be taken from the "/usr5/friend/work/" directory.
+% "\import{/user/friend/work/}{report}"; the explanation and picture will 
+% be taken from the "/user/friend/work/" directory.
 %
-% The "\subimport" command takes a relative path instead of a full absolute
-% file path, and it allows imported files to import files themselves, using
-% their own directory as the root of another "path_extension". Do not use
-% both "\import" and "\subimport" in the same file.
+% The <full-path> argument for "\import" can be a full absolute path
+% or a relative path starting from the main working directory for the document.
+% The "\subimport" command facilitates nesting of file imports. It takes a
+% relative <path-extension> based on the location of the current file.
 %
 % For example, if a file is imported (using either command) from directory
 % "abc/" and that file contains the command "\subimport{lmn/}{xyz}" then
 % file "abc/lmn/xyz.tex" is input, and any "\input" commands in that file
-% will read files from directory "abc/lmn/". 
+% will read files from directory "abc/lmn/".
 %
-% Note that the sub-import path is merely appended to the current import
-% path.  Mistakes from this method must be rectified by "\import at path@fix".
+% Find more documentation in import.tex or import.pdf.
 %
-% Depending on on how your \TeX\ system is configured, if a file with the 
-% same name as the import file exists in the current directory or in the 
-% TEXINPUTS path, that other file will be read in preference to one in the 
-% import directory.  So here is the real behavior of the previous example:
-% Given the sequence "\import{abc/}{one}", "\subimport{lmn/uvw/}{two}" (in
-% file one), "\input{three}" (in file two), \LaTeX\ first looks for three.tex
-% in the TEXINPUTS search path; if not found, it tries "abc/lmn/uvw/three";
-% if that doesn't exist, it tries "abc/three"; if still not found, it tries
-% the defined "\input at path", if there is one.
-%
-% To avoid searching the TEXINPUTS path when importing files, use the `star'
-% versions of the commands: "\import*" and "\subimport*".
-%
 % A hook "\import at path@fix" is provided to reformat the import path
 % to fit the syntax of a particular operating system.  It *could* be
-% defined to convert unix-style path names to the local format, but 
-% all it does now is remove "][" from VMS sub-import directories.
+% defined to convert unix-style path names to the local format. The default
+% definition ensures paths end with "/" on most systems, but removes
+% "][" from within sub-import directory paths on VMS systems.
 %
 % Presently, the paths are defined ``locally'' so input files must have 
 % balanced grouping.
 %====================== END INSTRUCTIONS ===========================
 
-\ProvidesPackage{import}[2009/03/23 \space  v 5.1]
+\ProvidesPackage{import}[2020/01/22 \space  v 6.0]
 \ProcessOptions
 
 \@ifundefined{import}{%
@@ -72,8 +57,9 @@
 \newcommand{\includefrom}{\global\let\import at path\@empty \@doimport\include}
 \newcommand{\subincludefrom}{\@doimport\include}
 
+% Consume now-meaningless "*"
 \def\@doimport#1{\@ifstar
-  {\@sub at import#1\@iffileonpath}{\@sub at import#1\IfFileExists}}
+  {\@sub at import#1\im at iffileexists}{\@sub at import#1\im at iffileexists}}
 
 % #1 = import command,  #2 = switch for *,  #3 = import path extension
 \def\@sub at import#1#2#3{%
@@ -94,10 +80,14 @@
 % #6 = previous \IfFileExists.   #7 = file name.
 %
 \def\@import#1#2#3#4#5#6#7{%
-  \gdef\import at path{#4}%
-  \protected at edef\input at path{{\import at path@fix{#4}}#2}%
-  \protected at edef\Ginput at path{{\import at path@fix{#4}}#3}%
-  #1{#7}%
+  \protected at xdef\import at path{\import at path@fix{#4}}%
+  \protected at edef\input at path{{\import at path}#2}%
+  \protected at edef\Ginput at path{{\import at path}#3}%
+  \protected at edef\import at path@file{% use full path/file for non-*
+    \ifx\IfFileExists\@iffileonpath\else \import at path\fi #7}%
+%
+  \expandafter#1\expandafter{\import at path@file}%
+%
   \let\IfFileExists#6% restore after \import*
   \gdef\import at path{#5}%
   \def\input at path{#2}\ifx\input at path\@empty \let\input at path\@undefined \fi
@@ -104,12 +94,40 @@
   \def\Ginput at path{#3}\ifx\Ginput at path\@empty \let\Ginput at path\@undefined \fi
 }
 
+% Our version of \IfFileExists that gives priority to files on \input at path,
+% #1 = file name,  #2 = action when exists, #3 = action when not exists
+\long\def \im at iffileexists#1#2#3{%
+  \let\@filef at und\@undefined
+  \ifx\input at path\@undefined\else 
+    \@iffileonpath{#1}{% (also defines \@filef at und)
+      \def\reserved at a{#2}%
+    }{}% no action yet for not found
+  \fi
+  \ifx\@filef at und\@undefined % not found on \input at path
+    \openin\@inputcheck#1 %
+    \ifeof\@inputcheck
+      \def\reserved at a{#3}%
+    \else
+      \closein\@inputcheck
+      \edef\@filef at und{#1 }%
+      \def\reserved at a{#2}%
+  \fi\fi
+  \reserved at a
+}
+
 \let\im@@IfFileExists\IfFileExists
 \gdef\import at path{}
 
 \let\import at path@fix\@firstofone % default
 
-% Check for vms file names and set \import at path@fix appropriately
+% Check for "./" currdir, and make \import at path@fix ensure trailing /
+\gdef\@gtempa{./}
+\ifx\@gtempa\@currdir % *x style paths
+ \gdef\import at path@fix#1{\@ensure at one@trailing at slash#1////\delimiter}%
+ \gdef\@ensure at one@trailing at slash#1////#2\delimiter{#1/}%
+\fi
+
+% Check for "[]" currdir (VMS file names) and set \import at path@fix appropriately
 \gdef\@gtempa{[]}
 \ifx\@gtempa\@currdir % VMS directory syntax
  \gdef\import at path@fix#1{\@gobbleVMSbrack#1][>}



More information about the tex-live-commits mailing list.