summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicefilelist/nicefilelist.sty
blob: 79d3ad0fafdeca6e41085e3add285be40381d30e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{nicefilelist}[2012/03/23 v0.1 
                               more file list alignment (UL)]

%% Copyright (C) 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.3c 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
%%
%% === Alignment Settings ===
%% \label{sec:templates}
%% We use the \ctanpkgref{monofill} package for alignment of plain text:
\RequirePackage{monofill}
%% See its documentation for details.
%%
%% We support three alignment ``fields" according to the terminology of \pkg{monofill}. 
%% Their ids are |f-base| for base filenames, |f-ext| for filename extensions, 
%% % |f-date| for the revision date, 
%% and |f-version| for the revision version id of a file %%% , 
%% % the latter two 
%% as read from `\ProvidesFile', `\ProvidesPackage', 
%% or `\ProvidesClass' command in the file.
%% Initial settings for them are following.
%% For modifying them, load 'nicefilelist.sty', 
%% then type your own settings, then issue `\listfiles'
%% or load 'myfilist.sty'.
\MFfieldtemplate{f-base}{nicefilelist}
\MFfieldtemplate{f-ext}{tex}
\MFfieldtemplate{f-version}{v0.11a}
%% We are not supporting version numbers greater than 9 at present---sorry! (TODO)
%% 
%% |\NFLspaceI|, |\NFLspaceII|, and |\NFLspaceIII| 
%% determine the space between the four 
%% columns for names, dates, versions, and ``captions":
\newcommand*{\NFLspaceI}  { \space}
\newcommand*{\NFLspaceII} { \space}
\newcommand*{\NFLspaceIII}{ }
%% 
%% === Failure Displays ===
%% \label{sec:failure}
%% |\NFLnodate| is displayed in place of a file date if it seems 
%% not to be given (configurable):
\newcommand*{\NFLnodate}{ -- \space-- --}
%% |\NFLnoversion| likewise---however, for alignment, 
%% each wanted space must be specified as `\space'
%% (not just a code blank space). 
%% It may need adjustment (by `\renewcommand') when
%% `\MFfieldtemplate{f-version}' is modified:
\newcommand*{\NFLnoversion}{\space--}
%% |\NFLnotfound| is for files with wrong or no 
%% \cs{Provides.\empty..} command:
\newcommand*{\NFLnotfound}{ * NOT FOUND *}
%% 
%% === Redefining \cs{listfiles} ===
%% Similarly to original \LaTeX, |\listfiles| carries almost everything 
%% that is needed for the file list only:
\renewcommand*{\listfiles}{%
  \let\listfiles\relax
%% ---this clears memory. Now \LaTeX\ requires that `\@listfiles'
%% is defined, although we don't use it 
%% (TODO use it in place of some `\NFL@'...?):
  \let\@listfiles\relax
%% |\@dofilelist| is executed by the standard \LaTeX\ `\enddocument'
%% macro or by `\ListInfos' from the \ctanpkgref{myfilist} package.
  \def\@dofilelist{%
%% ``Title:"
     \typeout{^^J \space\space
              \MFrightinfield{*File List*}{f-base}}%
     \@for\@currname:=\@filelist\do{%
%% This starts the loop through the list of files
       \filename@parse\@currname
       \edef\filename@ext{%
          \ifx\filename@ext\relax tex\else\filename@ext\fi}%
       \expandafter\let\expandafter\NFL@ver
            \csname ver@\filename@base.\filename@ext\endcsname
%% Some assignments for parsing file info, resembling \LaTeX's 
%% `\GetFileInfo', to make life within `\typout{<?>}' easier:
       \ifx\NFL@ver\relax \else
%% We assume that no date is given, until we find it; 
%% likewise for version: 
         \let\NFL@date   \NFLnodate
         \let\NFL@version\NFLnoversion
         \ifx\NFL@ver\@empty \else
           \ifx\NFL@ver\space
%              \let\NFL@ver\@empty
           \else
%% `\NFL@words' aims to be more careful than \LaTeX's `\GetFileInfo':
             \expandafter \NFL@words \NFL@ver 
               \@gobble? \@gobble? \@gobble?\@gobble?%
%% \cs{filedate} is not empty at the present condition, 
%% let's see if it starts with a date:
             \expandafter\NFL@test@date\filedate
%% Dummies in case \cs{filedate} has less elements than 
%% \cs{NFL@test@date} tries to read:
                \@empty\@empty\@empty\@empty\@empty
                       \@empty\@empty\@empty\@empty
                  \@nil
             \if@tempswa 
               \let\NFL@date\filedate
%% Is \cs{fileversion} a version id?
               \ifx\fileversion\@empty \else
                 \expandafter\NFL@test@version\fileversion\@empty\@nil
               \fi
%% Otherwise, the first word could be a version number---we 
%% ignore such awkward files in this package version (TODO) 
%% and even assume that no version is indicated.
%              \else 
             \fi
           \fi
         \fi
%% When \cs{filedate} is not a file date, it is considered part of 
%% the file ``caption," likewise for version:
         \edef\fileinfo{%
            \ifx\NFL@date\NFLnodate       \filedate    \space \fi
            \ifx\NFL@version\NFLnoversion \fileversion \space \fi
            \fileinfo}%
       \fi
       \typeout{%
%% Now all parsing and checking must be expandable.
         \NFL@make@macro@arg\MFrightinfield\filename@base{f-base}.%
         \NFL@make@macro@arg\MFleftinfield \filename@ext {f-ext}%
         \NFLspaceI
         \ifx\NFL@ver\relax
           \NFLnotfound
         \else
           \NFL@date
           \NFLspaceII      %% TODO conditionally?
           \NFL@make@macro@arg\MFleftinfield\NFL@version {f-version}%
           \NFLspaceIII     %% TODO conditionally?
           \fileinfo
         \fi
       }%
     }%
%% The line of stars:
     \typeout{ \space\space\space 
              \MFrightinfield{***********}{f-base}^^J}%
%% TODO or more stars as with 'longnamefilelist'?
  }%
%% This finishes the definition of `\@dofilelist'. 
%% The definitions of macros called from `\@dofilelist' are following.
%% |\NFL@words| tries to get the first three ``words":
  \def\NFL@words##1 ##2 ##3\@gobble?{%
    \edef\filedate{##1}\edef\fileversion{##2}\edef\fileinfo{##3}%
%% When the result of ```\csname ver@<file>\endcsname'" 
%% contains a single space token only, 
%% \cs{fileinfo} contains the result of expanding ```\@gobble? '", 
%% as opposed to ```\@gobble?"' in other cases. Thus this ``normalization":
    \ifx\fileinfo\space \let\fileinfo\@empty \fi }%
%% |\NFL@test@date| checks whether the first ``word" is a date:
  \def\NFL@test@date##1##2##3##4##5##6##7##8##9{%
    \@tempswatrue
%% Are there slashes at the correct positions?
    \if/##5\else\@tempswafalse\fi
    \if/##8\else\@tempswafalse\fi
%% Now we test the eight positions of expected digits:
    \NFL@test@digits{##1##2##3##4##6##7##9}}%
  \def\NFL@test@digits##1##2##3\@nil{%
%% It's not a date if it has more than 10 characters (TODO?).
%% If it \emph{is} a date, #2 is the last digit,
%% and #3 contains the dummies, and then?
    \edef\@tempa{##3}%
%      \typein{##1}%
    \ifx\@tempa\@empty \NFL@test@digit ##1##2\@nnil 
                           \else \@tempswafalse \fi }%
  \def\NFL@test@digit##1{%
    \ifx##1\@nnil \else
      \ifnum`##1<48 \@tempswafalse
      \else        \ifnum`##1>57 \@tempswafalse \fi
      \fi
%      \typein{code of ##1 is \number`##1.}%
      \if@tempswa
        \expandafter\expandafter\expandafter \NFL@test@digit
      \else
        \expandafter\expandafter\expandafter\NFL@kill
      \fi
    \fi 
  }%
  \def\NFL@kill##1\@nnil{}%
%% TODO or use \ctanpkgref{coolstr}?
%% or there may be \emph{some} package that offers a test 
%% whether something is a date.
%% \vskip\smallskipamount\noindent
%% |\NFL@test@version| checks whether the second ``word" is a version id:
  \def\NFL@test@version##1##2##3\@nil{%
    \if v##1\NFL@test@digit##2\@nnil \else \@tempswafalse \fi
    \if@tempswa \let\NFL@version\fileversion \fi
  }%
%% |\NFL@make@macro@arg| expands a macro storing a list inside braces 
%% (perhaps 'monofill' should offer such a thing TODO):
  \def\NFL@make@macro@arg##1##2{\expandafter##1\expandafter{##2}}%
}
%% === Leaving the Package File ===
\endinput
%%
%% === VERSION HISTORY ===

v0.1   2012/03/20   started 
       2012/03/22   almost ready
       2012/03/23   debugging; \NFLspaceI etc.; 
                    documentation completed