Debian Codegraph @

texmf-dist/tex/plain/zztex/zzdiv.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Module: ZzTeX Division Facilities
4 %
5 % Synopsis: This module contains the macros to support divisions, which
6 % allow a book to be processed in pieces.
7 %
8 % Author: Paul C. Anagnostopoulos
9 % Created: 24 September 1990
10 %
11 % Copyright 1989--2020 by Paul C. Anagnostopoulos
12 % under The MIT License (opensource.org/licenses/MIT)
13 %
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15
16 % Divisions
17 % ---------
18
19
20 \def \zdivext {tex}
21
22 \definetoks{\divisionname} % Name of current division.
23 \definetoks{\zdivreq} % Divisions requested with \setdivisions.
24 \zdivreq = {\all}
25 \definetoks{\zdivset} % Divisions set.
26 \setlist \zdivset = {}
27
28
29 %~ This command is used in the book's root file to specify
30 %~ the list of divisions that should be processed by ZzTeX.
31 %~ All other divisions are not processed. If the command
32 %~ does not appear in the root file, all divisions are processed.
33
34 \def \setdivisions #1{% {division,...}
35 \if \emptyargp{#1}%
36 \warning{nodivs}{The \noexpand\setdivisions command does not specify any divisions}
37 \else
38 \global\zdivreq = {#1}%
39 \fi}
40
41 %~ This command is used in the book's root file to specify the
42 %~ name of a book division file (e.g., |chap01|, |appa|). The order
43 %~ of these commands determines the order of the divisions.
44
45 \def \division #1{% {division}
46 \global\divisionname = {#1}%
47 \edef \znext {\noexpand\inclusionlist\noexpand\zset{#1}{\the\zdivreq}}%
48 \znext
49 \if \zset
50 \remark{Starting division `\the\divisionname'.}%
51 \push{#1}{\zdivset}%
52 \freshpage{\short\floats\any}%
53 \setcolumnnumber{1}%
54 \zxdivinit{#1}{\true}%
55 \zindexdivinit{#1}%
56 \zmndivinit
57 \zpndivinit
58 \zframedivinit
59 \zmrdivinit
60 \zfltdivinit
61 \include{#1.\zdivext}%
62 \endgraf
63 \freshpage{\short\floats\any}%
64 \zortahdivfinal
65 \zindexdivfinal
66 \zxdivfinal{#1}%
67 \else
68 \zxdivinit{#1}{\false}%
69 {\globaldefs = 1 \name{\=zS:#1}}% % Invoke snapshot.
70 \fi
71 \global\divisionname = \expandafter{\jobname}}
72
73 % This macro is invoked at the end of the document.
74
75 \def \zdivmsg {%
76 \edef \znext {\the\zdivreq}%
77 \edef \znextfirst {\expandafter\zdivmsga \znext\zmark}%
78 \if \tokeqlp{\znext}{\zallname}%
79 \remark{The entire book was processed.}%
80 \else\if \tokeqlp{\znextfirst}{\zallbutname}%
81 \relax
82 \else
83 \commalist{\zreqlist}{\the\zdivreq}%
84 \maplist{\zdivmsgb{##1}}{\zreqlist}%
85 \fi\fi}
86
87 \def \zdivmsga #1#2\zmark{#1}
88
89 \def \zdivmsgb #1{%
90 \member{\zexists}{#1}{\zdivset}%
91 \if \notp{\zexists}%
92 \warning{divnotexist}{The requested division `#1' does not exist}%
93 \fi}
94
95 % Division Snapshots
96 % -------- ---------
97
98
99 \setlist \zsnaplist = {} % List of registers to be snapshot.
100
101
102 \def \declaresnapitem #1{% {\name}
103 \append{#1}{\zsnaplist}}
104
105
106 \def \ztakesnap {%
107 \let \zmodesave = \xrefmode
108 \let \xrefmode = \xrefsnapmode
109 \def \znext {}%
110 \maplist{\zsnapone{##1}}{\zsnaplist}%
111 \ztoksa = \expandafter{\znext}%
112 \edef \znext {\noexpand\xref{snap}{\noexpand\folio}{}%
113 {\the\ztoksa}{\the\divisionname}}%
114 \znext
115 \let \xrefmode = \zmodesave}
116
117 \def \zsnapone #1{% {\register}
118 \ztoksa = \expandafter{\znext}%
119 \edef \znext {\the\ztoksa \noexpand#1\the#1}}
120
121
122 % Store division snapshot information in a special name in the tag namespace.
123
124 \def \xrefsnap #1#2#3#4{% {}{}{code}{division}
125 \ifnum \xrefmode=\xrefloadtagmode
126 \if \undefinedp{\=zS:#4}\withname{\gdef}{\=zS:#4}{}\fi
127 \withname\xdef{\=zS:#4}{\name{\=zS:#4}#3}%
128 \fi}