diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/fileinfo/myfilist.sty |
Initial commit
Diffstat (limited to 'macros/latex/contrib/fileinfo/myfilist.sty')
-rw-r--r-- | macros/latex/contrib/fileinfo/myfilist.sty | 277 |
1 files changed, 277 insertions, 0 deletions
diff --git a/macros/latex/contrib/fileinfo/myfilist.sty b/macros/latex/contrib/fileinfo/myfilist.sty new file mode 100644 index 0000000000..c3fd202e32 --- /dev/null +++ b/macros/latex/contrib/fileinfo/myfilist.sty @@ -0,0 +1,277 @@ +\def \filename {myfilist.sty} %% macro package for LaTeX, + +%% modifies \listfiles to choose files to be listed and +%% list them in a chosen file. + +\def \fileversion {0.71} \def \filedate {2012/11/22} + +%% copyright (C) 2008, 2010, 2011, 2012 Uwe Lueck, +%% http://www.contact-ednotes.sty.de.vu +%% -- author-maintained in the sense of LPPL below. +%% +%% This file can be redistributed and/or modified under +%% the terms of the LaTeX Project Public License; either +%% version 1.3a of the License, or any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% We did our best to help you, but there is NO WARRANTY. +%% +%% Please report bugs, problems, and suggestions via +%% +%% http://www.contact-ednotes.sty.de.vu +%% +% USAGE: +% +% Write a script file like gather.tex which you should have received +% together with myfilist.sty. We use LaTeX2e (required!), yet (in +% general) not for typesetting a document, therefore the script file +% needn't contain \documentclass. myfilist.sty is loaded by +% +% \RequirePackage{myfilist} +% +% instead of \usepackage{myfilist}. Usually you don't want to have +% myfilist.sty in the list, so type +% +% \EmptyFileList +% +% next; or type it after some additional \RequirePackage... for +% packages you want to use but not list. +% +% Next list the names of the files +% whose informations you want to get as arguments of +% +% \ReadFileInfos or \ReadPackageInfos or \ReadClassInfo +% +% With the latter two, you can omit ".sty" or ".cls" as with +% \usepackage and \documentclass. With the first one, the file name +% extension ".tex" may be omitted. The two first commands accept lists +% with commas as separators almost like with \usepackage (currently we +% must use "%" to hide a line break in the script, and there must be +% no spaces in the list).---For more details on these commands, +% please see readprov.pdf. +% +% The list of files is actually printed in the transcript .log +% and on screen on +% +% \ListInfos +% +% The list can additionally be written into a plain text file, +% +% \ListInfos[filelist.txt] +% +% as an example; i.e., you can use the brackets to tell which file is +% to contain your list of files. The file informations appear in the +% order of their names in your script file. +% +% \ListInfos concludes, ends the job, anything following in the +% script file will be ignored.---All of this requires %% 2010/04/02 +% that you run gather.tex or your other script file, about as +% +% latex gather +% +% To list files that were loaded earlier in a different order, +% list them in an \emph{optional argument} of \EmptyFileList, e.g., +% % trick avoiding main replacement 2010/11/26: +% +% \EmptyFileList[myfilist-.sty,readprov-.sty] +% +% NOTE: myfilist.sty (in its present state) is unable to list files +% that don't contain \ProvidesPackage, \ProvidesClass, or +% \ProvidesFile. myfilist.sty "loads" files to extract version +% informations, but quits them as soon as it has found one of these +% LaTeX2e commands. +% +% VARIANTS: +% +% v0.5 provides different interfaces to reduce (shared) TeX code +% when (similar) shell or batch scripts generate that gather.tex. +% +% \ReadListFileInfos[<txt-file>]{<tex-files>} +% +% is a shorthand for +% +% \ReadFileInfos{<tex-files>} +% \ListInfos[<txt-file>] +% +% \emph{Without} the optional argument, the screen output is \emph{not} +% written to disk---by default. However, preceding \ReadListFileInfos +% by +% +% \WriteFileInfosTo{<txt-file>} +% +% is an alternative way to get the list in the plain text file. +% +% \FindReadListFileInfos[<txt-file>]{<tex-files>} +% +% must be used rather than \ReadListFileInfos\ when the comma-separated +% list (generated by the "find" utility) \emph{starts} with a comma. +% Alternatively, +% +% \UseFindUtility +% +% preceding \ReadListFileInfos deals with the leading comma. +% +% v0.7 adds +% +% \NoStopListInfos[filelist.txt] +% +% after which the script can continue until \stop, e.g., for checks +% with filedate.sty so that the latter's messages are the final lines +% you see on screen. +% +% TRICKS: +% +% v0.6 first provides (e.g.) +% +% \FileListRemark[----]{---DOC.---} +% +% in order to insert `---DOC.--- ----' in the list. This writes +% funny files that may be somewhat dangerous ... +% I have used a bash script version of this for structuring +% large file lists. +% +% v0.6 moreover provides two hooks and a package option +% useful for the adhocfilelist package, +% or perhaps even otherwise. +% +% \ListGenerator +% +% is a hook for the final lines in the plain text output file (see implementation). +% +% \NoBottomLines +% +% suppresses final messages of the LaTeX run, which may be nicer and +% more informative on the screen. Package Option +% +% [no-bot] +% +% is a kind of shorthand to issue \NoBottomLines. +% +% IMPLEMENTATION: +% +\NeedsTeXFormat{LaTeX2e}[1994/12/01] %% \newcommand* etc. +\ProvidesPackage{myfilist} + [\filedate\space v\fileversion \space + \string\listfiles\space-- mine only (UL)] +% +% |\ReadFileInfos|, |\ReadPackageInfos|, and |\ReadClassInfo| +% are implemented in readprov.sty: +\RequirePackage{readprov}[2010/11/26] +% +% |\EmptyFileList[<read-again-files>]| %% opt. arg. 2010/11/26 +\newcommand{\EmptyFileList}[1][]{% + \let\@filelist\@gobble + \@for\@tempa:=#1\do{% + \global \expandafter \let \csname ver@\@tempa\endcsname \relax + %% v0.4: + \global \expandafter \let \csname opt@\@tempa\endcsname \relax}} +% |\ListInfos[<output-file>]| %% was `external output file' 2012/10/25 +\newcommand*{\ListInfos}[1][]{% + \ifx$#1$\@dofilelist\else + % \newwrite\file@of@filelist %% mv. v0.6 + \immediate\openout\file@of@filelist=#1\relax + \def\typeout##1{% + \read@@typeout{##1}% + \immediate\write\file@of@filelist{##1}}% + \@dofilelist + %% made at: + \@tempcnta\time \@tempcntb\@tempcnta + \divide\@tempcnta 60 \count@\@tempcnta + \multiply\count@ 60 \advance\@tempcntb -\count@ + \typeout{ List made at + \the\year/\two@digits{\the\month}/\two@digits{\the\day}, + \two@digits{\the\@tempcnta}:\two@digits{\the\@tempcntb}% +% v0.6 becomes more flexible here: + \ListGenerator} + \immediate\closeout\file@of@filelist + \fi + \stop} + %% <- TODO how to suppress first empty line? 2008/03/16 +\newwrite\file@of@filelist %% mv. v0.6 +% emulating versions before v0.6: +\providecommand*{\ListGenerator}{% + ^^J from script file \jobname.tex^^J} +\let\read@@typeout\typeout +% |\NoStopListInfos[<output-file>]| (v0.7) +\newcommand*{\NoStopListInfos}[1][]{{\let\stop\relax \ListInfos[#1]}} +% v0.5: +% +% There is a little (design) bug in \ListInfos: +% When gather.tex's last line is \ListInfos without optional +% argument or anything, LaTeX prompts for further input. +% This might be fixed using ifnextok.sty, but I am not sure +% right now. In |\VarListInfos|, \relax stops waiting for +% input. \providecommand means that the default can be +% overridden before loading myfilist.sty: +\providecommand*{\VarListInfos}{\ListInfos\relax} +% |\WriteFileInfosTo{<txt-file>}| overrides the previous default: +\newcommand*{\WriteFileInfosTo}[1]{% + \renewcommand\VarListInfos{\ListInfos[#1]}} +% |\ReadListFileInfos[<txt-file>]{<tex-files>}| +\newcommand*{\ReadListFileInfos}[2][]{% + \ifx$#1$\else\WriteFileInfosTo{#1}\fi + \read@comma@guard\read@list@file@infos#2\stop} +\let\read@comma@guard\@empty +\def\read@list@file@infos#1\stop{% +% Here |\VarListInfos| is used finally: + \ReadFileInfos{#1}\VarListInfos} +% |\UseFindUtility| activates \read@comma@guard in order +% to kill a leading comma: +\newcommand*{\UseFindUtility}{% + \let\read@comma@guard\@firstoftwo} +% |\FindReadListFileInfos[<txt-file>]{<tex-files>}| +\newcommand*{\FindReadListFileInfos}{% + \UseFindUtility\ReadListFileInfos} +% v0.6: +% +% |\FileListRemark[<info>]{<filename>}|\\ +% writes and reads a dummy file <filename> with \Provides... +% content <info> which is empty by default: +\newcommand*\FileListRemark[2][]{% + \immediate\openout\file@of@filelist#2 + \immediate\write\file@of@filelist{% + \string\ProvidesFile{#2}[#1]}% + \immediate\closeout\file@of@filelist +% v0.71 allows using \FileListRemark with 'filedate''s +% \FileDateAutoChecks: + {\ifx\@providesfile\FD@provfile + \let\@pr@videpackage\FD@@provpkg + \let\@providesfile \FD@@provfile + \fi + \ReadFileInfos{#2}}} +% +% |\NoBottomLines| +\newcommand*{\NoBottomLines}{% + \let\STOP\stop \def\stop{\batchmode\STOP}} +% Package option |[no-bot]|: +\DeclareOption{no-bot}{\NoBottomLines} +\ProcessOptions +% Finally issuing |\listfiles| (already before v0.5): +\listfiles + +\endinput + +%% VERSION HISTORY +v0.1 2008/03/19 created file "readprov.sty" + 2008/03/23 smart file name separation, \ifx$ for \ifcat$ + 2008/05/22 typo ist -> it +v0.2 2010/04/03 renamed "myfiles.sty"; + broke long lines etc. for doc +SENT TO CTAN -- declined +v0.2a 2010/04/08 undoubled \NeedsTeXFormat, copyright updated +v0.3 2010/11/26 split off from "myfiles.sty", opt. arg. for + \EmptyFileList, doc. reworked + 2010/11/27 some USAGE clarifications +v0.3a 2011/01/29 two empty lines commented out + 2011/01/30 copyright updated +v0.4 2012/05/26 \EmptyFileList clears options +v0.5 2012/09/27 \ReadListFileInfos, \WriteFileList, + \FindReadListInfos, \UseFindUtility +v0.6 2012/10/11 \FileListRemark, \ListGenerator, + \NoBottomLines, [no-bot] +v0.6a 2012/10/12 adding \UseFindUtility and \FindReadListInfos + in the history for v0.5 +v0.7 2012/10/25 \NoStopListInfos +v0.71 2012/11/22 \FileListRemark works with \FileDateAutoChecks + from `readprov.sty' v0.5; + doc. \FileListRemark: `\ ' -> `\\' |