summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/base/list-latin.tex
blob: 71d5bb6d9a1014407a2a934fe72fa946844cbef3 (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
% This program by D. E. Knuth is not copyrighted and can be used freely.
% Makes a listing of one or more files
% Extended to allow the Latin-1 accented characters in UTF-8 encoding
% Typical usage:
% tex list-latin *.txt \\end

\def\grabfile#1 {\setbox0=\lastbox\endgraf\doit{#1}}
\everypar{\grabfile}

\font\filenamefont= cmtt8 scaled\magstep3
\font\headlinefont= cmr8
\font\listingfont= cmtex10
\font\ttfont= cmtt10
\font\syttfont= cmsytt10
\font\eoffont= cmti8

\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\newcount\m \newcount\n
\n=\time \divide\n 60 \m=-\n \multiply\m 60 \advance\m \time
\def\hours{\twodigits\n\twodigits\m}
\def\twodigits#1{\ifnum #1<10 0\fi \number#1}

\newlinechar=`@
\message{@\today\space at \hours}

\raggedbottom
\nopagenumbers

\newcount\n
\catcode`\^^c3=\active
\def\missing{{\syttfont\char15}}
\def^^c3#1{\n=`#1\advance\n by-128
  {\ttfont\ifcase\n 
  \`A\or\'A\or\^A\or\~A\or\"A\or\AA\or\AE\or\c C\or
  \`E\or\'E\or\^E\or\"E\or\`I\or\'I\or\^I\or\"I\or
  \missing\or\~N\or\`O\or\'O\or\^O\or\~O\or\"O\or{\syttfont\char2}\or
  \O\or\`U\or\'U\or\^U\or\"U\or\'Y\or\missing\or\ss\or
  \`a\or\'a\or\^a\or\~a\or\"a\or\aa\or\ae\or\c c\or
  \`e\or\'e\or\^e\or\"e\or\`\i\or\'\i\or\^\i\or\"\i\or
  \missing\or\~n\or\`o\or\'o\or\^o\or\~o\or\"o\or{\syttfont\char4}\or
  \o\or\`u\or\'u\or\^u\or\"u\or\'y\or\missing\or\"y\fi}}

\chardef\other=12
\def\doit#1{\message{@Listing #1@}
  \begingroup \everypar{} \frenchspacing
  \headline{\filenamefont#1\quad\headlinefont \today\ at \hours
      \hfill Page \folio}
  \def\do##1{\catcode`##1=\other}\dospecials
  \catcode127=\other \catcode9=\other \catcode12=\other
  \parindent 0pt \parfillskip=0pt plus 1fil minus 1in
  \everypar{\hangindent 1in} \rightskip=0pt plus 2in
  \def\par{\ifvmode\penalty-500\medskip\else\endgraf\fi}
  \listingfont \obeylines \obeyspaces \global\pageno=1
  \input #1 {\eoffont(end of\/ file)}\endgraf\vfill\eject\endgroup}
{\obeyspaces\global\let =\ }
\catcode`\_=\other % allow _ in file names

% A tab (^^I) prints as lowercase gamma.
% Character ^^M could be made visible, with a bit of work;
% at present, it's indistinguishable from newline (^^J).

% You can get up to 103 characters on a line without an overfull box.

% Further notes from Don, January 2017:
% 
% Maybe I'm the only person left who still uses plain TeX in a UTF-8 world.
% 
% But for what it's worth, I'm appending a little file that I prepared today,
% since it turned out to be useful in a project of interest to me.
% 
% Namely, I've got a program that takes an XML encoding of organ-pipe
% settings, used by performers when they change the stops during a
% performance, and translates it into a human-readable form.
% I mean, the output says "when you reach combination nunber 0013,
% the following ranks of pipes are set to play".
% 
% The names of those ranks of pipes often contain accented characters,
% as well as things like the German \ss. In order to use such texts on the Web,
% I have them in UTF-8 code. But to make a verbatim hardcopy listing using
% nice typewriter-style fonts, I wanted a program like "list.tex", which
% I've been using to print text files for more than 25 years.
% 
% Fortunately, the accented characters all turn out to be two-character
% sequences in UTF-8, where the first character is always '303. So I
% can simply make that character active, and it can then change the
% following character appropriately.
% 
% Therefore I added a few lines to "list.tex", resulting in "list-latin.tex".
% And it works! Hence it might be a useful addition to the CTAN archives.
% 
% Yours truly, Don