| 1 |
% address book macros |
| 2 |
% copyright 1993 Victor Eijkhout |
| 3 |
% copyright 2014--2016 Vafa Khalighi |
| 4 |
% |
| 5 |
% |
| 6 |
% This program is free software: you can redistribute it and/or modify |
| 7 |
% it under the terms of the GNU General Public License as published by |
| 8 |
% the Free Software Foundation, either version 3 of the License, or |
| 9 |
% (at your option) any later version. |
| 10 |
% |
| 11 |
% This program is distributed in the hope that it will be useful, |
| 12 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
% GNU General Public License for more details. |
| 15 |
% |
| 16 |
% You should have received a copy of the GNU General Public License |
| 17 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
% |
| 19 |
% |
| 20 |
% These macros are based on the Lollipop macro package, |
| 21 |
% copyright 1992/3 Victor Eijkhout |
| 22 |
% copyright 2014--2016 Vafa Khalighi |
| 23 |
% |
| 24 |
% Format this file twice to get external files right. |
| 25 |
% |
| 26 |
|
| 27 |
% Some general options. |
| 28 |
% Please use another typeface if you have it! |
| 29 |
% |
| 30 |
\Distance:whitebefore=0pt \Distance:whiteafter=0pt |
| 31 |
\AlwaysIndent:no \FlushRight:no |
| 32 |
\TypeFace:ComputerSans \PointSize:8 \Style:roman |
| 33 |
\def\\{,\Spaces:1 } |
| 34 |
|
| 35 |
% The page is four columns, no footers etc |
| 36 |
% |
| 37 |
\DefinePageGrid:ThePage width:page=6.5in height:page=5in |
| 38 |
textband:start text white:10pt text white:10pt |
| 39 |
text white:10pt text textband:stop Stop |
| 40 |
|
| 41 |
% The main macro is the text block \Entity, representing one item |
| 42 |
% in the address book. |
| 43 |
% |
| 44 |
\DefineTextBlock:Entity HasTitle:short |
| 45 |
whitebefore:{6pt plus 6pt minus 3pt} whiteafter:whitebefore |
| 46 |
line:start rule:v={height 7pt width7pt depth0pt} Spaces:2 |
| 47 |
Style:italic title line:stop Stop |
| 48 |
|
| 49 |
% Data in an entity is formatted as a number of headings. |
| 50 |
% We declare all headings to be embedded, ie, they form a paragraph. |
| 51 |
% The 'nomarks' option is to prevent memory overflow. |
| 52 |
% |
| 53 |
\OptionsMacro:embed=embedded:yes nomarks |
| 54 |
whitebefore:0pt whiteafter:0pt Stop |
| 55 |
\DefineHeading:phone HasTitle:short macro:embed |
| 56 |
literal:phone : Spaces:1.5 title , Spaces:2 Stop |
| 57 |
\DefineHeading:fax HasTitle:short macro:embed |
| 58 |
literal:fax : Spaces:1.5 title , Spaces:2 Stop |
| 59 |
\DefineHeading:Address HasTitle:short macro:embed |
| 60 |
title , Spaces:2 Stop |
| 61 |
\DefineHeading:Note HasTitle:short macro:embed |
| 62 |
( title ) Spaces:2 Stop |
| 63 |
|
| 64 |
% Here's an example of non-standard handling of the title: |
| 65 |
% email addresses are set in \tt, and can be broken differently |
| 66 |
% |
| 67 |
\def\breakemail{\hyphenchar\font=`. } |
| 68 |
\DefineHeading:email HasTitle:short macro:embed |
| 69 |
begingroup tt breakemail title endgroup , Spaces:2 Stop |
| 70 |
|
| 71 |
% This is invisible information; maybe later we'll do something |
| 72 |
% with it. |
| 73 |
\DefineHeading:Route HasTitle:short Stop |
| 74 |
|
| 75 |
% Here is the first really cute application. |
| 76 |
% If a person is declared to be \At a certain company, then |
| 77 |
% that fact is written out to an external file, which can be loaded |
| 78 |
% later. |
| 79 |
% |
| 80 |
\DefineExternalFile:companies=ats |
| 81 |
\def\WorksAt{Works at: } |
| 82 |
\DefineHeading:At macro:embed |
| 83 |
HasTitle:short WorksAt title Spaces:2 |
| 84 |
external:companies title unhskip title:Entity unhskip external:stop Stop |
| 85 |
% When the 'companies' file gets loaded the title only gets |
| 86 |
% parsed by the macro \CompNam, and nothing else happens. |
| 87 |
% The title is split into company and person; #1 becomes the name |
| 88 |
% of a list to which #2 is added. |
| 89 |
% |
| 90 |
\def\CompNam#1\unhskip#2\unhskip{ |
| 91 |
\if\UndefinedCS{#1}\NewList:{#1} \fi |
| 92 |
\AppendToList:#1={#2\unhskip, } } |
| 93 |
\DefineExternalItem:At file:companies |
| 94 |
expandafter CompNam title Stop |
| 95 |
% The company lists are later simply loaded; see below. |
| 96 |
|
| 97 |
% Even more complicated: birthdays. |
| 98 |
% All birthdays are written to an external file. |
| 99 |
% |
| 100 |
\DefineExternalFile:births=brt |
| 101 |
\DefineHeading:birthday HasTitle:short macro:embed |
| 102 |
literal:Born : title Spaces:2 |
| 103 |
external:births title unhskip title:Entity unhskip external:stop Stop |
| 104 |
% Later every month becomes something like an entity; |
| 105 |
% here is how we generate a token list for each month. |
| 106 |
% |
| 107 |
\def\month#1{\ifcase#1\or jan\or feb\or mar\or apr\or may\or jun\or |
| 108 |
jul\or aug\or sep\or oct\or nov\or dec\fi} |
| 109 |
\tempcounta=1 \loop\ifnum\tempcounta<13 |
| 110 |
\xp\NewList\xp:\xp{\month\tempcounta} |
| 111 |
\advance\tempcounta1 \repeat |
| 112 |
% Formatting the caboodle means: |
| 113 |
% -- loading the 'births' file |
| 114 |
% -- formatting each month separately by \OneMonth |
| 115 |
% which is essentially a call to the text block \Month |
| 116 |
% |
| 117 |
\def\AllBirths{\LoadExternalFile:births |
| 118 |
\tempcounta=1 \loop\ifnum\tempcounta<13 |
| 119 |
\OneMonth \advance\tempcounta1 \repeat} |
| 120 |
\def\OneMonth{\xp\Month\month\tempcounta\par |
| 121 |
\TheList:{\month\tempcounta} \>} |
| 122 |
% Month is much like \Entity, just a bit different visually. |
| 123 |
% |
| 124 |
\DefineTextBlock:Month |
| 125 |
whitebefore:{6pt plus 6pt minus 3pt} whiteafter:whitebefore |
| 126 |
line:start rule:v={height 7pt width7pt depth0pt} Spaces:2 |
| 127 |
Style:italic title Spaces:2 |
| 128 |
fillup rule:v={height 7pt width7pt depth0pt} line:stop |
| 129 |
Stop |
| 130 |
% When the external file is loaded, every birthday is processed |
| 131 |
% by \BirNam which splits it into #1 year #2 month #3 day and |
| 132 |
% #4 person's name. This is then written to the list for the |
| 133 |
% appropriate month. |
| 134 |
% |
| 135 |
\def\BirNam#1 #2 #3\unhskip #4\unhskip |
| 136 |
{\tempcounta#2\relax |
| 137 |
\AppendToList:{\month\tempcounta}={\JollyFellow #3 #4 (#1)\par} |
| 138 |
} |
| 139 |
\DefineExternalItem:birthday file:births |
| 140 |
expandafter BirNam title Stop |
| 141 |
\DefineHeading:JollyFellow title nomarks Stop |
| 142 |
|
| 143 |
% Phooeew! Now we can get down to business! |
| 144 |
|
| 145 |
\WriteExtern:yes |
| 146 |
\Start |
| 147 |
\LoadExternalFile:companies |
| 148 |
|
| 149 |
\Entity Adam Aardvark |
| 150 |
\Address Page~1, English Language Dictionary |
| 151 |
\> |
| 152 |
|
| 153 |
\Entity Barbara Beeton |
| 154 |
\At Tugbt |
| 155 |
\Note Editor in chief |
| 156 |
\> |
| 157 |
|
| 158 |
\Entity Jane Doe |
| 159 |
\email [email protected] |
| 160 |
\> |
| 161 |
|
| 162 |
\Entity John Doe |
| 163 |
\phone +1 212 555 4141 |
| 164 |
\> |
| 165 |
|
| 166 |
\Entity Victor Eijkhout |
| 167 |
\Address Department of Computer Science, University of Tennessee |
| 168 |
\phone +1 615 974 8298 |
| 169 |
\At Tugbt |
| 170 |
\Note merely associate editor |
| 171 |
\email [email protected] |
| 172 |
\birthday 1959 11 29 |
| 173 |
\> |
| 174 |
|
| 175 |
\Entity Elvis Presley |
| 176 |
\birthday 1938(?) 01 08 |
| 177 |
\> |
| 178 |
|
| 179 |
\Entity Tugboat |
| 180 |
\TheList:Tugbt |
| 181 |
\> |
| 182 |
|
| 183 |
\AllBirths |
| 184 |
|
| 185 |
\Stop |
| 186 |
|