[latex3-commits] [latex3/latex2e] gh945: Add optional argument to \listfiles (7c9885b4)
github at latex-project.org
github at latex-project.org
Wed Nov 15 11:09:16 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : gh945
Link : https://github.com/latex3/latex2e/commit/7c9885b43523d9d1dbf07ef79a225c42f9aefe2e
>---------------------------------------------------------------
commit 7c9885b43523d9d1dbf07ef79a225c42f9aefe2e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed Nov 15 10:09:16 2023 +0000
Add optional argument to \listfiles
>---------------------------------------------------------------
7c9885b43523d9d1dbf07ef79a225c42f9aefe2e
base/changes.txt | 6 ++++++
base/doc/usrguide.tex | 35 ++++++++++++++++++++++++++++++++
base/ltfiles.dtx | 55 ++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 51e856dd..bc51ce58 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================
+2023-11-15 Joseph Wright <Joseph.Wright at latex-project.org>
+ * ltfiles.dtx (subsection{Listing files}):
+ Extend \listfiles to optionally include file sizes and hashes
+ * usrguide.tex
+ Re-introduce \listfiles (extended) description
+
2023-11-09 Yukai Chou <muzimuzhi at gmail.com>
* clsguide-historic.tex, usrguide.tex:
Replace quotation with quote envs for zero para indent
diff --git a/base/doc/usrguide.tex b/base/doc/usrguide.tex
index 69428d96..002e2cf9 100644
--- a/base/doc/usrguide.tex
+++ b/base/doc/usrguide.tex
@@ -1258,4 +1258,39 @@ between dotted- and dotless-i, one could use for example
|\DeclareUppercaseMapping[xx]{"0131}{I}|
\end{quote}
+\section{Support for problem solving}
+
+\begin{decl}
+ |\listfiles| \oarg{options}
+\end{decl}
+
+If this command is placed in the preamble then a list of the files
+read in (as a result of processing the document) will be displayed
+on the terminal (and in the log file) at the end of the run. Where
+possible, a short description will also be produced. These descriptions
+will (hopefully) include the descriptions, dates and version numbers
+for package and class files.
+
+Sometimes, if may be that a local edit has been made to a package or
+class file (or rather a copy of such a file). To allow these cases to
+be identified, \cs{listfiles} takes an optional argument which allows
+adjustment of the information printed using a key--value approach
+\begin{description}
+ \item[\texttt{hashes}] Adds the MD5 hash for each file to the
+ information printed
+ \item[\texttt{sizes}] Adds the file size for each file to the
+ information printed
+\end{description}
+Note that the difference in line ends used by Windows and Unix
+systems \emph{does} show up here: as such, you should compare
+results from computers using the same operating system.
+
+\emph{Warning}: this command will list only files which were read
+using \LaTeX{} commands such as |\input|\arg{file} or
+|\include|\arg{file}. If the file was read using the primitive \TeX{}
+syntax |\input |\emph{file} (without |{ }| braces around the file name)
+then it will not be listed; failure to use the \LaTeX{} form with the
+braces can cause more severe problems, possibly leading to overwriting
+important files, so \textbf{always put in the braces}.
+
\end{document}
diff --git a/base/ltfiles.dtx b/base/ltfiles.dtx
index f079c2cf..3ed56def 100644
--- a/base/ltfiles.dtx
+++ b/base/ltfiles.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2023/06/17 v1.2u LaTeX Kernel (File Handling)]
+ [2023/11/15 v1.2v LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -1682,6 +1682,22 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\if at listfiles@hashes}
+% \changes{v1.2v}{2023/11/15}{Extend file list information}
+% \begin{macro}{\if at listfiles@sizes}
+% \changes{v1.2v}{2023/11/15}{Extend file list information}
+% \begin{macrocode}
+\ExplSyntaxOn
+\keys_define:nn { __kernel / listfiles }
+ {
+ hashes .legacy_if_set:n = @listfiles at hashes ,
+ sizes .legacy_if_set:n = @listfiles at sizes
+ }
+\ExplSyntaxOff
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\listfiles}
% A preamble command to cause |\end{document}| to list files input
% from the main file.
@@ -1693,8 +1709,10 @@
% {Stop \cs{listfiles} being run twice}
% \changes{v1.0i}{1994/10/18}
% {code moved here from ltclass}
+% \changes{v1.2v}{2023/11/15}{Extend file list information}
% \begin{macrocode}
-\def\listfiles{%
+\NewDocumentCommand\listfiles{O{}}{%
+ \SetKeys[__kernel/listfiles]{#1}%
\let\listfiles\relax
\def\@listfiles##1##2##3##4##5##6##7##8##9\@@{%
\def\reserved at d{\\}%
@@ -1730,9 +1748,40 @@
\filename at area\filename at base\\\\\\\\\\\\\\\\\\\@@
\typeout{%
\filename at area\reserved at a
- \ifx\reserved at b\relax\else\@spaces\reserved at b\fi}}%
+ \ifx\reserved at b\relax\else\@spaces\reserved at b\fi
+% \end{macrocode}
+% Now we add the additional information if requested.
+% \begin{macrocode}
+ \ifnum0%
+ \if at listfiles@hashes1\fi
+ \if at listfiles@sizes1\fi
+ >0 %
+ ^^J\@spaces
+ (%
+ \if at listfiles@sizes
+ size \@dofilelist at size\@currname
+ \if at listfiles@hashes
+ , %
+ \fi
+ \fi
+ \if at listfiles@hashes
+ hash \@dofilelist at hash\@currname
+ \fi
+ )%
+ \fi
+ }}%
\typeout{ ***********^^J}}}
% \end{macrocode}
+% \begin{macro}{\@dofilelist at hash}
+% \begin{macro}{\@dofilelist at size}
+% \begin{macrocode}
+\ExplSyntaxOn
+\cs_new_eq:NN \@dofilelist at hash \file_mdfive_hash:n
+\cs_new_eq:NN \@dofilelist at size \file_size:n
+\ExplSyntaxOff
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
%
% \changes{LaTeX2e}{1994/03/13}
% {Reset \cs{@addtofilelist} at begin document}
More information about the latex3-commits
mailing list.