texlive[52208] Master/texmf-dist: filecontentsdef (29sep19)
commits+karl at tug.org
commits+karl at tug.org
Sun Sep 29 23:13:57 CEST 2019
Revision: 52208
http://tug.org/svn/texlive?view=revision&revision=52208
Author: karl
Date: 2019-09-29 23:13:57 +0200 (Sun, 29 Sep 2019)
Log Message:
-----------
filecontentsdef (29sep19)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL
trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL.md
trunk/Master/texmf-dist/doc/latex/filecontentsdef/README.md
trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.pdf
trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.test
trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.tex
trunk/Master/texmf-dist/source/latex/filecontentsdef/filecontentsdef.dtx
trunk/Master/texmf-dist/tex/latex/filecontentsdef/filecontentsdef.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef-tab.test
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL 2019-09-29 21:13:57 UTC (rev 52208)
@@ -1,4 +1,4 @@
- Source: filecontentsdef.dtx (v1.4 2019/04/20)
+ Source: filecontentsdef.dtx (v1.5 2019/09/29)
Author: Jean-Francois Burnol
Info: filecontents + macro + verbatim
License: LPPL 1.3c
@@ -15,7 +15,7 @@
Else, for manual installation:
- To extract the package and at the same time produce the
- documentation, execute latex twice on filecontentsdef.dtx then
+ documentation, execute latex thrice on filecontentsdef.dtx then
dvipdfmx on the dvi file.
To customize the PDF documentation (paper size, etc...): execute
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL.md 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/INSTALL.md 2019-09-29 21:13:57 UTC (rev 52208)
@@ -1,6 +1,6 @@
<!-- -->
- Source: filecontentsdef.dtx (v1.4 2019/04/20)
+ Source: filecontentsdef.dtx (v1.5 2019/09/29)
Author: Jean-Francois Burnol
Info: filecontents + macro + verbatim
License: LPPL 1.3c
@@ -15,7 +15,7 @@
Else, for manual installation:
- To extract the package and at the same time produce the documentation,
- execute latex twice on `filecontentsdef.dtx` then `dvipdfmx` on the
+ execute latex thrice on `filecontentsdef.dtx` then `dvipdfmx` on the
`dvi` file.
To customize the PDF documentation (paper size, etc...): execute `etex`
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/README.md 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/README.md 2019-09-29 21:13:57 UTC (rev 52208)
@@ -1,6 +1,6 @@
<!-- -->
- Source: filecontentsdef.dtx (v1.4 2019/04/20)
+ Source: filecontentsdef.dtx (v1.5 2019/09/29)
Author: Jean-Francois Burnol
Info: filecontents + macro + verbatim
License: LPPL 1.3c
@@ -27,6 +27,40 @@
CHANGE LOG
==========
+v1.5 \[2019/09/29\]
+-------------------
+
+- `\filecontentsexec` does not forcefully reset `\newlinechar`
+ to its LaTeX default after execution.
+
+- `\FCD@` as prefix for internal non public macros.
+
+- drop usage of the legacy LaTeX mechanism which issued a warning
+ in case of a form feed or horizontal tabulation character in the
+ parsed contents.
+
+- make handling of the tabulation and form feed characters
+ customizable.
+
+- treat especially the case when the `\end{filecontents...}`
+ is not on a line of its own.
+
+- add `filecontentsdefstarred` (et al.) as alias for
+ `filecontentsdef*` (et al.) for easying up encapsulation in
+ wrapping environments.
+
+- breaking change: `filecontentsdef` and `filecontentsdefmacro`
+ define a macro obeying the local scope. Use `filecontentsgdef`,
+ resp. `filecontentsgdefmacro` for definitions with global scope.
+
+- make the name of the environment used by `\filecontentsprint`
+ customizable (it defaults to `verbatim`) and allow to pass options
+ to it; has been tested with `fancyvrb` and `minted`.
+
+- add `\filecontentsprintviascan` which allows to use verbatim-like
+ environment such as `listings` which are incompatible with
+ `\filecontentsprint`.
+
v1.4 \[2019/04/20\]
-------------------
Added: trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef-tab.test
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef-tab.test (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef-tab.test 2019-09-29 21:13:57 UTC (rev 52208)
@@ -0,0 +1,5 @@
+%% LaTeX2e file `filecontentsdef-tab.test'
+%% generated by the `filecontentshere' environment
+%% from source `filecontentsdef' on 2019/09/29.
+%%
+Here is a tab and then three in a row .
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.test
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.test 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.test 2019-09-29 21:13:57 UTC (rev 52208)
@@ -1,7 +1,3 @@
-%% LaTeX2e file `filecontentsdef.test'
-%% generated by the `filecontentshere' environment
-%% from source `filecontentsdef' on 2019/05/03.
-%%
\begin{framed}
\noindent
We have coded this in \LaTeX: both
Modified: trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.tex 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/doc/latex/filecontentsdef/filecontentsdef.tex 2019-09-29 21:13:57 UTC (rev 52208)
@@ -1,6 +1,6 @@
%%
%% Package: filecontentsdef
-%% Version: 1.4 (2019/04/20)
+%% Version: 1.5 (2019/09/29)
%% License: LPPL 1.3c
%% Copyright (C) 2016-2019 Jean-Francois Burnol <jfbu at free dot fr>
%%
Modified: trunk/Master/texmf-dist/source/latex/filecontentsdef/filecontentsdef.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/filecontentsdef/filecontentsdef.dtx 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/source/latex/filecontentsdef/filecontentsdef.dtx 2019-09-29 21:13:57 UTC (rev 52208)
@@ -2,12 +2,12 @@
% N.B.: this dtx file is NOT for use with \DocInput but only docstrip.
% The latex source of the user manual isn't commented out.
%<*none>
-\def\dtxtimestamp{21-04-2019 at 15:24:14 CEST}%
+\def\dtxtimestamp{29-09-2019 at 10:46:12 CEST}%
%</none>
%<*!readme&!install>
%%
%% Package: filecontentsdef
-%% Version: 1.4 (2019/04/20)
+%% Version: 1.5 (2019/09/29)
%% License: LPPL 1.3c
%% Copyright (C) 2016-2019 Jean-Francois Burnol <jfbu at free dot fr>
%%
@@ -14,9 +14,9 @@
%</!readme&!install>
%<*none>
\def\pkgname {filecontentsdef}
-\def\pkgdate {2019/04/20}
-\def\pkgdocdate {2019/04/21}
-\def\pkgversion {v1.4}
+\def\pkgdate {2019/09/29}
+\def\pkgdocdate {2019/09/29}
+\def\pkgversion {v1.5}
\def\pkgdescription {filecontents + macro + verbatim (JFB)}
\catcode`\^ 12 \iffalse
%</none>
@@ -23,7 +23,7 @@
%<*readme|install>
<!-- -->
- Source: filecontentsdef.dtx (v1.4 2019/04/20)
+ Source: filecontentsdef.dtx (v1.5 2019/09/29)
Author: Jean-Francois Burnol
Info: filecontents + macro + verbatim
License: LPPL 1.3c
@@ -52,6 +52,40 @@
CHANGE LOG
==========
+v1.5 \[2019/09/29\]
+-------------------
+
+- `\filecontentsexec` does not forcefully reset `\newlinechar`
+ to its LaTeX default after execution.
+
+- `\FCD@` as prefix for internal non public macros.
+
+- drop usage of the legacy LaTeX mechanism which issued a warning
+ in case of a form feed or horizontal tabulation character in the
+ parsed contents.
+
+- make handling of the tabulation and form feed characters
+ customizable.
+
+- treat especially the case when the `\end{filecontents...}`
+ is not on a line of its own.
+
+- add `filecontentsdefstarred` (et al.) as alias for
+ `filecontentsdef*` (et al.) for easying up encapsulation in
+ wrapping environments.
+
+- breaking change: `filecontentsdef` and `filecontentsdefmacro`
+ define a macro obeying the local scope. Use `filecontentsgdef`,
+ resp. `filecontentsgdefmacro` for definitions with global scope.
+
+- make the name of the environment used by `\filecontentsprint`
+ customizable (it defaults to `verbatim`) and allow to pass options
+ to it; has been tested with `fancyvrb` and `minted`.
+
+- add `\filecontentsprintviascan` which allows to use verbatim-like
+ environment such as `listings` which are incompatible with
+ `\filecontentsprint`.
+
v1.4 \[2019/04/20\]
-------------------
@@ -104,7 +138,7 @@
Else, for manual installation:
- To extract the package and at the same time produce the documentation,
- execute latex twice on `filecontentsdef.dtx` then `dvipdfmx` on the
+ execute latex thrice on `filecontentsdef.dtx` then `dvipdfmx` on the
`dvi` file.
To customize the PDF documentation (paper size, etc...): execute `etex`
@@ -172,7 +206,7 @@
\Msg{*\space\space\space\space \pkgname.sty^^J}%
\Msg{*^^J}%
\Msg{* To produce the documentation with source code included run latex^^J}%
-\Msg{* twice on file \pkgname.tex and then dvipdfmx on \pkgname.dvi^^J}%
+\Msg{* thrice on file \pkgname.tex and then dvipdfmx on \pkgname.dvi^^J}%
\Msg{*^^J}%
\Msg{* Happy TeXing!^^J}%
\Msg{*^^J}%
@@ -257,7 +291,7 @@
\newcommand\fcdname{%
\texorpdfstring{{\color{joli}\ttfamily\bfseries \pkgname}}{\pkgname}\xspace}
-\DeclareRobustCommand\csa [1] {{\ttfamily\hyphenchar\font45 \char`\\ #1}}
+\DeclareRobustCommand\csa[1]{{\ttfamily\hyphenchar\font45 \char`\\ #1}}
\newcommand\csh[1]{\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}}
@@ -292,25 +326,20 @@
\usepackage{filecontentsdef}
\makeatletter
-% Revert change to \smash and other macros at LaTeX 2018/12/01
-% https://github.com/latex3/latex2e/issues/108
-\let\leavevmode at ifvmode\empty % for \smash in \NewWith etc...
-\newcommand\inmarg [1]{\@bsphack
+% \hbox needed since change to \smash and other macros at LaTeX 2018/12/01
+\def\NewWith #1{\@bsphack
\vadjust{\vskip-\dp\strutbox
- \smash{\hbox to 0pt
- {\color[named]{PineGreen}\normalfont\small\bfseries
+ \hbox{\smash{\hbox to 0pt {\hss\color[named]{Thistle}%
+ \normalfont\small\bfseries
\hsize 2.5cm\rightskip.5cm minus.5cm
- \hyphenpenalty\z@\exhyphenpenalty\z@
- \doublehyphendemerits\z@\baselineskip9pt
- \hss\vtop{\noindent#1}\kern.25cm }}%
+ \vtop{\noindent New with #1}\kern.25cm }}}%
\vskip\dp\strutbox }\strut\@esphack}
-%! 24 février 2014. J'ai besoin de me débarrasser du \to
-\def\NewWith #1{\@bsphack
+\def\ChangedAt #1{\@bsphack
\vadjust{\vskip-\dp\strutbox
- \smash{\hbox to 0pt {\hss\color[named]{Thistle}%
+ \hbox{\smash{\hbox to 0pt {\hss\color[named]{Thistle}%
\normalfont\small\bfseries
\hsize 2.5cm\rightskip.5cm minus.5cm
- \vtop{\noindent New with #1}\kern.25cm }}%
+ \vtop{\noindent Changed at #1}\kern.25cm }}}%
\vskip\dp\strutbox }\strut\@esphack}
\makeatother
@@ -361,21 +390,20 @@
\href{https://ctan.org/pkg/attachfile}{attachfile}.)
\end{abstract}
-\section{Description}
+\tableofcontents
-This package provides the |filecontentsdef|\inmarg{|file\-contents\-def|}
-environment. It is like |filecontents| but requires a second argument. This
-argument will either be:
+\section{Environments and macros}
+
+\subsection{\textcolor[named]{PineGreen}{\texttt{filecontentsdef}},
+ \textcolor[named]{PineGreen}{\texttt{filecontentsgdef}}}
+
+The |filecontentsdef| environment is like |filecontents| but
+requires a second argument. This argument will either be:
\begin{itemize}
-\item a single control sequence token such as |\macro|,
-\item \mbox{}\NewWith{v1.4$\to$}or anything else which then must after expansion be
+\item a single control sequence token such as |\foo|,
+\item or anything else which then must after expansion be
usable as a macro \emph{name} (it will be handled via
|\csname...\endcsname| encapsulation).
-% Bordel, que d'emmerdements avec le LaTeX \footnote et \verb ! On ne peut même
-% pas faire \string\fi (ou \else, ou \if pas vérifié lequel des trois:
-% incomplete \ifmmode
-%\footnote{
-% Bon ben finalement pas de footnote de toute façon. Déjà fait le mark-up je laisse.
For example \texttt{\string\myitemnumber\{3\}} can be used as argument and
it will then be expanded inside \texttt{\string\csname...\string\endcsname}
to construct a control sequence, whose name will possibly contain digits or
@@ -383,13 +411,11 @@
allowed as long as its expansion is
\texttt{\string\csname...\string\endcsname} compatible; the character itself
will \emph{not} be assigned a new meaning.
-%}
-%
\end{itemize}
Thus the syntax is either:
\begin{verbatim}
- \begin{filecontentsdef}{<filename>}{\macro}
+ \begin{filecontentsdef}{<filename>}{\foo}
... arbitrary contents ...
\end{filecontentsdef}
\end{verbatim}
@@ -401,22 +427,32 @@
\end{verbatim}
The environment creates the file and stores its (verbatim) contents into its
-second argument |\macro| (or into the macro |\<macro name>| with given name).
+second argument |\foo| (or into the macro |\<macro name>| with given name).
+\begin{framed}
+ Hint: if some |\foo| contains the \emph{name} of the macro to be defined, use
+ |\empty\foo| as argument, thus avoiding |\foo| itself to get overwritten by
+ the environment.
+\end{framed}
+
\begin{enumerate}
-\item The starred variant acts like |filecontents*| environment regarding the
- file contents.
+\item The starred variant |filecontentsdef*| acts like
+ |filecontents*| environment regarding the file contents, i.e.
+ it drops addition of a (\TeX) commented out header.
+\item |filecontentsdefstarred| is an alias for
+ |filecontentsdef*|.\NewWith{v1.5}
\item The contents put into the macro are the same for the starred and
- non-starred environments: they do not contain the commented-out header.
-\item The scope of the macro definition is global.
+ non-starred environments: neither contains a commented-out header.
+\item The scope of the macro definition is
+ \textbf{local}.\ChangedAt{v1.5}
+\item
+ Use |filecontentsgdef| for a definition with global scope.\NewWith{v1.5}
\item No check is done on whether the defined macro pre-existed.
-% \item |filecontentshere| is a wrapper of the |filecontentsdef|
-% environment using \csa{filecontentsheremacro} as the macro where the
-% contents are stored.\inmarg{\csa{file\-contents\-here\-macro}} This macro
-% can then be reused elsewhere if wanted.
-\item The macro holds a verbatim rendering of the contents, which handles the
- Form Feed and Tabulation characters analogously to the |filecontents|
- treatment.
+\item The macro holds a verbatim rendering of the contents, with active spaces
+ and active |^^M| tokens.
+\item The handling of the\NewWith{v1.5}
+ Form Feed and Tabulation characters can be, contrarily to the |filecontents|
+ treatment, customized. See \autoref{sec:tab}.
\item Babel shorthands will be neutralized the same way they are when
encountered in a verbatim environment or in a |filecontents|
environment. Their action is reactivated if the macro (assuming the
@@ -425,13 +461,10 @@
\item The environment can be used either in the preamble or the body
of the document.
\item The contents must not contain themselves a
- \texttt{\string\end}|{filecontentsdef}| (or |end{filecontentsdef*}| in the
+ \texttt{\string\end}|{filecontentsdef}| (or \texttt{\string\end}|{filecontentsdef*}| in the
starred case).
-\item If some |\macro| contains the \emph{name} of the macro to be defined,
- use then |\empty\macro| as argument, this trick will avoid the environment
- thinking it is supposed to redefine |\macro| itself.
% problème avec Emacs/AUCTeX et |\end{...}| qui fait boguer le fontlock
-% biarrement le deuxième ne pose pas de problème. 19 avril 2019.
+% bizarrement le deuxième ne pose pas de problème. 19 avril 2019.
\end{enumerate}
\begin{footnotesize}
@@ -442,8 +475,8 @@
\item the space becomes the active character of ascii code |32|,
\item the end of line is converted into the active character |^^M| (i.e. ascii
code |13|),
-\item the tabulation character |CTRL-I| becomes the active space character,
-\item the form feed character |CTRL-L| is converted into a pair of active |^^M|,
+\item see \autoref{sec:tab} for the handling of the horizontal tabulation
+ and form feed characters,
\item the active bytes of ascii code between |128| and |255| (this is now
systematically the case with |inputenc+utf8| being default) are stored
into the produced macro ``as is'',
@@ -455,22 +488,44 @@
\par
\end{footnotesize}
-\medskip
+\subsection{\textcolor[named]{PineGreen}{\texttt{filecontentsdefmacro}},
+ \textcolor[named]{PineGreen}{\texttt{filecontentsgdefmacro}}}
-The \csa{filecontentsprint}\inmarg{\csa{file\-contents\-print}} macro has a
+This environment
+\begin{verbatim}
+ \begin{filecontentsdefmacro}{\foo or macro name}
+ ... arbitrary contents ...
+ \end{filecontentsdefmacro}
+\end{verbatim}
+was added at |v1.4|. It is like |filecontentsdef| without the
+``save to file'' part... and has thus a sole mandatory argument which may be
+either a control sequence or a name (or material expanding to name), as
+previously described. The macro can then be either printed verbatim via
+\csa{filecontentsprint} or, if it consists of \LaTeX\ code, be executed in
+re-tokenized form via \csa{filecontentsexec}.
+
+Its name is thus a bit paradoxical but was chosen to share an existing prefix
+with the other package macros and environments.
+
+\subsection{\textcolor[named]{PineGreen}{\csh{filecontentsprint}},
+\textcolor[named]{PineGreen}{\csh{FCDprintenvname}},
+\textcolor[named]{PineGreen}{\csh{FCDprintenvoptions}}}
+
+
+\csa{filecontentsprint} has a
unique mandatory argument which will be either:
\begin{itemize}
-\item a single control sequence token (for example |\macro|),
-\item \mbox{}\NewWith{v1.4$\to$}or anything else which then must after expansion be
+\item a single control sequence token (for example |\foo|),
+\item or anything else which then must after expansion be
usable as a macro \emph{name} (for example |macro|). It will be handled via
|\csname...\endcsname| encapsulation (see earlier explanations).%
\end{itemize}
-The |\macro| must be of the type constructed by the environment
-|filecontentsdef|. It will be then be printed exactly as
+The |\foo| must be of the type constructed by the environments
+|filecontentsdef| or |filecontentsdefmacro|. It will be then be printed exactly as
\begingroup\makeatletter\def\x{\let\@xverbatim\relax
\verbatim
\string\begin\string{verbatim\string}\par
-<contents of \string\macro>\par
+<contents of \string\foo>\par
\string\end\string{verbatim\string}\par
\endverbatim%
\endgroup}\x
@@ -483,11 +538,6 @@
\href{http://www.ctan.org/pkg/verbatim}{verbatim} (whose mechanism is quite
different from the one of the default |verbatim| environment.)
-%xxx
-% MARRE DE EMACS/AUCTEX QUI SE CROIT PLUS INTELLIGENT QUE L'UTILISATEUR POUR
-% L'INDENTATION PAR FILL-PARAGRAPH (M-q)
-%xxx
-
\begin{framed}
Due to limitation of the |verbatim| environment, the
\texttt{\string\end}|{verbatim}| must not appear inside the contents... else
@@ -498,30 +548,182 @@
affects \csa{filecontentsprint}, not \csa{filecontentsexec}.
\end{framed}
+The name of the used environment is held in macro
+\textcolor[named]{PineGreen}{\csa{FCDprintenvname}}.\NewWith{v1.5}
+Redefine it to modify the environment name from its default |verbatim|.
+
+Furthermore\NewWith{v1.5} the macro
+\textcolor[named]{PineGreen}{\csa{FCDprintenvoptions}} can be used to pass
+options to that environment.
+
+Here is a set-up using |fancyvrb| which I tested with success:
+\begin{verbatim}
+\documentclass{article}
+\usepackage{filecontentsdef}
+\usepackage{xcolor}
+\usepackage{fancyvrb}
+\usepackage{fvextra}
+
+% store tabs as active characters so they can be handled by fancyvrb
+{\catcode`\^^I=\active\gdef\FCDtabtomacro{\noexpand^^I}}
+
+% Use fancyvrb Verbatim environment
+\renewcommand*\FCDprintenvname{Verbatim}
+
+% with these options. This will be submitted to an \edef, so we
+% simply wrap in \unexpanded to avoid problems
+\renewcommand*\FCDprintenvoptions{%
+ \unexpanded{[fontsize=\scriptsize, highlightlines={1, 3-4},
+ numbers=both, showspaces, spacecolor=red,
+ showtabs, %tab=\rightarrowfill% incompatible with linebreaks?
+ breaklines,breakbefore=\\\space]}%
+}
+\begin{filecontentsdefmacro}{\testfancyvrb}
+some contents with long lines and tabs to test the options
+\end{filecontentsdefmacro}
+\end{verbatim}
+
+Here is now a set-up with |minted| which worked also (although the syntax
+highlighting was not handling correctly control sequences using the @ letter,
+but I am not knowledgeable enough in the Pygmentize library):
+
+\begin{verbatim}
+\documentclass{article}% needs shell-escape
+\usepackage{filecontentsdef}
+\usepackage{minted}
+\newminted{tex}{linenos}
+
+\renewcommand*\FCDprintenvname{texcode}
+
+\begin{filecontentsdefmacro}{\testminted}
+some TeX macros
+\end{filecontentsdefmacro}
+
+\begin{document}
+\filecontentsprint\testminted
+\end{document}
+\end{verbatim}
+
+\subsection{\textcolor[named]{PineGreen}{\csh{filecontentsprintviascan}}}
+
+It is not possible to use a |listings| environment via \csa{filecontentsprint}
+and \csa{FCDprintenv}, because |listings| has a special way to identify where
+it ends and this is incompatible with the \csa{filecontentsprint} approach.
+
+At |v1.5|
+\csa{filecontentsprintviascan} is added\NewWith{v1.5} which is more powerful
+than \csa{filecontentsprint} as it should work not only with verbatim
+environments known to be compatible with \csa{filecontentsprint} but
+also with environments of the |listings| type. But this requires \eTeX{}
+\csa{scantokens} (it uses \csa{filecontentsexec}, see next).%
+%
+\footnote{I know that the \LaTeX{} kernel itself requires \eTeX{} for a few
+ years now, but \fcdname could have been installed on an old machine...}
+
+Here is an example of usage which worked for me (although the syntax
+highlighting, like the one from |minted|, was not fully satisfying):
+
+\begin{verbatim}
+\documentclass{article}
+\usepackage{filecontentsdef}
+\usepackage{xcolor}
+\usepackage{listings}
+\lstnewenvironment{latexverbatim}
+ {\lstset{
+ basicstyle=\small\ttfamily,
+ breaklines=true,
+ columns=fullflexible,
+ language=[LaTeX]TeX,
+ numbers=left,
+ numbersep=1em,
+ numberstyle=\tiny\color{gray},
+ keywordstyle=\color{red}}}{}
+
+\renewcommand*\FCDprintenvname{latexverbatim}
+
+\begin{document}
+
+\begin{filecontentsdefmacro}{\testlistings}
+\gdef\filecontentsprintviascan{\FCD at get\FCD at printviascan}%
+\gdef\FCD at printviascan#1{%
+ \toks@\expandafter{#1}%
+ \edef\FCD at envwithcontents{%
+ \noexpand\begin{\FCDprintenvname}\FCDprintenvoptions\noexpand^^M%
+ \the\toks@\@backslashchar end{\FCDprintenvname}\noexpand^^M}%
+ \FCD at exec\FCD at envwithcontents}%
+\end{filecontentsdefmacro}
+
+\filecontentsprintviascan\testlistings
+\end{document}
+\end{verbatim}
+
+\subsection{\textcolor[named]{PineGreen}{\csh{filecontentsexec}}}
+
Although \fcdname itself generally does not require \eTeX, it provides as a
-convenience \csa{filecontentsexec}\inmarg{\csa{file\-contents\-exec}} which
+convenience \csa{filecontentsexec} which
does require it as it uses |\scantokens| to re-assign the current catcode
regime to the verbatimized tokens stored into its mandatory argument. Again
-the mandatory argument may have one of the two forms described previously.%
-\NewWith{v1.4$\to$}
+the mandatory argument may have one of the two forms described previously.
And of course this assumes that the tokens provide legitimate \LaTeX\ code.
\begin{footnotesize}
- \textbf{TeX-hacker note:} As an aftereffect, the |\newlinechar| will be set
- to |10| (its \LaTeX\ default) after execution; we skipped the saving and
- restoring of its value (it is temporarily set to |13| for |\scantokens|
- execution). No group is used in order to not create an extra scoping of the
- executed macro contents.
+ \textbf{TeX-hacker note:} No group is used in order to not create an extra
+ scoping of the executed macro contents.
- \textbf{TeX-hacker note:} A space token will be present at the end of the
- expansion, due to |\scantokens|'s way of working, but may be hidden by the
- nature of the contents themselves, if for example they end with a |\relax|
- or a |%|, or from arising in vertical mode.
+ \textbf{TeX-hacker note:} In the case of storage in a macro of some \LaTeX{}
+ contents, and re-parsing via |\filecontentsexec| which uses
+ |\scantokens|, the last line before the
+ \texttt{\string\end}|{filecontentsdef}|
+ or |\end{filecontentsdefmacro}| potentially generates an end of line
+ character, typically a space token (but this depends on the
+ \csa{endlinechar} valid at this location
+ setting). Such a space coming from the last end of line has no impact if
+ the \LaTeX{} contents get executed in vertical mode. In horizontal mode it
+ will be avoided if these contents end with a |%|
+ or also with some control sequence such as a |\relax| or
+ |\empty| (only if \csa{endlinechar} is standard).
+ At |v1.5|\NewWith{v1.5} a special convention is added that if the
+ \texttt{\string\end}|{filecontentsdef}| (or variants) stands on
+ the same line as the last line of the contents, rather than being on
+ a line of its own, then the stored contents will get postfixed with
+ an added \csa{empty} token. Thus execution via
+ \csa{filecontentsexec} in horizontal mode will not induce any ending
+ space token (assuming the \csa{endlinechar} is then at its standard
+ setting). This feature is to be used only with contents representing
+ \TeX{} macros, as the \csa{empty} makes sense only in that context.
+ This token will remain invisible in the PDF output from
+ \csa{filecontentsprint}.
+
+ No \csa{empty}
+ gets added to the last line of the exported file (if there is one).
+ The original |filecontents| environment issues a warning when there is
+ contents before the end of the environment on the same line, this warning is
+ now skipped.\ChangedAt{v1.5}
+
+ This extra \csa{empty}
+ added only under such special usage of the environment is not currently
+ customizable, but I can add such a feature if there is a user request.
+
+ \textbf{TeX-hacker note:} one should not think that using
+ \csa{filecontentsexec} with some stored material will behave like copying
+ pasting that material directly at that very location of the source code: for
+ example if the last line ends with a |%|
+ this does not mean that this will comment out what is next in the source
+ code on the same line after the \csa{filecontentsexec}! It is more analogous
+ to making first a macro definition with the contents and then execute that
+ macro. But it is not possible for some macro from inside these contents to
+ itself grab tokens coming next after the \csa{filecontentsexec}\csa{foo}
+ (moreover, \fcdname adds tokens of its own in order restore the
+ \csa{newlinechar}).
+
+
\end{footnotesize}
-The environment\inmarg{|file\-contents\-here|}
+\subsection{\textcolor[named]{PineGreen}{\texttt{filecontentshere}}}
+
+This environment
\begin{verbatim}
\begin{filecontentshere}{<filename>}
... arbitrary contents ...
@@ -538,11 +740,18 @@
\begin{verbatim}
\filecontentsprint\filecontentsheremacro
\end{verbatim}
-The |\filecontentsheremacro| remains available for reuse with |\filecontentsexec|.
+The |\filecontentsheremacro| is then available for usage as argument
+of |\filecontentsexec|. Since |v1.5| its definition has only
+local scope.
+\ChangedAt{v1.5}
+The environment has a starred variant
+|filecontentshere*| (also |filecontentsherestarred|) which does the
+expected thing.
+
For example
\begin{verbatim}
-\begin{filecontentshere}{\jobname.test}
+\begin{filecontentshere*}{\jobname.test}
\begin{framed}
\noindent
We have coded this in \LaTeX: both
@@ -549,12 +758,12 @@
$E=mc^2$ (input as \verb|$E=mc^2$|)
and $E=h\nu$ owe much to \textsc{Albert Einstein}.
\end{framed}
-\end{filecontentshere}
+\end{filecontentshere*}
\filecontentsexec\filecontentsheremacro
\end{verbatim}
-will produce the external file with extension
-|.test| and have this effect in the document (verbatim framed then real framed):
-\begin{filecontentshere}{\jobname.test}
+will produce an external file with the above contents and have this
+effect in the document (verbatim framed then real framed):
+\begin{filecontentshere*}{\jobname.test}
\begin{framed}
\noindent
We have coded this in \LaTeX: both
@@ -561,61 +770,49 @@
$E=mc^2$ (input as \verb|$E=mc^2$|)
and $E=h\nu$ owe much to \textsc{Albert Einstein}.
\end{framed}
-\end{filecontentshere}
+\end{filecontentshere*}
\filecontentsexec\filecontentsheremacro
-The environment\inmarg{|file\-contents\-def\-macro|}
-\begin{verbatim}
- \begin{filecontentsdefmacro}{\macro or macro name}
- ... arbitrary contents ...
- \end{filecontentsdefmacro}
-\end{verbatim}
-was added at |v1.4|.\NewWith{v1.4} It is like |filecontentsdef| without the
-``save to file'' part... and has thus a sole mandatory argument which may be
-either a control sequence or a name (or material expanding to name), as
-previously described. The macro can then be either printed verbatim via
-\csa{filecontentsprint} or, if it consists of \LaTeX\ code, be executed in
-re-tokenized form via \csa{filecontentsexec}.
-
-Its name is thus a bit paradoxical but was chosen to share an existing prefix
-with the other package macros and environments.
-
\section{How to wrap usage of \texttt{filecontentsdef} in another
environment}
-It is simple: don't use |\begin/\end| syntax
-% \verb|\end{filecontentsdef}|, % uniquement à cause de bug de Emacs/AUCTeX
-% % fontlocking
-but |\begingroup\filecontentsdef{..}{..}| and |\endfilecontentsdef\endgroup|.
+Don't use the |\begin/\end| syntax but directly
+|\begingroup\filecontentsdef{..}{..}| and |\endfilecontentsdef\endgroup|.
And these should come last, respectively first, in the definition of the
begin, respectively end, part of the new environment.
-The extra |\begingroup...\endgroup| is needed only to the extent that
-definitions and catcode assignments could affect the execution of the
-rest of the |end| part of the new environment. As this |end| part will
-be tokenized at time of definition, it will in general be indifferent to
-the catcode modifications done by \csa{filecontentsdef} and generally
-speaking the |\begingroup...\endgroup| can be dropped.
+The extra |\begingroup...\endgroup| are mandatory with the
+\fcdname environments making a local scope definition.\ChangedAt{v1.5}
-Of course, for wrapping the starred variant one should use
-% PUTAIN DE BORDEL DE Text for \verb command ended by end of line, QU'EST-CE
-% QUE LATEX EST CHIANT. Plus le fill-paragraph de Emacs et le doctex-mode défectueux.
-|\csname filecontentsdef*\endcsname|, or make the definition with |*| having catcode
-letter. But the \verb|\endfilecontentsdef| can drop the |*|, as the starred
-environments defined by the \fcdname package use the same ending macros as
-their non-starred variants.
+For those creating global scope macros, |\begingroup...\endgroup|
+is recommended, as the \LaTeX{} state is not completely clean
+after |\endfilecontentsgdef| (et al.) execution. Thus it is
+better to have the extra |\begingroup...\endgroup| pair always
+(which are a part of the things added by the |\begin/\end| syntax).
+For wrapping the starred variant one needs to use
+|\csname filecontentsdef*\endcsname|, or make the definition with |*|
+having catcode letter. A simpler way is to use the alias ending
+in |...starred|.\NewWith{v1.5} Regarding the ending macro its
+name can drop the |*|, as the starred environments defined by the
+\fcdname package use the same ending macros as their non-starred
+variants.
+
As exercise, let's imagine we want an environment which will be associated
to some counter, will automatically increment it at each usage, and will
-use this counter to index the files and macros created on each invocation.
+use this counter to index the files and macros created on each
+invocation.
+Except if you know how to smuggle how a macro from an environment
+you probably want to use |filecontentsgdef| in order for the
+macro to have global scope.
\begin{filecontentsdefmacro}{\pablo}
\newcounter{pablo}
\newenvironment{defexercise}
{\stepcounter{pablo}%
\begingroup
- \csname filecontentsdef*\endcsname
+ \filecontentsgdefstarred
{\jobname-ex\the\value{pablo}}{exercise-\the\value{pablo}}}%
- {\endfilecontentsdef\endgroup}
+ {\endfilecontentsgdefstarred\endgroup}
\newcommand{\printexercise}[1]{\filecontentsexec{exercise-\the\numexpr#1\relax}}
\end{filecontentsdefmacro}
\filecontentsprint\pablo
@@ -649,11 +846,155 @@
Additionally, three small files were created containing the \LaTeX\ mark-up
for each exercise.
+
+\section{How to customize handling of tabulation and form feed characters}
+\label{sec:tab}
+
+\LaTeX{} assigns catcode 10 by default to |^^I| meaning that it is handled by
+default as a space character:
+\begin{filecontentsdefmacro}{\coucou}
+\def\test{^^I}
+\ifx\test\space \textcolor{blue}{OK}\else \ERROR\fi
+\end{filecontentsdefmacro}
+\filecontentsprint\coucou
+\filecontentsexec\coucou
+
+But \fcdname like the original |filecontents| environment assigns active
+catcode to the tabulation character before parsing the contents. This allows
+special treatment.
+
+\begin{framed}
+ Attention that if input as |^^I| (in opposition to the real ascii character
+ of ascii code 9), it will end up simply as |^^I| in external file or macro,
+ because the caret loses its special meaning in the environment.
+
+ The discussion in this section about customizing \fcdname behaviour applies
+ only to a source with a real tabulation character, not one in \TeX{} notation
+ |^^I|.
+\end{framed}
+
+With
+|v1.5|, \fcdname diverges from original |filecontents| by adding the means to
+customize the handling of such tabulation character, rather than simply raising
+a warning and exporting it as a space like original |filecontents|. And also
+the handling of the form feed character can be customized.
+
+This is controlled via four control sequences whose default definitions are
+the following:\NewWith{v1.5}
+\begin{verbatim}
+\def\FCDtabtofile{ }%
+
+{\catcode32\active\gdef\FCDtabtomacro{\noexpand }}%
+
+\def\FCDformfeedtofile{^^J^^J}%
+
+{\catcode`\^^M\active\gdef\FCDformfeedtomacro{\noexpand^^M\noexpand^^M}}%
+\end{verbatim}
+
+Each of \csa{FCDtabtofile}, \csa{FCDtabtomacro},
+\csa{FCDformfeedtofile}, \csa{FCDformfeedtomacro} gets used via an
+expansion inside an \csa{edef}, hence the need for \csa{noexpand} in front
+of active characters. The |^^J| in \csa{FCDformfeedtofile} matches
+the default newline character (ascii code 10) of \LaTeX{} for
+exporting files. The active |^^M| is used for macro storage
+because this is the most suitable for verbatim printing via
+\csa{filecontentsprint} as typically in a verbatim environment end
+of lines get converted into such active |^^M| (which will create
+a |\par| token).
+
+If you want for example tabulation characters to get converted into four
+spaces, use:
+\begin{verbatim}
+\def\FCDtabtofile{\space\space\space\space}%
+{\catcode32\active\gdef\FCDtabtomacro{\noexpand \noexpand \noexpand \noexpand }}%
+\end{verbatim}
+I have here used for macro storage active spaces. The \csa{noexpand} are
+mandatory in such case, but they will disappear from stored contents in a
+macro. We could also have defined \csa{FCDtabtofile} as an alias to
+\csa{FCDtabtomacro} here because a non-expanding active space will simply give a
+space in the external file. Due to \TeX{} tokenization rules
+|\def\FCDtabtofile{ }| would be the same as with only one single space and
+thus we used |\space\space\space\space|.
+
+If you want an actual tabulation character stored to a file, use:
+\begin{verbatim}
+{\catcode`\^^I=12 \gdef\FCDtabtofile{^^I}}
+\def\FCDtabtomacro{TAB}
+\end{verbatim}
+The second line is for demonstration only as an example of how to store the
+tabulation character in a macro, use anything adequate to replace \texttt{TAB}
+as used here. For example you can store in it the actual tabulation (ascii code
+9) with catcode 12, via using rather |\let\FCDtabtomacro\FCDtabtofile| in the
+above. Or use some Unicode symbol and appropriate font configuration.
+
+Here is an example. This is rendered via |verbatim| which will treat the
+tabulation characters as spaces, but they are there in the original:
+\begin{verbatim}
+{\catcode`\^^I=12 \gdef\FCDtabtofile{^^I}}
+\let\FCDtabtomacro\FCDtabtofile
+\begin{filecontentshere}{\jobname-tab.test}
+Here is a tab and then three in a row .
+\end{filecontentshere}
+(we will see them in the PDF output via the glyph at slot 9 of the T1 encoding).
+\end{verbatim}
+Here is what the original produces indeed when executed:
+{\catcode`\^^I=12 \gdef\FCDtabtofile{^^I}}
+\let\FCDtabtomacro\FCDtabtofile
+\begin{filecontentshere}{\jobname-tab.test}
+Here is a tab and then three in a row .
+\end{filecontentshere}
+The way it looks in the PDF is due to our definition of \csa{FCDtabtomacro}
+which gives a catcode12 character of ascii code 9, and we use T1
+font-encoding. The exported file does contain on the other hand as promised a
+real tabulation character.
+
\begin{footnotesize}
+ \begin{framed}
+ \LaTeX{} since 2018 uses by default |\usepackage[utf8]{inputenc}| and
+ almost all control characters are given active catcode. Exceptions: |^^@|
+ (illegal), |^^I| (treated as space), |^^J| (for some reason it gets catcode
+ 12 and thus will if printed to PDF give the glyph at slot 10 of the font
+ encoding), and |^^M| (end of line).
-\section{Custom verbatim print-outs}
+ Notice that such a control character which in the source gets input using
+ \TeX{} notation, for example |^^P|, causes no issue to \fcdname as the
+ caret |^| has lost its special catcode. Thus a |^^P| will be printed to
+ external file.
-We now comment on alternatives to using \csa{filecontentsprint}. Here is
+ If one tries to use directly in the source the CTRL-P, an error will be
+ raised by \LaTeX{} triggered by the active character (\fcdname does not
+ sanitize catcodes in this ascii range, as original |filecontents|
+ environment does not either).
+
+ One can always reassign catcodes, thus you can set the catcode of |^^P| to
+ 12 for example. However, when exporting such a control character with
+ catcode 11 or 12 to a file, pdflatex uses |^^| notation in the output.
+ There are three exceptions (with |pdflatex|): the horizontal tabulation (ascii code 9,
+ |^^I|), the line feed (ascii code 10, |^^J|), and vertical tabulation
+ (ascii code 11, |^^K|) are exported to the file as the corresponding ascii
+ characters (at least this is the case with \TeX Live). \emph{These
+ exceptions do not apply with} |xelatex|.
+
+ Thus we again end up with \TeX{} notation |^^P| in the exported file. To
+ get a literal CTRL-P, you need to set the catcode of |^^P| to 11 or 12, and
+ to run |pdflatex| with the |-8bit| option. With Xe\LaTeX, this would be
+ needed even for the horizontal tabulation CTRL-I.
+ \end{framed}
+\end{footnotesize}
+
+\begin{footnotesize}
+
+\section{How to obtain customized verbatim in the output}
+
+Please refer first to the discussion of \csa{filecontentsprint} and
+\csa{filecontentsprintviascan} as it provides examples using |fancyvrb|,
+|minted|, or |listings| environments which may be what you are looking for.
+
+Here we make quick comments on alternatives to using \csa{filecontentsprint},
+and handling directly the contents via the configuration of active spaces and
+active end of lines.
+
+Here is
some (non-\LaTeX) text snippet.
\begin{verbatim}
\begin{filecontentsdef}{\jobname.test2}{\testactive}
@@ -726,6 +1067,20 @@
\end{footnotesize}
+\section{Related packages}
+
+\begin{itemize}
+\item Scott~\textsc{Pakin}'s
+ \href{http://www.ctan.org/pkg/filecontents}{filecontents}. Notice that the
+ package functionality has been integrated into \LaTeX{} release dated
+ |2019/10/01|.
+\item Pablo~\textsc{González}'s
+ \href{http://www.ctan.org/pkg/scontents}{scontents}. Make sure your version
+ is at least |v1.3| as earlier ones had a dependency on \fcdname
+ and are broken by the changes coming with |filecontentsdef v1.5|.
+\end{itemize}
+
+
\StopEventually{\end{document}}
\clearpage
@@ -777,19 +1132,62 @@
%
%</none>
%<*package>
-% Most of
-% the code is still identical to the one in \textsc{Scott Pakin}'s
-% \href{http://www.ctan.org/pkg/filecontents}{filecontents} hence to
-% the original one in \LaTeX's sources.
-%
-% But |v1.4| adds \cs{filecontentsdefmacro} which does not write to a file...
% \begin{macrocode}
+\let\FCD at global\global
\begingroup
\catcode`\^^M\active%
+% \end{macrocode}
+% Attention that all end of lines must now get protected due to
+% the end of line character being active.
+%
+% The \LaTeX{} default for active |^^L| was \csa{outer} up to the |2017-01-01|
+% release (got modified in |{v2.3b}{2016/11/06}| version of |ltplain.dtx|).
+% But we must still handle that possibility for usage with older formats.
+% \begin{macrocode}
\catcode`\^^L\active\let^^L\relax%
\catcode`\^^I\active%
-\gdef\filec at ntentsdef#1#2{%
- \let#2\@empty%
+% \end{macrocode}
+% \csa{FCD at main} is the core construct.
+%
+% Bulk of the code is still identical to the one in \textsc{Scott Pakin}'s
+% \href{http://www.ctan.org/pkg/filecontents}{filecontents} hence to the
+% original one in \LaTeX's sources regarding \csa{filec at ntents}, as
+% |filecontentsdef| was conceived as an extension of the original
+% |filecontents| environment, with the added feature of storing the
+% verbatimized contents in a \TeX{} macro, which can then be printed (verbatim)
+% or re-tokenized later via \csa{scantokens} and executed (if it represents
+% \LaTeX{} material). Starting with |v1.5| some renaming of internal macros
+% appears and the original coding is not only extended but starts being
+% modified at some places as well.
+%
+% |v1.4| adds \csa{filecontentsdefmacro} which does not write to a file.
+%
+% |v1.5| renames all internal macros to use |\FCD@| namespace prefix. This
+% applies here to \csa{FCD at main} whose name was still \csa{filec at ntentsdef} at
+% |v1.4|. The change also applies to the \csa{reserved at b} and \csa{reservec at c}.
+%
+% |v1.5| adds customizability of how tabulation and form feed characters are
+% handled either in file output or in macro storage.
+%
+% |v1.5| modifies |filecontentsdef| to only make a definition with local
+% scope. For this we must smuggle out of the environment both the name and the
+% meaning of the control sequence to define. We prepare for this a
+% \csa{FCD at defmacro} which gets executed via |\endfilecontentsdef| (and
+% variants). As \csa{FCD at defmacro} issues \csa{endgroup}, direct usage of
+% \csa{filecontentsdef} (not as environment) must be inside an explicit
+% \csa{begingroup}/\csa{endgroup} pair, mimicking the one which an environment
+% would insert.
+%
+% The |filecontentsgdef/filecontentsgdefmacro| environments do define
+% \csa{FCD at defmacro} but do not execute it.
+% \begin{macrocode}
+\gdef\FCD at main#1#2{%
+ \def\FCD at defmacro%
+ {\toks@\expandafter{#2}%
+ \edef\x{\endgroup\def\noexpand#2{\the\toks@}%
+ \begingroup\def\noexpand\@currenvir{\@currenvir}}%
+ \x}%
+ \FCD at global\let#2\@empty%
\if at filesw%
\openin\@inputcheck#1 %
\ifeof\@inputcheck%
@@ -800,11 +1198,11 @@
{Overwriting file `\@currdir#1'}%
\fi%
\closein\@inputcheck%
- \chardef\reserved at c15 %
- \ch at ck7\reserved at c\write%
- \immediate\openout\reserved at c#1\relax%
+ \chardef\FCD at reserved@c15 %
+ \ch at ck7\FCD at reserved@c\write%
+ \immediate\openout\FCD at reserved@c#1\relax%
\if at tempswa%
- \immediate\write\reserved at c{%
+ \immediate\write\FCD at reserved@c{%
\@percentchar\@percentchar\space%
\expandafter\@gobble\string\LaTeX2e file `#1'^^J%
\@percentchar\@percentchar\space generated by the %
@@ -837,18 +1235,21 @@
\ifnum\count@<\@cclvi%
\repeat%
% \end{macrocode}
-% The default active |^^L| is |\outer|. But |\reserved at b| will be |def'd|
-% with an active |^^L| in its replacement text.
+% The default active |^^L| was |\outer| up to |2017/01/01|.
% \begin{macrocode}
\let^^L\relax%
- \edef\E{\@backslashchar end\string{\@currenvir\string}}%
- \edef\reserved at b{\def\noexpand\reserved at b####1\E####2\E####3\relax}%
+ \edef\FCD at E{\@backslashchar end\string{\@currenvir\string}}%
+ \edef\FCD at reserved@b{\def\noexpand\FCD at reserved@b####1\FCD at E####2\FCD at E####3\relax}%
% \end{macrocode}
-% \cs{filecontentsdefmacro} sets \cs{if at filesw} to false.
+% \csa{filecontentsdefmacro} sets \csa{if at filesw} to false.
% \begin{macrocode}
- \reserved at b{%
+ \FCD at reserved@b{%
\ifx\relax##3\relax%
- \if at filesw\immediate\write\reserved at c{##1}\fi%
+ \if at filesw%
+ \let^^L\FCDformfeedtofile%
+ \let^^I\FCDtabtofile%
+ \immediate\write\FCD at reserved@c{##1}%
+ \fi%
% \end{macrocode}
% This is where the original |filecontents| is extended to store the
% parsed material in a macro (in my very first hack I simply
@@ -862,29 +1263,34 @@
% the characters it contains are protected from further expansion in
% the |\xdef|'s. And the single |\noexpand| is enough also for the
% |\write| done above.
-%
-% The |lccode| of the tilde is |32| when this gets executed. Multiple
-% form feeds produce the same effect in the macro (insertion of two
-% |^^M| per form feed) as in the written out file (via two |^^J|).
% \begin{macrocode}
\toks@\expandafter{#2}%
- {\def^^L{\noexpand^^M\noexpand^^M}\lowercase{\let^^I~}%
- \xdef#2{\the\toks@##1\noexpand^^M}}%
+ \let^^L\FCDformfeedtomacro%
+ \let^^I\FCDtabtomacro%
+ \FCD at global\edef#2{\the\toks@##1\noexpand^^M}%
\else%
\edef^^M{\noexpand\end{\@currenvir}}%
\ifx\relax##1\relax%
\else%
- \if at filesw%
- \@latex at warning{Writing text `##1' before %
- \string\end{\@currenvir}\MessageBreak as last line of #1}%
- \immediate\write\reserved at c{##1}%
- \fi%
+ \if at filesw%
% \end{macrocode}
-% Same added code as above.
+% |v1.5| suppresses the warning issued by |filecontents| environment
+% in such case.
% \begin{macrocode}
+ \let^^L\FCDformfeedtofile%
+ \let^^I\FCDtabtofile%
+ \immediate\write\FCD at reserved@c{##1}%
+ \fi%
+% \end{macrocode}
+% In such case with the end of environment not being on a line of its own,
+% |v1.5| injects an extra |\empty| token at end of last line. Thus
+% usage in this form is restricted to contents representing \TeX{} macros.
+% We still need the final |^^M| for \csa{filecontentsprint} matters.
+% \begin{macrocode}
\toks@\expandafter{#2}%
- {\def^^L{\noexpand^^M\noexpand^^M}\lowercase{\let^^I~}%
- \xdef#2{\the\toks@##1\noexpand^^M}}%
+ \let^^L\FCDformfeedtomacro%
+ \let^^I\FCDtabtomacro%
+ \FCD at global\edef#2{\the\toks@##1\noexpand\empty\noexpand^^M}%
\fi%
\ifx\relax##2\relax%
\else%
@@ -893,24 +1299,28 @@
\fi%
\fi%
^^M}%
- \catcode`\^^L\active%
% \end{macrocode}
-% |v1.4|: sync |^^L| and |^^I| with 2018/04/01 LaTeX release.
+% |v1.4|: sync |^^L| and |^^I| with |2018/04/01| \LaTeX{} release.
+%
+% |v1.5|: drop the |^^L| and |^^I| \LaTeX{} definitions in favour of
+% \csa{FCDformfeedtomacro} etc...
% \begin{macrocode}
- \let\L\@undefined%
- \def^^L{\expandafter\ifx\csname L\endcsname\relax\fi^^J^^J}%
+ \catcode`\^^L\active%
\catcode`\^^I\active%
- \let\I\@undefined%
- \def^^I{\expandafter\ifx\csname I\endcsname\relax\fi\space}%
\catcode`\^^M\active%
- \edef^^M##1^^M{\noexpand\reserved at b##1\E\E\relax}%
+ \edef^^M##1^^M{\noexpand\FCD at reserved@b##1\FCD at E\FCD at E\relax}%
% \end{macrocode}
-% We want space characters to be active in the produced macro.
-% We only need to protect them once from expansion.
+% We need active space characters to be active in the produced macro.
+% We only need to protect them once from expansion. The definition
+% will work both for writing to a file and for storage into the macro.
% \begin{macrocode}
\catcode32\active\lccode`~32 \lowercase{\def~{\noexpand~}}%
}%
-\endgroup
+\gdef\FCDformfeedtofile{^^J^^J}%
+\gdef\FCDformfeedtomacro{\noexpand^^M\noexpand^^M}%
+\gdef\FCDtabtofile{ }%
+\catcode32\active\gdef\FCDtabtomacro{\noexpand }%
+\endgroup%
% \end{macrocode}
% The |v1.4| macros accept a name as alternative to a macro. Empty or
% ill-formed |#2| will break code. But |#2| can be using |\if|, |\else|,
@@ -917,38 +1327,70 @@
% |\fi| tokens, the whole thing will end up |\csname|-expanded. An active
% character also will end up |\csname|-expanded. There is no check on
% whether |#2| or |\csname#2\endcsname| is an existing macro.
+%
+% |v1.5| replaces \csa{@tempa,b} by \csa{FCD at tempa,b}. And its
+% \csa{FCD at get@aux} directly grabs |#2| rather than issuing \csa{@firstofone}.
% \begin{macrocode}
-\long\def\filecontentsdef at aux#1\filecontentsdef at aux{\@firstofone}%
-\def\filecontentsdef at get#1#2%
+\long\def\FCD at get@aux#1\FCD at get@aux#2{#2}%
+\def\FCD at get#1#2%
{%
- \def\@tempa{#1}\def\@tempb{{#2}}%
- \expandafter\filecontentsdef at aux\@gobbletwo#2\filecontentsdef at aux
+ \def\FCD at tempa{#1}\def\FCD at tempb{{#2}}%
+ \expandafter\FCD at get@aux\@gobbletwo#2\FCD at get@aux
\@thirdofthree
- \filecontentsdef at aux
+ \FCD at get@aux
{\ifcat\relax\noexpand#2\expandafter\@gobble\else\expandafter\@firstofone\fi}%
- {\edef\@tempb{{\expandafter\noexpand\csname#2\endcsname}}}%
- \expandafter\@tempa\@tempb
+ {\edef\FCD at tempb{{\expandafter\noexpand\csname#2\endcsname}}}%
+ \expandafter\FCD at tempa\FCD at tempb
}%
% \end{macrocode}
-% |v1.4| adds \cs{filecontentsdefmacro}. I abuse the \cs{if at filesw} toggle as there
-% is no \cs{if at tempswb} available. No need for a starred version as anyhow
-% the commented-out header was not put into the macro by the existing
-% \cs{filec at ntentsdef} code. No need to reset the toggle as only usage as
-% an environment is supported. And by lazyness and to spare extra coding,
-% \cs{endfilecontentsdefmacro} emits no warning about Form Feed and Tabulation.
+% |v1.4| adds \csa{filecontentsdefmacro}. I abuse the \csa{if at filesw} toggle as
+% there is no \csa{if at tempswb} available. No need for a starred version as
+% anyhow the commented-out header was not put into the macro by the existing
+% \csa{FCD at main} code. No need to reset the toggle as documentation explains
+% direct usage of the environment begin and end macros must be inside a
+% |\begingroup\endgroup| pair.
+%
+% |v1.5| adds the ``starred''-named variants as aliases.
% \begin{macrocode}
\begingroup
\catcode`\*=11
-\gdef\filecontentsdef #1{\@tempswatrue\filecontentsdef at get{\filec at ntentsdef{#1}}}%
-\gdef\filecontentsdef*#1{\@tempswafalse\filecontentsdef at get{\filec at ntentsdef{#1}}}%
-\global\let\endfilecontentsdef \endfilecontents
-\global\let\endfilecontentsdef*\endfilecontents
-\gdef\filecontentsdefmacro{\@fileswfalse\filecontentsdef at get{\filec at ntentsdef{}}}%
-\global\let\endfilecontentsdefmacro\relax
-\gdef\filecontentshere #1{\@tempswatrue\filec at ntentsdef{#1}\filecontentsheremacro}%
-\gdef\filecontentshere*#1{\@tempswafalse\filec at ntentsdef{#1}\filecontentsheremacro}%
-\gdef\endfilecontentshere{\endfilecontentsdef\aftergroup\filecontents at here}%
+\gdef\filecontentsdef #1{\let\FCD at global\@empty
+ \@tempswatrue\FCD at get{\FCD at main{#1}}}%
+\gdef\filecontentsdef*#1{\let\FCD at global\@empty
+ \@tempswafalse\FCD at get{\FCD at main{#1}}}%
+\global\let\filecontentsdefstarred\filecontentsdef*
+\gdef\filecontentsgdef #1{\@tempswatrue\FCD at get{\FCD at main{#1}}}%
+\gdef\filecontentsgdef*#1{\@tempswafalse\FCD at get{\FCD at main{#1}}}%
+\global\let\filecontentsgdefstarred\filecontentsgdef*
+% \end{macrocode}
+% |v1.5| can not use original \csa{endfilecontents} which makes reference to
+% \csa{reserved at c} whereas \fcdname now uses in its place \csa{FCD at reserved@c}.
+% Finally I drop altogether the bulk of this macro which issued a warning in
+% case of an encountered form feed or tabulation character.
+%
+% |v1.5| adds support for definitions with local scope so we must smuggle the
+% defined macro out of the environment. This is done via \csa{FCD at defmacro}
+% which is set-up via \csa{FCD at main}.
+% \begin{macrocode}
+\gdef\endfilecontentsdef{\immediate\closeout\FCD at reserved@c\FCD at defmacro}%
+\global\let\endfilecontentsdef*\endfilecontentsdef
+\global\let\endfilecontentsdefstarred\endfilecontentsdef
+\gdef\endfilecontentsgdef{\immediate\closeout\FCD at reserved@c}%
+\global\let\endfilecontentsgdef*\endfilecontentsgdef
+\global\let\endfilecontentsgdefstarred\endfilecontentsgdef
+\gdef\filecontentsdefmacro{\let\FCD at global\@empty
+ \@fileswfalse\FCD at get{\FCD at main{}}}%
+\gdef\endfilecontentsdefmacro{\FCD at defmacro}%
+\gdef\filecontentsgdefmacro{\@fileswfalse\FCD at get{\FCD at main{}}}%
+\global\let\endfilecontentsgdefmacro\relax
+\gdef\filecontentshere #1{\let\FCD at global\@empty
+ \@tempswatrue\FCD at main{#1}\filecontentsheremacro}%
+\gdef\filecontentshere*#1{\let\FCD at global\@empty
+ \@tempswafalse\FCD at main{#1}\filecontentsheremacro}%
+\global\let\filecontentsherestarred\filecontentshere*
+\gdef\endfilecontentshere{\endfilecontentsdef\aftergroup\FCD at here}%
\global\let\endfilecontentshere*\endfilecontentshere
+\global\let\endfilecontentsherestarred\endfilecontentshere
% \end{macrocode}
% Package |verbatim.sty| modifies the standard |verbatim| environment. For
% both the original and the modified version we need to insert an active |^^M|
@@ -961,20 +1403,48 @@
% the code compatible with further packages (I have not looked for them)
% modifying the |verbatim| environment. For better code readibility I use
% |^^M%|'s rather than exploiting the active ends of lines here.
+%
+% |v1.5| adds \csa{FCDprintenvname} which holds the name of the environment to
+% be used. Initially configured to hold of course |verbatim|. And it also adds
+% \csa{FCDprintenvoptions}.
% \begin{macrocode}
-\gdef\filecontentsprint{\filecontentsdef at get\filecontents at print}%
+\gdef\filecontentsprint{\FCD at get\FCD at print}%
\catcode`\^^M\active%
-\gdef\filecontents at print #1{\let\filecontents at print@EOL^^M\let^^M\relax%
- \begingroup\toks@\expandafter{#1}\edef\x{\endgroup%
- \noexpand\begin{verbatim}^^M%
- \the\toks@\@backslashchar end\string{verbatim\string}}\x^^M%
- \filecontents at print@resetEOL}%
-\gdef\filecontents at print@resetEOL{\let^^M\filecontents at print@EOL}%
+\gdef\FCD at print #1{\let\FCD at print@EOL^^M\let^^M\relax%
+ \begingroup\toks@\expandafter{#1}%
+ \edef\x{\endgroup%
+ \noexpand\begin{\FCDprintenvname}\FCDprintenvoptions^^M%
+ \the\toks@\@backslashchar end\string{\FCDprintenvname\string}}%
+ \x^^M%
+ \FCD at print@resetEOL}%
+\gdef\FCD at print@resetEOL{\let^^M\FCD at print@EOL}%
+\gdef\filecontentsprintviascan{\FCD at get\FCD at printviascan}%
+% \end{macrocode}
+% |v1.5| adds \csa{filecontentsprintviascan} which uses \csa{scantokens} to wrap
+% stored contents in a verbatim-like environment. This is needed for things
+% such as |listings| (it uses an active backslash at start of lines).
+% Attention to the \csa{scantokens} subtlety with \csa{end} which would become
+% |\end<space>| and then again |listings| would not recognize the ending
+% pattern.
+% \begin{macrocode}
+\gdef\FCD at printviascan#1{%
+ \toks@\expandafter{#1}%
+ \edef\FCD at envwithcontents{%
+ \noexpand\begin{\FCDprintenvname}\FCDprintenvoptions\noexpand^^M%
+ \the\toks@\@backslashchar end{\FCDprintenvname}\noexpand^^M}%
+ \FCD at exec\FCD at envwithcontents}%
\endgroup
-\def\filecontents at here{\filecontents at print\filecontentsheremacro}%
-\def\filecontentsexec{\filecontentsdef at get\filecontents at exec}%
-\def\filecontents at exec #1{\newlinechar13
- \scantokens\expandafter{#1}\newlinechar10\relax}%
+\def\FCDprintenvname{verbatim}%
+\let\FCDprintenvoptions\@empty
+\def\FCD at here{\FCD at print\filecontentsheremacro}%
+\def\filecontentsexec{\FCD at get\FCD at exec}%
+% \end{macrocode}
+% |v1.5| restores \csa{newlinechar} to its prior value, rather than setting it
+% to the \LaTeX{} default (10).
+% \begin{macrocode}
+\def\FCD at exec #1{\edef\FCD at newlinechar{\the\newlinechar}%
+ \newlinechar13
+ \scantokens\expandafter{#1}\newlinechar\FCD at newlinechar\relax}%
\endinput
% \end{macrocode}
% \MakePercentComment
Modified: trunk/Master/texmf-dist/tex/latex/filecontentsdef/filecontentsdef.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/filecontentsdef/filecontentsdef.sty 2019-09-29 21:13:43 UTC (rev 52207)
+++ trunk/Master/texmf-dist/tex/latex/filecontentsdef/filecontentsdef.sty 2019-09-29 21:13:57 UTC (rev 52208)
@@ -23,19 +23,25 @@
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{filecontentsdef}
- [2019/04/20 v1.4 filecontents + macro + verbatim (JFB)]
+ [2019/09/29 v1.5 filecontents + macro + verbatim (JFB)]
%%
%% Package: filecontentsdef
-%% Version: 1.4 (2019/04/20)
+%% Version: 1.5 (2019/09/29)
%% License: LPPL 1.3c
%% Copyright (C) 2016-2019 Jean-Francois Burnol <jfbu at free dot fr>
%%
+\let\FCD at global\global
\begingroup
\catcode`\^^M\active%
\catcode`\^^L\active\let^^L\relax%
\catcode`\^^I\active%
-\gdef\filec at ntentsdef#1#2{%
- \let#2\@empty%
+\gdef\FCD at main#1#2{%
+ \def\FCD at defmacro%
+ {\toks@\expandafter{#2}%
+ \edef\x{\endgroup\def\noexpand#2{\the\toks@}%
+ \begingroup\def\noexpand\@currenvir{\@currenvir}}%
+ \x}%
+ \FCD at global\let#2\@empty%
\if at filesw%
\openin\@inputcheck#1 %
\ifeof\@inputcheck%
@@ -46,11 +52,11 @@
{Overwriting file `\@currdir#1'}%
\fi%
\closein\@inputcheck%
- \chardef\reserved at c15 %
- \ch at ck7\reserved at c\write%
- \immediate\openout\reserved at c#1\relax%
+ \chardef\FCD at reserved@c15 %
+ \ch at ck7\FCD at reserved@c\write%
+ \immediate\openout\FCD at reserved@c#1\relax%
\if at tempswa%
- \immediate\write\reserved at c{%
+ \immediate\write\FCD at reserved@c{%
\@percentchar\@percentchar\space%
\expandafter\@gobble\string\LaTeX2e file `#1'^^J%
\@percentchar\@percentchar\space generated by the %
@@ -73,26 +79,32 @@
\ifnum\count@<\@cclvi%
\repeat%
\let^^L\relax%
- \edef\E{\@backslashchar end\string{\@currenvir\string}}%
- \edef\reserved at b{\def\noexpand\reserved at b####1\E####2\E####3\relax}%
- \reserved at b{%
+ \edef\FCD at E{\@backslashchar end\string{\@currenvir\string}}%
+ \edef\FCD at reserved@b{\def\noexpand\FCD at reserved@b####1\FCD at E####2\FCD at E####3\relax}%
+ \FCD at reserved@b{%
\ifx\relax##3\relax%
- \if at filesw\immediate\write\reserved at c{##1}\fi%
+ \if at filesw%
+ \let^^L\FCDformfeedtofile%
+ \let^^I\FCDtabtofile%
+ \immediate\write\FCD at reserved@c{##1}%
+ \fi%
\toks@\expandafter{#2}%
- {\def^^L{\noexpand^^M\noexpand^^M}\lowercase{\let^^I~}%
- \xdef#2{\the\toks@##1\noexpand^^M}}%
+ \let^^L\FCDformfeedtomacro%
+ \let^^I\FCDtabtomacro%
+ \FCD at global\edef#2{\the\toks@##1\noexpand^^M}%
\else%
\edef^^M{\noexpand\end{\@currenvir}}%
\ifx\relax##1\relax%
\else%
- \if at filesw%
- \@latex at warning{Writing text `##1' before %
- \string\end{\@currenvir}\MessageBreak as last line of #1}%
- \immediate\write\reserved at c{##1}%
- \fi%
+ \if at filesw%
+ \let^^L\FCDformfeedtofile%
+ \let^^I\FCDtabtofile%
+ \immediate\write\FCD at reserved@c{##1}%
+ \fi%
\toks@\expandafter{#2}%
- {\def^^L{\noexpand^^M\noexpand^^M}\lowercase{\let^^I~}%
- \xdef#2{\the\toks@##1\noexpand^^M}}%
+ \let^^L\FCDformfeedtomacro%
+ \let^^I\FCDtabtomacro%
+ \FCD at global\edef#2{\the\toks@##1\noexpand\empty\noexpand^^M}%
\fi%
\ifx\relax##2\relax%
\else%
@@ -102,52 +114,81 @@
\fi%
^^M}%
\catcode`\^^L\active%
- \let\L\@undefined%
- \def^^L{\expandafter\ifx\csname L\endcsname\relax\fi^^J^^J}%
\catcode`\^^I\active%
- \let\I\@undefined%
- \def^^I{\expandafter\ifx\csname I\endcsname\relax\fi\space}%
\catcode`\^^M\active%
- \edef^^M##1^^M{\noexpand\reserved at b##1\E\E\relax}%
+ \edef^^M##1^^M{\noexpand\FCD at reserved@b##1\FCD at E\FCD at E\relax}%
\catcode32\active\lccode`~32 \lowercase{\def~{\noexpand~}}%
}%
-\endgroup
-\long\def\filecontentsdef at aux#1\filecontentsdef at aux{\@firstofone}%
-\def\filecontentsdef at get#1#2%
+\gdef\FCDformfeedtofile{^^J^^J}%
+\gdef\FCDformfeedtomacro{\noexpand^^M\noexpand^^M}%
+\gdef\FCDtabtofile{ }%
+\catcode32\active\gdef\FCDtabtomacro{\noexpand }%
+\endgroup%
+\long\def\FCD at get@aux#1\FCD at get@aux#2{#2}%
+\def\FCD at get#1#2%
{%
- \def\@tempa{#1}\def\@tempb{{#2}}%
- \expandafter\filecontentsdef at aux\@gobbletwo#2\filecontentsdef at aux
+ \def\FCD at tempa{#1}\def\FCD at tempb{{#2}}%
+ \expandafter\FCD at get@aux\@gobbletwo#2\FCD at get@aux
\@thirdofthree
- \filecontentsdef at aux
+ \FCD at get@aux
{\ifcat\relax\noexpand#2\expandafter\@gobble\else\expandafter\@firstofone\fi}%
- {\edef\@tempb{{\expandafter\noexpand\csname#2\endcsname}}}%
- \expandafter\@tempa\@tempb
+ {\edef\FCD at tempb{{\expandafter\noexpand\csname#2\endcsname}}}%
+ \expandafter\FCD at tempa\FCD at tempb
}%
\begingroup
\catcode`\*=11
-\gdef\filecontentsdef #1{\@tempswatrue\filecontentsdef at get{\filec at ntentsdef{#1}}}%
-\gdef\filecontentsdef*#1{\@tempswafalse\filecontentsdef at get{\filec at ntentsdef{#1}}}%
-\global\let\endfilecontentsdef \endfilecontents
-\global\let\endfilecontentsdef*\endfilecontents
-\gdef\filecontentsdefmacro{\@fileswfalse\filecontentsdef at get{\filec at ntentsdef{}}}%
-\global\let\endfilecontentsdefmacro\relax
-\gdef\filecontentshere #1{\@tempswatrue\filec at ntentsdef{#1}\filecontentsheremacro}%
-\gdef\filecontentshere*#1{\@tempswafalse\filec at ntentsdef{#1}\filecontentsheremacro}%
-\gdef\endfilecontentshere{\endfilecontentsdef\aftergroup\filecontents at here}%
+\gdef\filecontentsdef #1{\let\FCD at global\@empty
+ \@tempswatrue\FCD at get{\FCD at main{#1}}}%
+\gdef\filecontentsdef*#1{\let\FCD at global\@empty
+ \@tempswafalse\FCD at get{\FCD at main{#1}}}%
+\global\let\filecontentsdefstarred\filecontentsdef*
+\gdef\filecontentsgdef #1{\@tempswatrue\FCD at get{\FCD at main{#1}}}%
+\gdef\filecontentsgdef*#1{\@tempswafalse\FCD at get{\FCD at main{#1}}}%
+\global\let\filecontentsgdefstarred\filecontentsgdef*
+\gdef\endfilecontentsdef{\immediate\closeout\FCD at reserved@c\FCD at defmacro}%
+\global\let\endfilecontentsdef*\endfilecontentsdef
+\global\let\endfilecontentsdefstarred\endfilecontentsdef
+\gdef\endfilecontentsgdef{\immediate\closeout\FCD at reserved@c}%
+\global\let\endfilecontentsgdef*\endfilecontentsgdef
+\global\let\endfilecontentsgdefstarred\endfilecontentsgdef
+\gdef\filecontentsdefmacro{\let\FCD at global\@empty
+ \@fileswfalse\FCD at get{\FCD at main{}}}%
+\gdef\endfilecontentsdefmacro{\FCD at defmacro}%
+\gdef\filecontentsgdefmacro{\@fileswfalse\FCD at get{\FCD at main{}}}%
+\global\let\endfilecontentsgdefmacro\relax
+\gdef\filecontentshere #1{\let\FCD at global\@empty
+ \@tempswatrue\FCD at main{#1}\filecontentsheremacro}%
+\gdef\filecontentshere*#1{\let\FCD at global\@empty
+ \@tempswafalse\FCD at main{#1}\filecontentsheremacro}%
+\global\let\filecontentsherestarred\filecontentshere*
+\gdef\endfilecontentshere{\endfilecontentsdef\aftergroup\FCD at here}%
\global\let\endfilecontentshere*\endfilecontentshere
-\gdef\filecontentsprint{\filecontentsdef at get\filecontents at print}%
+\global\let\endfilecontentsherestarred\endfilecontentshere
+\gdef\filecontentsprint{\FCD at get\FCD at print}%
\catcode`\^^M\active%
-\gdef\filecontents at print #1{\let\filecontents at print@EOL^^M\let^^M\relax%
- \begingroup\toks@\expandafter{#1}\edef\x{\endgroup%
- \noexpand\begin{verbatim}^^M%
- \the\toks@\@backslashchar end\string{verbatim\string}}\x^^M%
- \filecontents at print@resetEOL}%
-\gdef\filecontents at print@resetEOL{\let^^M\filecontents at print@EOL}%
+\gdef\FCD at print #1{\let\FCD at print@EOL^^M\let^^M\relax%
+ \begingroup\toks@\expandafter{#1}%
+ \edef\x{\endgroup%
+ \noexpand\begin{\FCDprintenvname}\FCDprintenvoptions^^M%
+ \the\toks@\@backslashchar end\string{\FCDprintenvname\string}}%
+ \x^^M%
+ \FCD at print@resetEOL}%
+\gdef\FCD at print@resetEOL{\let^^M\FCD at print@EOL}%
+\gdef\filecontentsprintviascan{\FCD at get\FCD at printviascan}%
+\gdef\FCD at printviascan#1{%
+ \toks@\expandafter{#1}%
+ \edef\FCD at envwithcontents{%
+ \noexpand\begin{\FCDprintenvname}\FCDprintenvoptions\noexpand^^M%
+ \the\toks@\@backslashchar end{\FCDprintenvname}\noexpand^^M}%
+ \FCD at exec\FCD at envwithcontents}%
\endgroup
-\def\filecontents at here{\filecontents at print\filecontentsheremacro}%
-\def\filecontentsexec{\filecontentsdef at get\filecontents at exec}%
-\def\filecontents at exec #1{\newlinechar13
- \scantokens\expandafter{#1}\newlinechar10\relax}%
+\def\FCDprintenvname{verbatim}%
+\let\FCDprintenvoptions\@empty
+\def\FCD at here{\FCD at print\filecontentsheremacro}%
+\def\filecontentsexec{\FCD at get\FCD at exec}%
+\def\FCD at exec #1{\edef\FCD at newlinechar{\the\newlinechar}%
+ \newlinechar13
+ \scantokens\expandafter{#1}\newlinechar\FCD at newlinechar\relax}%
\endinput
%%
%% End of file `filecontentsdef.sty'.
More information about the tex-live-commits
mailing list