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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
|
%D \module
%D [ file=t-letter,
%D version=2008.10.27,
%D title=\CONTEXT\ User Module,
%D subtitle=Framework for Letters,
%D author=Wolfgang Schuster,
%D date=\currentdate,
%D copyright=Wolfgang Schuster,
%D email=schuster.wolfgang@googlemail.com,
%D license=Public Domain]
%M \loadsetups[cont-en.xml]
%M \loadsetups[t-letter.xml]
%D \subject{Constants and Variables}
\writestatus{loading}{Context User Module / Framework for Letters}
\unprotect
%D I use a few extra constants and variables in my module.
\startinterface all
\setinterfaceconstant {graphic} {graphic}
\setinterfaceconstant {head} {head}
\setinterfaceconstant {foot} {foot}
\setinterfaceconstant {backaddress} {backaddress}
\setinterfaceconstant {topmark} {topmark}
\setinterfaceconstant {botmark} {botmark}
\setinterfaceconstant {cutmark} {cutmark}
\setinterfaceconstant {endmark} {endmark}
\setinterfaceconstant {usermark} {usermark}
\setinterfaceconstant {foldmark} {foldmark}
\setinterfaceconstant {extension} {extension}
\setinterfaceconstant {interface} {interface}
\setinterfaceconstant {backgroundimage} {backgroundimage}
\setinterfaceconstant {whitespace} {whitespace}
\setinterfaceconstant {optimize} {optimize}
\setinterfaceconstant {nexthead} {nexthead}
\setinterfaceconstant {nextfoot} {nextfoot}
\stopinterface
\startinterface all
\setinterfacevariable {letter} {letter}
\setinterfacevariable {secondpage} {secondpage}
\setinterfacevariable {backaddress} {backaddress}
\setinterfacevariable {foot} {foot}
\setinterfacevariable {topmark} {topmark}
\setinterfacevariable {botmark} {botmark}
\setinterfacevariable {cutmark} {cutmark}
\setinterfacevariable {endmark} {endmark}
\setinterfacevariable {reference} {reference}
\setinterfacevariable {location} {location}
\setinterfacevariable {option} {option}
\setinterfacevariable {address} {address}
\setinterfacevariable {foldmark} {foldmark}
\setinterfacevariable {usermark} {usermark}
\setinterfacevariable {opening} {opening}
\setinterfacevariable {closing} {closing}
\setinterfacevariable {layer} {layer}
\setinterfacevariable {letternext} {letternext}
\setinterfacevariable {lettermain} {lettermain}
\setinterfacevariable {special} {special}
\setinterfacevariable {notation} {notation}
\setinterfacevariable {inside} {inside}
\setinterfacevariable {nexthead} {nexthead}
\setinterfacevariable {nextfoot} {nextfoot}
\stopinterface
%D Before we start the real module let us introduce two namespaces
%D for the style and content setup commands.
\def\????ld{@@@@ld} % LetterData
\def\????ls{@@@@ls} % LetterStyle
\def\????lv{@@@@lv} % LetterValue
\startmodule[letter]
\setupmodule
[\c!style=, % default letter style
\c!extension=, % default letter extension
\c!interface=default] % default letter interface
%D \subject{Setup commands}
%D
%D \macros{setupletterstyle}
%D
%D The layout for the first page could be set with the \mono{firstpage}
%D key and the layout for the second and all following pages with the
%D \mono{secondpage} key. You could use any key and value from
%D \tex{setuplayout} to set your own letter layout.
%D
%D \showsetup{setupletterstyle:layout}
%D
%D The header and footer texts for the letter is set with the \mono{header}
%D and \mono{footer} keys, the text itself I written as argument as one of
%D the three keys. The command itself has no option to use different texts
%D for odd and even pages (if you really want this in a letter) but you could
%D solve this with the macro \tex{doifoddpageelse}, I will give you a short
%D example below.
%D
%D \showsetup{setupletterstyle:text}
%D
%D This setups could produce somtimes a unwanted result is you use a doublesided
%D layout, because the values for \mono{lefttext} and \mono{righttext} change on
%D odd and even pages their position, e.g. \mono{righttext} will always go to the
%D outer margin and \mono{lefttext} to the inner margin. Let's you want the
%D pagenumber always on the right side you could use the following code, you could
%D adapt it to your own needs without problems.
%D
%D \starttyping
%D \setupletterstyle
%D [header]
%D [lefttext=\doifoddpageelse\donothing\pagenumber,
%D righttext=\doifoddpageelse\pagenumber\donothing]
%D \stoptyping
\def\setupletterstyle
{\dotripleempty\dosetupletterstyle}
\def\dosetupletterstyle[#1][#2][#3]%
{\ifthirdargument
\dodosetupletterstyle[#1][#2][#3]%
\else\ifsecondargument
\dodosetupletterstyle[#1][#2][]%
\else
\dodosetupletterstyle[\v!option][#1][]%
\fi\fi}
\def\dodosetupletterstyle[#1][#2][#3]%
{\processallactionsinset
[#1]
[ \v!firstpage=>{\definelayout[\v!letter\v!firstpage][#2]},
\v!secondpage=>{\definelayout[\v!letter\v!secondpage][#2]},
\v!header=>{\dosetupletterheader[#2][#3]},
\v!footer=>{\dosetupletterfooter[#2][#3]},
\v!option=>{\dosetupletteroption[\v!option][#2]},
\v!foldmark=>{\dododosetupletterstyle[\v!topmark,\v!botmark,\v!cutmark][#2][#3]},
\s!unknown=>{\dododosetupletterstyle[#1][#2][#3]}]}
%D Set the values for normal options.
\def\dosetupletteroption[#1][#2]%
{\getparameters[\????ls#1][#2]}
%D Setup of the layers and their frames.
\def\dododosetupletterstyle[#1][#2][#3]%
{\def\dodododosetupletterstyle##1%
{\doifelsenothing{#3}
{\ExpandSecondAfter\doifinsetelse{##1}\letter!list!sections
{\dododododosetupletterstyle[##1][\v!option][#2]}
{\ExpandSecondAfter\doifinsetelse{##1}\letter!list!descriptions
{\setupdescriptions[\v!letter##1][#2]}
{\ExpandSecondAfter\doifinsetelse{##1}\letter!list!layers
{\dododododosetupletterstyle[##1][\v!layer,\v!frame,\v!option][#2]}
{\dosetupletteroption[##1][#2]}}}}
{\dododododosetupletterstyle[##1][#2][#3]}}%
\processcommacommand[#1]\dodododosetupletterstyle}
\def\dododododosetupletterstyle[#1][#2][#3]%
{\def\dodododododosetupletterstyle##1%
{\processaction
[##1]
[ \v!layer=>{\dododododosetupletterstyle[#1][\v!layer\v!a,\v!layer\v!b][#3]},
\v!layer\v!a=>{\setuplayer[\v!letter:#1][#3]},
\v!layer\v!b=>{\getparameters[\????ls#1\v!layer][#3]},
\v!frame=>{\getparameters[\????ls#1\v!frame][#3]},
\v!option=>{\getparameters[\????ls#1][#3]},
\s!unknown=>{\getparameters[\????ls#1##1][#3]}]}%
\processcommalist[#2]\dodododododosetupletterstyle}
%D Setup for the header and footer texts.
\newtoks\letter!toks!header
\newtoks\letter!toks!footer
\def\dosetupletterheader[#1][#2]%
{\letter!toks!header\emptytoks
\doifelsenothing{#2}
{\letter!toks!header{\setupheader[\v!text][#1]}}
{\letter!toks!header{\setupheader[#1][#2]}}}
\def\dosetupletterfooter[#1][#2]%
{\letter!toks!footer\emptytoks
\doifelsenothing{#1}
{\letter!toks!footer{\setupfooter[\v!text][#1]}}
{\letter!toks!footer{\setupfooter[#1][#2]}}}
%D \macros
%D {setupletter}
%D
%D The \tex{setupletter} macro could be used from a interface, I define
%D only the macro and nothing else. You could also redefine the macro later
%D because it is not used from the raw interface.
%D
%D The first version of the \tex{setupletter} macro used two arguments
%D for each value:
%D
%D \starttyping
%D \def\setupletter
%D {\dodoubleempty\dosetupletter}
%D
%D \def\dosetupletter[#1][#2]%
%D {\ifsecondargument
%D \dodosetupletter[#1][#2]%
%D \else\iffirstargument
%D \dodosetupletter[\v!option][#1]%
%D \fi\fi}
%D
%D \def\dodosetupletter[#1][#2]%
%D {\def\dododosetupletter##1%
%D {\getparameters[\????ld##1][#2]}%
%D \processcommalist[#1]\dododosetupletter}
%D \stoptyping
%D
%D The next version use only one argument for normal values and use
%D the second argument only for settings on the reference line.
\def\setupletter
{\dodoubleempty\dosetupletter}
\def\dosetupletter[#1][#2]%
{\ifsecondargument
\dodosetupletter[#1][#2]%
\else
\dodosetupletter[#1][]%
\fi}
\def\dodosetupletter[#1][#2]%
{\doifelsenothing{#2}
{\getparameters[\????ld][#1]}
{\def\dododosetupletter##1%
{\getparameters[\????ld##1][#2]}%
\processcommalist[#1]\dododosetupletter}}
\definecomplexorsimple\setlettervalue
\def\complexsetlettervalue[#1]#2%
{\setvalue{\????ld#1}{#2}}
\def\simplesetlettervalue#1#2%
{\setvalue{\????ld#1}{#2}}
%D A few extra macros to test for content of the letter values, don't rely
%D on them at the moment because they could change or I will remove, rename,
%D rewrite etc. them.
%D
%D With the change of the \tex{setupletter} command it was also necessary
%D to change the definition for lettervalue tests.
%D
%D \starttyping
%D \def\doiflettervalue#1#2%
%D {\doiftextelse{\lettervalue{#1}{#2}}
%D \firstofoneargument
%D \gobbleoneargument}
%D
%D \def\doifelselettervalue#1#2%
%D {\doiftextelse{\lettervalue{#1}{#2}}
%D \firstoftwoarguments
%D \secondoftwoarguments}
%D \stoptyping
%\def\doiflettervalue#1%
% {\doiftextelse{\lettervalue{#1}}
% \firstofoneargument
% \gobbleoneargument}
%\def\doifelselettervalue#1%
% {\doiftextelse{\lettervalue{#1}}
% \firstoftwoarguments
% \secondoftwoarguments}
\long\def\doiflettervalue#1%
{\ifcsname\????ld#1\endcsname
\edef\!!stringa{\csname\????ld#1\endcsname}%
\ifx\!!stringa\empty
\@EAEAEA\gobbleoneargument
\else
\@EAEAEA\firstofoneargument
\fi
\else
\@EA\gobbleoneargument
\fi}
\long\def\doifelselettervalue#1%
{\ifcsname\????ld#1\endcsname
\edef\!!stringa{\csname\????ld#1\endcsname}%
\ifx\!!stringa\empty
\@EAEAEA\secondoftwoarguments
\else
\@EAEAEA\firstoftwoarguments
\fi
\else
\@EA\secondoftwoarguments
\fi}
\def\doifletterstylevalue#1#2%
{\ifcsname\????ls#1#2\endcsname
\edef\!!stringa{\csname\????ls#1#2\endcsname}%
\ifx\!!stringa\empty
\@EAEAEA\gobbleoneargument
\else
\@EAEAEA\firstofoneargument
\fi
\else
\@EA\firstofoneargument
\fi}
\def\doifelseletterstylevalue#1#2%
{\ifcsname\????ls#1#2\endcsname
\edef\!!stringa{\csname\????ls#1#2\endcsname}%
\ifx\!!stringa\empty
\@EAEAEA\secondoftwoarguments
\else
\@EAEAEA\firstoftwoarguments
\fi
\else
\@EA\secondoftwoarguments
\fi}
%D \subject{Interface, Style and Extension files}
%D
%D \macros
%D {useletterextension,useletterstyle,useletterinterface}
%D
%D This module provides different types of files beside the main module.
%D
%D Two of them could be used by the user while the third is only used in
%D this file but you're free to use but you should really now what you do.
%D
%D Each of the files has it's own file extension, you have to use if you
%D want to create such a file, this has the advantage to use the same name
%D for a collection of macros.
\def\letter!suffix!style {nls}
\def\letter!suffix!extension{nle}
\def\letter!suffix!interface{nli}
%D Let us begin now to talk about the different types of files.
%D
%D \subsubject{letter interface}
%D
%D The letter interface provides the connection between the user and the
%D inner macros, it is possible to write a letter without a interface but
%D you will loose many of the nice features. The features itself are defined
%D within the interface and try to help the user to write a letter in
%D a simpler than the raw interface.
%D
%D I want to show you the difference between the default interface and the
%D raw backend with a simple example, just a opening, the content and
%D a closing text.
%D
%D The example with the default interface looks like:
%D
%D \starttyping
%D \startletter
%D [opening=Hello User,
%D closing=Good luck with your own interface]
%D I will show you how you could write a letter with my letter module
%D and the difference between the default and the raw interface. The raw
%D interface is should be only used by a high level interface and not the
%D user but you're free to do it.
%D \stopletter
%D \stoptyping
%D
%D The same example with the raw interface looks like:
%D
%D \starttyping
%D \startsetups[letter:opening]
%D Hello User
%D \stopsetups
%D
%D \startsetups[letter:content]
%D I will show you how you could write a letter with my letter module
%D and the difference between the default and the raw interface. The raw
%D interface is should be only used by a high level interface and not the
%D user but you're free to do it.
%D \stopsetups
%D
%D \startsetups[letter:closing]
%D Good luck with your own interface
%D \stopsetups
%D \stoptyping
%D
%D The interface itself is loaded with the \tex{useletterinterface}
%D command but you could also use the optional argument for \tex{usemodule}
%D to load it. The first is only used in this file but it makes sense
%D to use it also in a wrapper file for your own interface.
%D
%D \showsetup{useletterinterface}
\def\useletterinterface
{\dosingleargument\douseletterinterface}
\def\douseletterinterface[#1]%
{\def\dodouseletterinterface##1%
{\readfile{##1.\letter!suffix!interface}\donothing\donothing}%
\processcommacommand[#1]\dodouseletterinterface}
%D \subsubject{letter extension}
%D
%D The second filetype this module supports are letterextensions, you
%D could use it to save macros and other values you want to use in many
%D without the need to put it always in the real letter.
%D
%D A few reasons for a letterextension file are:
%D
%D \startitemize[packed,intro]
%D \item The letter head from your company,
%D \item your own macro for the reference line,
%D \item labels you need in different files (see \mono{label.nle}),
%D \item \unknown
%D \stopitemize
%D
%D The syntax to load a letterextension file is the same as for a interface
%D and you could also argument for \tex{usemodule}.
%D
%D \showsetup{useletterextension}
\def\useletterextension
{\dosingleargument\douseletterextension}
\def\douseletterextension[#1]%
{\def\dodouseletterextension##1%
{\readfile{##1.\letter!suffix!extension}\donothing\donothing}%
\processcommacommand[#1]\dodouseletterextension}
%D \subsubject{letter styles}
%D
%D After I mentioned above how to load a interface and extension
%D I will now come to the most important extension for the module.
%D
%D Letter styles are used to change the layout of the letter,
%D set the values for layers and enable and disable common options.
%D Although it is possible to do all these things in the letter itself
%D it is better to save often used settings in a extra file you could
%D load on demand and share between your letters.
%D
%D You could load a style file in the same way as the other to files,
%D the first is \tex{useletterstyle} and the second the optional argument
%D for \tex{usemodule}.
%D
%D \showsetup{useletterstyle}
\def\useletterstyle
{\dosingleargument\douseletterstyle}
\def\douseletterstyle[#1]%
{\def\dodouseletterstyle##1%
{\readfile{##1.\letter!suffix!style}\donothing\donothing}%
\processcommacommand[#1]\dodouseletterstyle}
%D \macros
%D {letterstylevalue,lettervalue}
%D
%D The two commands \tex{letterstylevalue} and \tex{lettervalue} could
%D be used to access the values for the keys used in the letterstyle
%D settings and the letter values for information.
%D The rest of module contains only internal macros and other settings,
%D you don't need them as a normal user but you look at the default.
\def\letterstylevalue#1#2%
{\csname\????ls#1#2\endcsname}
%D The old definition of \tex{lettervalue} required two arguments.
%D
%D \starttyping
%D \def\lettervalue#1#2%
%D {\csname\????ld#1#2\endcsname}
%D \stoptyping
%D
%D The new definition needs only one arguments because \tex{setupletter}
%D needs only one argument for the values in the new version.
\def\lettervalue#1%
{\csname\????ld#1\endcsname}
\let\letter!list!layers\empty
\def\letter!list!marking
{\v!topmark,\v!botmark,\v!cutmark,\v!endmark,\v!usermark}
\def\dodefineletterlayer[#1]%
{\ExpandSecondAfter\doifelse{#1}\v!foldmark
{\def\dodododefineletterlayer##1{\dododefineletterlayer[##1]}%
\processcommacommand[\letter!list!marking]\dodododefineletterlayer}
{\dododefineletterlayer[#1]}}
\def\dododefineletterlayer[#1]%
{\setvalue{\????ls\v!option#1}{\v!yes}%
\doifnotinset{#1}\letter!list!layers
{\appendtocommalist{#1}\letter!list!layers}%
\presetlocalframed[\????ls#1\v!frame]%
\definelayer
[\v!letter:#1]
[\c!width=\paperwidth,
\c!height=\paperheight]%
\setupletterstyle
[#1][\v!option]
[\c!symbol=,
\c!alternative=\v!a,
\c!separator=\crlf,
\c!offset=\zeropoint,
\c!leftmargin=\zeropoint,
\c!rightmargin=\zeropoint]%
\setupletterstyle
[#1][\v!frame]
[\c!frame=\v!off,
\c!align=\v!right,
\c!offset=\zeropoint,
\c!strut=\v!yes]%
\setupletterstyle
[#1][\v!layer]
[\c!state=\v!start,
\c!offset=\zeropoint,
\c!preset=\v!left\v!top]}
\def\dosetletterlayer[#1]%
{\doifinsetelse{#1}{\v!topmark,\v!botmark,\v!cutmark,\v!endmark,\v!usermark}
{\doifelseletterstylevalue{#1}\c!symbol
{\dodosetletterlayer[#1][\setups{letter:#1}]}
{\dodosetletterlayer[#1][\letterstylevalue{#1}\c!symbol]}}
{\dodosetletterlayer[#1][\setups{letter:#1}]}}
\def\dodosetletterlayer[#1][#2]%
{\setlayer[\v!letter:#1]
{\localframed[\????ls#1\v!frame]
{\doadaptleftskip {\letterstylevalue{#1}\c!leftmargin}%
\doadaptrightskip{\letterstylevalue{#1}\c!rightmargin}%
\doattributes{\????ls#1}\c!style\c!color{#2}}}}
\let\letter!list!sections\empty
\def\dodefinelettersection[#1]%
{\setvalue{\????ls\v!option#1}{\v!yes}%
\doifnotinset{#1}\letter!list!sections
{\appendtocommalist{#1}\letter!list!sections}%
\setupletterstyle
[#1]
[\v!option]
[\c!before=,
\c!after=,
\c!align=,
\c!leftmargin=\zeropoint,
\c!rightmargin=\zeropoint,
\c!alternative=\v!a,
\c!separator=\crlf,
\c!style=,
\c!color=]}
\def\dosetlettersection[#1]%
{\begingroup
\edef\@@lettersection{#1}%
\doifelseletterstylevalue\@@lettersection\c!before
{\letterstylevalue\@@lettersection\c!before}
\endgraf
\doadaptleftskip {\letterstylevalue\@@lettersection\c!leftmargin}%
\doadaptrightskip{\letterstylevalue\@@lettersection\c!rightmargin}%
\doifletterstylevalue\@@lettersection\c!align
{\setupalign[\letterstylevalue\@@lettersection\c!align]}%
\dostartattributes{\????ls#1}\c!style\c!color\empty
\setups[letter:#1]%
\dostopattributes
\doifletterstylevalue\@@lettersection\c!after
{\endgraf\letterstylevalue\@@lettersection\c!after}
\endgraf
\endgroup}
\let\letter!list!descriptions\empty
\def\dodefineletterdescription[#1]%
{\setvalue{\????ls\v!option#1}{\v!yes}%
\doifnotinset{#1}\letter!list!descriptions
{\appendtocommalist{#1}\letter!list!descriptions}%
\definedescription
[\v!letter#1]
[\c!location=\v!top,
\c!inbetween=\nowhitespace]}
\def\dosetletterdescription[#1]%
{\doiftext{\setups[letter:#1]}
{\csname\e!start\v!letter#1\endcsname{\labeltext{\v!letter:#1}}
\setups[letter:#1]%
\csname\e!stop \v!letter#1\endcsname}}
\def\doflushletterdescription
{\def\dodoflushletterdescription##1%
{\doif{\letterstylevalue\v!option{##1}}\v!yes{\dosetletterdescription[##1]}}%
\processcommacommand[\letter!list!descriptions]\dodoflushletterdescription}
%D \subject{Placement of the content}
%D
%D Enable the layouts for the first and second page.
\startsetups[letter:layout]
\setuplayout[\v!letter\v!firstpage]
\appendtoks\setuplayout[\v!letter\v!secondpage]\to\everyaftershipout
\stopsetups
%D Header for the first page, you could use it to place the logo from your
%D company or your own address and name.
\dodefineletterlayer[\v!head]
\startsetups[letter:place:head]
\dosetletterlayer[\v!head]
\stopsetups
%D Address
\dodefineletterlayer[\v!address]
\startsetups[letter:place:address]
\dosetletterlayer[\v!address]
\stopsetups
%D Could be used to place a backaddress above the normal address.
\dodefineletterlayer[\v!backaddress]
\startsetups[letter:place:backaddress]
\dosetletterlayer[\v!backaddress]
\stopsetups
%D Reference line
\dodefineletterlayer[\v!reference]
\startsetups[letter:place:reference]
\dosetletterlayer[\v!reference]
\stopsetups
%D Location field
\dodefineletterlayer[\v!location]
\startsetups[letter:place:location]
\dosetletterlayer[\v!location]
\stopsetups
%D Footer block, you could use it to place information about your company
%D but take care set \mono{repeat=yes} if you want to place it on every page,
%D you should disable the footer for the second and following pages inb this
%D case.
\dodefineletterlayer[\v!foot]
\startsetups[letter:place:foot]
\dosetletterlayer[\v!foot]
\stopsetups
%D Two additional layers from Hans Hagen's own letter module, it provide
%D for users who used \mono{m-letter.tex} and want to switch to my module.
%D
%D I need they also for my pragma letter interface.
\dodefineletterlayer[\v!lettermain]
\startsetups[letter:place:lettermain]
\dosetletterlayer[\v!lettermain]
\stopsetups
\dodefineletterlayer[\v!letternext]
\startsetups[letter:place:letternext]
\dosetletterlayer[\v!letternext]
\stopsetups
%D Layer to set head and foot blocks at the second and all following pages.
\dodefineletterlayer[\v!nexthead]
\startsetups[letter:place:nexthead]
\dosetletterlayer[\v!nexthead]
\stopsetups
\dodefineletterlayer[\v!nextfoot]
\startsetups[letter:place:nextfoot]
\dosetletterlayer[\v!nextfoot]
\stopsetups
%D Letterhead, american only
\dodefinelettersection[\v!letter\v!head]
\startsetups[letter:place:\v!letter\v!head]
\dosetlettersection[\v!letter\v!head]
\stopsetups
%D Date Line, american only
\dodefinelettersection[\v!date\v!line]
\startsetups[letter:place:\v!date\v!line]
\dosetlettersection[\v!date\v!line]
\stopsetups
%D Reference Line, american only
\dodefinelettersection[\v!reference\v!line]
\startsetups[letter:place:\v!reference\v!line]
\dosetlettersection[\v!reference\v!line]
\stopsetups
%D Special Notation, american only
\dodefinelettersection[\v!special\v!notation]
\startsetups[letter:place:\v!special\v!notation]
\dosetlettersection[\v!special\v!notation]
\stopsetups
%D Inside Address, american only
\dodefinelettersection[\v!inside\v!address]
\startsetups[letter:place:\v!inside\v!address]
\dosetlettersection[\v!inside\v!address]
\stopsetups
%D Title
\dodefinelettersection[\v!title]
\startsetups[letter:place:\v!title]
\dosetlettersection[\v!title]
\stopsetups
%D Subject
\dodefinelettersection[\v!subject]
\startsetups[letter:place:\v!subject]
\dosetlettersection[\v!subject]
\stopsetups
%D Opening
\dodefinelettersection[\v!opening]
\startsetups[letter:place:\v!opening]
\dosetlettersection[\v!opening]
\stopsetups
%D Letter content
\dodefinelettersection[\v!content]
\startsetups[letter:place:\v!content]
\begingroup
\doifletterstylevalue\v!option\c!indenting{\setupindenting[\@@@@lsoptionindenting]}
\dosetlettersection[\v!content]
\endgroup
\stopsetups
%D Closing
\dodefinelettersection[\v!closing]
\startsetups[letter:place:\v!closing]
\dosetlettersection[\v!closing]
\stopsetups
%D Apendices
\dodefinelettersection[\v!appendices]
\startsetups[letter:place:\v!appendices]
\dosetlettersection[\v!appendices]
\stopsetups
%D Fold- and cutmarks, you enable and disable all of them independant
%D from any other or disable all marks with just one command.
\dodefineletterlayer[\v!foldmark]
\startsetups[letter:place:foldmark]
% Upper foldmark
\startlocalsetups[letter:place:topmark]
\dosetletterlayer[\v!topmark]
\stoplocalsetups
% Lower foldmark
\startlocalsetups[letter:place:botmark]
\dosetletterlayer[\v!botmark]
\stoplocalsetups
% Cutmark
\startlocalsetups[letter:place:cutmark]
\dosetletterlayer[\v!cutmark]
\stoplocalsetups
% Endmark, a relict from the typewriter area
\startlocalsetups[letter:place:endmark]
\dosetletterlayer[\v!endmark]
\stoplocalsetups
% Free mark, you could use it to place your own symbols
\startlocalsetups[letter:place:usermark]
\dosetletterlayer[\v!usermark]
\stoplocalsetups
\doif\@@@@lsoptiontopmark \v!yes{\setups[letter:place:topmark]}
\doif\@@@@lsoptionbotmark \v!yes{\setups[letter:place:botmark]}
\doif\@@@@lsoptioncutmark \v!yes{\setups[letter:place:cutmark]}
\doif\@@@@lsoptionendmark \v!yes{\setups[letter:place:endmark]}
\doif\@@@@lsoptionusermark\v!yes{\setups[letter:place:usermark]}
\stopsetups
%D Background graphic:
\defineoverlay
[\v!letter:\c!backgroundimage]
[\doifsomething\@@@@lsoptionbackgroundimage
{\overlayfigure{\@@@@lsoptionbackgroundimage}}]
\defineoverlay
[\v!letter:\c!background]
[\@@@@lsoptionbackground]
\def\letter!list!backgrounds
{\v!letter:\c!backgroundimage,\v!letter:\c!background,%
\v!letter:\v!letternext,\v!letter:\v!lettermain,\v!letter:\v!head,%
\v!letter:\v!foot,\v!letter:\v!backaddress,\v!letter:\v!address,%
\v!letter:\v!reference,\v!letter:\v!location,\v!letter:\v!nexthead,%
\v!letter:\v!nextfoot,\v!letter:\v!topmark,\v!letter:\v!botmark,
\v!letter:\v!cutmark,\v!letter:\v!endmark,\v!letter:\v!usermark}
%D Settings at the begin of every letter.
\startsetups[letter:initialize]
\@@@@lsoptionbefore
\setupsubpagenumber
[\c!number=\@@@@lsoptionpagenumber,
\c!way=\v!by\v!text,
\c!state=\@@@@lsoptionstate]
\resetsubpagenumber
\begingroup
\page
\setuppagenumbering
[\c!alternative=\@@@@lsoptionalternative,
\c!location=] % use the header and footer option instead
\the\letter!toks!header
\the\letter!toks!footer
\setupbackgrounds
[\v!paper]
[\c!background=\v!color,
\c!backgroundcolor=\@@@@lsoptionbackgroundcolor]
\setupbackgrounds
[\v!page]
[\c!background=\letter!list!backgrounds,
\c!backgroundcolor=\@@@@lsoptionbackgroundcolor]
\doifletterstylevalue\v!option\c!bodyfont {\switchtobodyfont[\@@@@lsoptionbodyfont]}
\doifletterstylevalue\v!option\c!whitespace{\setupwhitespace[\@@@@lsoptionwhitespace]}
\stopsetups
%D Settings at the end of every letter.
\startsetups[letter:finish]
\page
\setuplayout[\v!reset]
\endgroup
\resetsubpagenumber
\@@@@lsoptionafter
\stopsetups
%D Place the letter.
\startsetups[letter:place]
\setups[letter:initialize] % Settings at the begin
\setups[letter:optimize] % Interface dependend
\setups[letter:layout] % Page layout
\setups[letter:reset] % Reset layers
\setups[letter:layer] % Place layers
\setups[letter:sequence] % Place content
\setups[letter:finish] % Settings at the end
\stopsetups
%D Reset the layer content.
\def\letter!list!resetlayers
{\v!topmark,\v!botmark,\v!cutmark,\v!endmark,\v!usermark,\v!letternext,\v!lettermain}
\def\dodoresetletterlayer#1%
{\resetlayer[#1]}
\startsetups[letter:reset]
\processcommacommand[\letter!list!resetlayers]\dodoresetletterlayer
\setuplayer[\v!letternext][\c!state=\v!continue]
\stopsetups
\startsetups[letter:layer]
\doif\@@@@lsoptionmarking \v!yes{\setups[letter:place:foldmark]}
\doif\@@@@lsoptionhead \v!yes{\setups[letter:place:head]}
\doif\@@@@lsoptionbackaddress\v!yes{\setups[letter:place:backaddress]}
\doif\@@@@lsoptionaddress \v!yes{\setups[letter:place:address]}
\doif\@@@@lsoptionreference \v!yes{\setups[letter:place:reference]}
\doif\@@@@lsoptionlocation \v!yes{\setups[letter:place:location]}
\doif\@@@@lsoptionfoot \v!yes{\setups[letter:place:foot]}
\doif\@@@@lsoptionlettermain \v!yes{\setups[letter:place:lettermain]}
\doif\@@@@lsoptionletternext \v!yes{\setups[letter:place:letternext]}
\doif\@@@@lsoptionnexthead \v!yes{\setups[letter:place:nexthead]}
\doif\@@@@lsoptionnextfoot \v!yes{\setups[letter:place:nextfoot]}
\stopsetups
%D Place the letter content.
\let\letter!order!sections\letter!list!sections
\def\doflushlettersection#1%
{\doif{\letterstylevalue\v!option{#1}}\v!yes{\setups[letter:place:#1]}}
\startsetups[letter:sequence]
\executeifdefined{\v!letter\s!start\c!optimize\@@@@lsoptionoptimize}\donothing
\processcommacommand[\letter!order!sections]\doflushlettersection
\executeifdefined{\v!letter\s!stop \c!optimize\@@@@lsoptionoptimize}\donothing
\stopsetups
%D \subject{Default values}
%D
%D Default settings for the option values of the letter.
\setupletterstyle
[\v!option]
[\c!marking=\v!yes,
\c!endmark=\v!no,
\c!usermark=\v!no,
\c!backaddress=\v!no,
\c!indenting=,
\c!whitespace=,
\c!background=,
\c!backgroundcolor=\v!white,
\c!backgroundimage=,
\c!before=,
\c!after=,
\c!header=\v!reset,
\c!footer=\v!reset,
\c!pagenumber=1,
\c!bodyfont=,
\c!optimize=\v!no,
\c!alternative=\v!singlesided,
\c!state=\v!stop]
% interface always before styles and extension because users should
% start with a clean interface without predefined and unwanted values.
\useletterinterface[\currentmoduleparameter\c!interface]
\useletterstyle [\currentmoduleparameter\c!style ]
\useletterextension[\currentmoduleparameter\c!extension]
%D The special style \mono{user} is not included in the archive and has
%D to be written by the user itself, it can be used to set default values
%D for personal letters and to load additional extensions and styles.
\useletterstyle[user] % don't rely on the name, it can change for the moment
\stopmodule
\protect \endinput
|