summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/letter/interface/default.nli
blob: 5018a29e99defa94f1dff04d54e9ea394318632f (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
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
%D \module
%D   [       file=default,
%D        version=2008.10.27,
%D          title=\CONTEXT\ Letter Interface,
%D       subtitle=Default Interface,
%D         author=Wolfgang Schuster,
%D           date=\currentdate,
%D      copyright=Wolfgang Schuster,
%D          email=schuster.wolfgang@googlemail.com,
%D        license=Public Domain]

%M \loadsetups[letter.xml]

%D \subject{Constants and Variables}

\unprotect

%D I define a few additional constants and variables, I will move them
%D to the base some time.

\startinterface all
  \setinterfaceconstant {opening}      {opening}
  \setinterfaceconstant {content}      {content}
  \setinterfaceconstant {closing}      {closing}
  \setinterfaceconstant {signature}    {signature}
  \setinterfaceconstant {dispatch}     {dispatch}
  \setinterfaceconstant {appendices}   {appendices}
  \setinterfaceconstant {fromaddress}  {fromaddress}
  \setinterfaceconstant {frombank}     {frombank}
  \setinterfaceconstant {frommail}     {frommail}
  \setinterfaceconstant {fromfax}      {fromfax}
  \setinterfaceconstant {fromlogo}     {fromlogo}
  \setinterfaceconstant {fromname}     {fromname}
  \setinterfaceconstant {fromphone}    {fromphone}
  \setinterfaceconstant {fromurl}      {fromurl}
  \setinterfaceconstant {toname}       {toname}
  \setinterfaceconstant {toaddress}    {toaddress}
  \setinterfaceconstant {enclosure}    {enclosure}
  \setinterfaceconstant {copy}         {copy}
  \setinterfaceconstant {postscript}   {postscript}
  \setinterfaceconstant {attention}    {attention}
  \setinterfaceconstant {distribution} {distribution}
  \setinterfaceconstant {salutation}   {salutation}
  \setinterfaceconstant {addressee}    {addressee}
\stopinterface

\startinterface all
  \setinterfacevariable {e}          {e}
  \setinterfacevariable {data}       {data}
  \setinterfacevariable {sender}     {sender}
  \setinterfacevariable {dispatch}   {dispatch}
  \setinterfacevariable {enclosure}  {enclosure}
  \setinterfacevariable {copy}       {copy}
  \setinterfacevariable {nobreak}    {nobreak}
  \setinterfacevariable {endgraf}    {endgraf}
  \setinterfacevariable {memo}       {memo}
  \setinterfacevariable {addressee}  {addressee}
  \setinterfacevariable {french}     {french}
  \setinterfacevariable {simplified} {simplified}
  \setinterfacevariable {fullblock}  {fullblock}
  \setinterfacevariable {hanging}    {hanging}
  \setinterfacevariable {modified}   {modified}
\stopinterface

%D \subject{Reference line}
%D 
%D Dimen value to save the height of the reference line.

\newdimen\letter!height!reference

%D We come now to the new macros defined in this file, they are meant to place the
%D information about date, phone number and more information. You could select on of
%D the alternatives with \type{\setupletter[alternative=...]}.
%D 
%D I define here only what I need myself but you're free to define your own
%D alternatives but try to avoid to use the same names as I do. You could also send
%D me your alternatives and I will include them.
%D 
%D This is the first alternative a, it use the values from the style file without any
%D change, this is the normal layout for a DIN letter.

\long\def\doformatreferencelista#1%
  {\def\\{\egroup\hbox\bgroup}%
   \setupinterlinespace\hbox\bgroup#1\egroup\par}

\long\def\formatreferencelista#1%
  {\bgroup
   \convertargument#1\to\ascii
   \vbox
     {\vbox{\doattributes{\????ld\ascii}\c!titlestyle\c!titlecolor
        {\doformatreferencelista{\labeltext{\v!letter:\ascii}}}}
      \vtop{\doattributes{\????ld\ascii}\c!textstyle\c!textcolor
        {\doformatreferencelista{\lettervalue\ascii}}}}%
   \egroup
   \hfill}

\setvalue{\v!letter:\v!reference:\v!a}%
  {\setbox\scratchbox\hbox\!!to\hsize
     {\getcommacommandsize[\@@@@ldlist]% \@@@@ldreference?
      \ifnum\commalistsize<\plustwo\hfill\fi
      \processcommacommand[\@@@@ldlist]\formatreferencelista\unskip}%
   \global\letter!height!reference\dimexpr\ht\scratchbox+\dp\scratchbox\relax
   \box\scratchbox}

\startsetups[letter:reference:\v!a]

\setupletterstyle
  [\v!reference]
  [\c!hoffset=\backspace,
   \c!voffset=\dimexpr\letterstylevalue\v!address\c!voffset+\letterstylevalue\v!address\c!height+\plusthree\c!mm\relax,
   \c!width=\textwidth]

\setupletterstyle
  [\v!firstpage]
  [\c!topspace=\dimexpr\letterstylevalue\v!reference\c!voffset+\letter!height!reference+\plustwo\lineheight\relax]

\stopsetups

%D This is the alternative b, you could use it if you want to place the information
%D in a infoblock not just a simple line, it is also better suited if you want to
%D place more infomration.

\long\def\formatreferencelistb#1%
  {\bgroup
   \doifelse{#1}\v!line
     {\blank[\v!line]}
     {\hbox
        {\doattributes{\????ld#1}\c!titlestyle\c!titlecolor
           {\labeltext{\v!letter:#1}\lettervalue{#1\c!separator}}%
         \doattributes{\????ld#1}\c!textstyle\c!textcolor
           {\lettervalue{#1}}}}%
   \egroup}

\setvalue{\v!letter:\v!reference:\v!b}%
  {\vtop % why not \vbox?
     {\processcommacommand[\@@@@ldlist]\formatreferencelistb}}

\startsetups[letter:reference:\v!b]

\setupletterstyle
  [\v!reference]
  [\v!layer]
  [\c!hoffset=125.7mm,
   \c!voffset=\letterstylevalue\v!address\c!voffset]

\setupletterstyle
  [\v!reference]
  [\v!frame]
  [\c!width=\dimexpr\paperwidth-\letterstylevalue{\v!reference\v!layer}\c!hoffset-\cutspace\relax,
   \c!height=\v!fit]

\stopsetups

%D The third alternative c could used, if you want to place just a single line
%D with text and nothing more, like your place and the date. You need only the
%D following two lines in your document.
%D 
%D \starttyping
%D \setupletter[alternative=c,list=reference]
%D \setupletter[reference=\rightaligned{Place, \currentdate}]
%D \stoptyping

\long\def\formatreferencelistc#1%
  {\bgroup
   \convertargument#1\to\ascii
   \doattributes{\????ld\ascii}\c!textstyle\c!textcolor
     {\lettervalue\ascii}%
   \egroup}

\setvalue{\v!letter:\v!reference:\v!c}%
  {\hbox\!!to\hsize
     {\processcommacommand[\@@@@ldlist]\formatreferencelistc}}

\startsetups[letter:reference:\v!c]

\setups[letter:reference:\v!a]

\stopsetups

%D Alternative d, text is placed in a block like alternative bit the text
%D is put in a table.

\long\def\doformatreferencelistd#1%
  {\doifelse{#1}\v!line
     {\NC\NC\NC\NR} % ugly but working
     {\NC \doattributes{\????ld#1}\c!titlestyle\c!titlecolor
            {\labeltext{\v!letter:#1}\lettervalue{#1\c!separator}}%
      \NC\doattributes{\????ld#1}\c!textstyle\c!textcolor{\lettervalue{#1}}
      \NC\NR}}

\def\formatreferencelistd#1%
  {\appendtoks\doformatreferencelistd{#1}\to\scratchtoks}

\setvalue{\v!letter:\v!reference:\v!d}%
  {\vtop % why not \vbox?
     {\scratchtoks\emptytoks
      \processcommacommand[\@@@@ldlist]\formatreferencelistd
      \setuptabulate[\c!before=,\c!after=]%
      \starttabulate[|l|l|]
      \the\scratchtoks
      \stoptabulate}}

\startsetups[letter:reference:\v!d]

\setupletterstyle
  [\v!reference]
  [\v!layer]
  [\c!hoffset=125.7mm,
   \c!voffset=\letterstylevalue\v!address\c!voffset]

\setupletterstyle
  [\v!reference]
  [\v!frame]
  [\c!width=\dimexpr\paperwidth-\letterstylevalue{\v!reference\v!layer}\c!hoffset-\cutspace\relax,
   \c!height=\v!fit]

\stopsetups

%D Alternative e, nearly the same as a but you could control the width of the
%D fields with the width key for \tex{setupletter}.

\long\def\doformatreferenceliste#1%
  {\def\\{\egroup\hbox\bgroup}%
   \setupinterlinespace\hbox\bgroup#1\egroup\par}

\long\def\formatreferenceliste#1%
  {\bgroup
   \convertargument#1\to\ascii
   \doifelselettervalue{\ascii\c!width}
     {\hbox\!!to\lettervalue{\ascii\c!width}}
     {\hbox}%
     {\vbox
        {\vbox{\doattributes{\????ld\ascii}\c!titlestyle\c!titlecolor
           {\doformatreferenceliste{\labeltext{\v!letter:\ascii}}}}
         \vtop{\doattributes{\????ld\ascii}\c!textstyle\c!textcolor
           {\doformatreferenceliste{\lettervalue\ascii}}}}}%
   \egroup}

\setvalue{\v!letter:\v!reference:\v!e}%
  {\hbox\!!to\hsize
     {\processcommacommand[\@@@@ldlist]\formatreferenceliste\hss}}

\startsetups[letter:reference:\v!e]

\setups[letter:reference:\v!a]

\stopsetups

%D The alternative \mono{none} could be used to disable the reference.
%D 
%D The advantage is to change only the list alternative to nothing, another
%D method to get this result to use alternative c and remove all values from
%D the reference but the none key is better.

\resetvalue{\v!letter:\v!reference:\v!none}

\startsetups[letter:reference:\v!none]

  % Use the topspace value from the style

\stopsetups

%D \subject{Setup commands}
%D 
%D \macros
%D   {setupletter,setlettervalue}
%D 
%D The values for the letter field is set eitheir either with \tex{setupletter}
%D or with \tex{setlettervalue}, the first commands allows you to input the data
%D in a key-val list while the second is only able to accept a single value.
%D 
%D The first definition for \tex{setupletter} was defined in \filename{t-letter.tex}
%D and used till \date[d=20,m=4,y=2008] but I decided to replace it by a simpler
%D method to avoid a few lines of code in my letter and the letter versions from
%D \date[d=21,m=4,y=2008] will use the new user interface. The old definition from
%D \filename{t-letter.tex} is now oveloaded in will eventually disappear.
%D 
%D The second command to set \tex{setlettervalue} was developed as a alternative
%D method to set values for the letter, I implemnted the command at the same time
%D as I changed the user interface.
%D 
%D Untill the old definition for \tex{setupletter} remains in \filename{t-letter.tex}
%D I have to redefine also \tex{lettervalue}, \tex{doiflettervalue} and
%D \tex{doifelselettervalue} because the old and new definitions differe in the
%D number of arguments but the new definition will move to the core file as soon
%D as I replace \tex{setupletter} in the core.

%D \starttyping
%D \def\setupletter
%D   {\dodoubleempty\dosetupletter}
%D 
%D \def\dosetupletter[#1][#2]%
%D   {\ifsecondargument
%D      \dodosetupletter[#1][#2]%
%D    \else
%D      \dodosetupletter[#1][]%
%D    \fi}
%D 
%D \def\dodosetupletter[#1][#2]%
%D   {\doifelsenothing{#2}
%D      {\getparameters[\????ld][#1]}
%D      {\def\dododosetupletter##1%
%D         {\getparameters[\????ld##1][#2]}%
%D       \processcommalist[#1]\dododosetupletter}}
%D 
%D \def\lettervalue#1%
%D   {\csname\????ld#1\endcsname}
%D 
%D \def\doiflettervalue#1%
%D   {\doiftextelse{\lettervalue{#1}}
%D      \firstofoneargument
%D      \gobbleoneargument}
%D 
%D \def\doifelselettervalue#1%
%D   {\doiftextelse{\lettervalue{#1}}
%D      \firstoftwoarguments
%D      \secondoftwoarguments}
%D 
%D \definecomplexorsimple\setlettervalue
%D 
%D \def\complexsetlettervalue[#1]#2%
%D   {\setvalue{\????ld#1}{#2}}
%D 
%D \def\simplesetlettervalue#1#2%
%D   {\setvalue{\????ld#1}{#2}}
%D \stoptyping

%D \subject{Letter environment}
%D 
%D \macros
%D   {startletter}
%D 
%D The main macro in this file, it is used to write the letter content.
%D It is also possible to set the address and a few other values like
%D the opening and closing with the optional argument, the values are
%D local in this case and not global like the values you could set with
%D \tex{setupletter}.
%D 
%D \showsetup{startletter}

\def\startletter
  {\bgroup\dodoubleempty\dostartletter}

\def\dostartletter[#1][#2]%
  {\ifsecondargument
     \setupletter[#1]%
     \doifundefinedelse{\????ld\????ld#2}
       {\setvalue{\????ld\c!toaddress}{#2}}
       {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#2}}}%
   \else\iffirstargument
     \doifassignmentelse{#1}
       {\setupletter[#1]}
       {\doifundefinedelse{\????ld\????ld#1}
          {\setvalue{\????ld\c!toaddress}{#1}}
          {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#1}}}}%
   \fi\fi
   \def\stopletter
     {\setups[letter:place]\egroup
      \setupsubpagenumber[\c!state=\@@@@lsoptionstate]}%
   \dostartbuffer[lettercontent][startletter][stopletter]}

%D Patched version of the \tex{flushbufferline} macro for \MKII,
%D the changes are definition as long and removing of \tex{string}
%D in the argument of the last write block.

\long\def\flushbufferline#1%
  {\iftmpblockstarted
     \ifsegmentatebuffer
       \ifemptybufferline
         \immediate\write\tmpblocks{\string\stopbufferparagraph }%
         \immediate\write\tmpblocks{\string\startbufferparagraph}%
       \else
         \immediate\write\tmpblocks{#1}%
       \fi
     \else
       \immediate\write\tmpblocks{#1}%
     \fi
   \else
     \doifsomething{#1}
       {\tmpblockstartedtrue
        \immediate\write\tmpblocks{#1}}%
   \fi}

%D \macros
%D   {startlettercontent}
%D 
%D The letter content is saved in the value content, although I could
%D place it in the corresponding I prefer this solution because you could
%D now use it in your own macros and redefine the content setups to your
%D own wishes.

\setupletter
  [\c!content={\getbuffer[lettercontent]}]

\def\startlettercontent
  {\dostartbuffer[lettercontent][startlettercontent][stoplettercontent]}

%D After the definition of all macros I could now put the content
%D in the corresponding setups, this is only important if you want
%D to define your own layout for header, address etc.

\setvalue{\v!letter:\v!head:\v!a}%
  {\lettervalue\c!fromname
   \doiflettervalue\c!fromname\\
   \lettervalue\c!fromaddress}

\startsetups[letter:head]
\def\\{\letterstylevalue\v!head\c!separator}%
\executeifdefined{\v!letter:\v!head:\@@@@lsheadalternative}{\getvalue{\v!letter:\v!head:\v!a}}%
\stopsetups

\startsetups[letter:foot]
\executeifdefined{\v!letter:\v!foot:\@@@@lsfootalternative}\donothing
\stopsetups

\startsetups[letter:nexthead]
\executeifdefined{\v!letter:\v!nexthead:\@@@@lsnextheadalternative}\donothing
\stopsetups

\startsetups[letter:nextfoot]
\executeifdefined{\v!letter:\v!nextfoot:\@@@@lsnextfootalternative}\donothing
\stopsetups

\setvalue{\v!letter:\v!header:\v!fullblock}%
  {\hbox\!!to\hsize
     {\rlap{\lettervalue\c!toname}%
      \midaligned{\pagenumber}%
      \llap{\framed[\c!frame=\v!off,\c!location=\v!top,\c!align=\v!left]
        {\lettervalue\c!date   \\
         \lettervalue\c!reference}}}}

\setvalue{\v!letter:\v!header:\v!hanging}%
  {\hbox\!!to\hsize
     {\framed[\c!frame=\v!off,\c!location=\v!top,\c!align=v!right]
       {\lettervalue\c!toname    \\
        \lettervalue\c!date      \\
        \lettervalue\c!reference \\
        \labeltext{page}\pagenumber}}\hss}

\copycsname\v!letter:\v!header:\v!modified\endcsname\csname\v!letter:\v!header:\v!hanging\endcsname

\startsetups[letter:header]
\executeifdefined{\v!letter:\v!header:\@@@@lsheaderalternative}\donothing
\stopsetups

\startsetups[letter:footer]
\executeifdefined{\v!letter:\v!footer:\@@@@lsfooteralternative}\donothing
\stopsetups

%D \subject{Addressee field}
%D 
%D The address field is separated into two different fields.
%D The upper field is meant for dispatch information, the official height
%D in germany is 3 lines but this would lead to different heights dependent
%D of the font size and the fonts own height. The lower field contains the
%D name and address of the receiver and has a height of 6 lines in germany.
%D This value will lead to the same problem as the upper field, because the
%D whole address field has a fixed height and both field should fit into
%D this space. I solved this problem by assinging the upper field 1/3 of the
%D address height and the lower field 2/3 of the address height.
%D 
%D If you hace problem to put all information in the limited space you could
%D try to reduce the font size or reduce the interlinespace in the field.

\presetlocalframed[\????ls\v!dispatch]
\presetlocalframed[\????ls\v!addressee]

\startsetups[letter:place:dispatch]

  \localframed
    [\????ls\v!dispatch]
    {\doadaptleftskip {\letterstylevalue\v!dispatch\c!leftmargin}%
     \doadaptrightskip{\letterstylevalue\v!dispatch\c!rightmargin}%
     \doattributes{\????ls\v!dispatch}\c!style\c!color{\setups[letter:address:dispatch]}}

\stopsetups

\startsetups[letter:place:addressee]

  \localframed
    [\????ls\v!addressee]
    {\doadaptleftskip {\letterstylevalue\v!addressee\c!leftmargin}%
     \doadaptrightskip{\letterstylevalue\v!addressee\c!rightmargin}%
     \doattributes{\????ls\v!addressee}\c!style\c!color{\setups[letter:address:content]}}

\stopsetups

\setvalue{\v!letter:\v!address:\v!a}%
  {\doif\@@@@lsoptiondispatch \v!yes{\setups[letter:place:dispatch]}%
   \doif\@@@@lsoptionaddressee\v!yes{\setups[letter:place:addressee]}}

\startsetups[letter:address]
\offinterlineskip\vskip-\lineheight
\executeifdefined{\v!letter:\v!address:\@@@@lsaddressalternative}{\getvalue{\v!letter:\v!address:\v!a}}%
\stopsetups

\startsetups[letter:address:dispatch]
\lettervalue\c!dispatch
\stopsetups

\startsetups[letter:address:content]
\def\\{\letterstylevalue\v!address\c!separator}%
\lettervalue\c!toname
\doiflettervalue\c!toname\\
\lettervalue\c!toaddress
\stopsetups

%D The following setups shouldn't be changed ar you will loose information
%D in the output.
%D 
%D The reference line is choosen with the alternative key or if you set
%D a not defined alternative the definition a is choosen.

\startsetups[letter:reference]
\executeifdefined{\v!letter:\v!reference:\@@@@lsreferencealternative}{\getvalue{\v!letter:\v!reference:\v!a}}
\stopsetups

\resetvalue{\v!letter:\v!location:\v!a}

\setvalue{\v!letter:\v!location:\v!french}%
  {\lettervalue\c!place
   \doiflettervalue\c!place{\lettervalue{\c!place\c!separator}}%
   \lettervalue\c!date}

\startsetups[letter:location]
\executeifdefined{\v!letter:\v!location:\@@@@lslocationalternative}{\getvalue{\v!letter:\v!location:\v!a}}
\stopsetups

\startsetups[letter:title]
\doifelselettervalue\c!title
  {\lettervalue\c!title}
  {\doiflettervalue\c!attention
     {\labeltext{\v!letter:\c!attention}\lettervalue\c!attention}}
\stopsetups

\startsetups[letter:subject]
\def\\{\letterstylevalue\v!subject\c!separator}%
\labeltext{\v!letter:\c!subject}\lettervalue\c!subject
\stopsetups

\setvalue{\v!letter:\v!opening:\v!a}%
  {\doifelselettervalue\c!opening
     {\lettervalue\c!opening}
     {\doiflettervalue\c!salutation
        {\lettervalue\c!salutation}}}

\setvalue{\v!letter:\v!opening:\v!french}%
  {\ExpandSecondAfter\doifsomething{\letterstylevalue\v!option\c!indenting}
     {\setupindenting[\@@@@lsoptionindenting]}%
   \getvalue{\v!letter:\v!opening:\v!a}}

\startsetups[letter:opening]
\executeifdefined{\v!letter:\v!opening:\@@@@lsopeningalternative}{\getvalue{\v!letter:\v!opening:\v!a}}
\stopsetups

\startsetups[letter:content]
\lettervalue\c!content
\stopsetups

%D \subject{Closing and appendices}
%D 
%D It is possible to attach a signature to the closing command, before the signature
%D a skip is inserted but only if the the signature key has a value. The height of the
%D closing environment itself has a height of 4 lines to provide a free space for your
%D own handwritten signature and to have a little bit space between the closing text
%D and the appendices.

\setvalue{\v!letter:\v!closing:\v!a}%
  {\lettervalue\c!closing
   \doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}%
   \lettervalue\c!signature}

\setvalue{\v!letter:\v!closing:\v!french}%
  {\ExpandSecondAfter\doifsomething{\letterstylevalue\v!option\c!indenting}
     {\setupindenting[\@@@@lsoptionindenting,\v!first]}%
   \lettervalue\c!closing
   \doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}%
   \raggedcenter\doadaptleftskip{.5\textwidth}% quick and dirty
   \lettervalue\c!signature\endgraf}

\setvalue{\v!letter:\v!closing:\v!simplified}%
  {\doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}%
   \lettervalue\c!signature}

\startsetups[letter:closing]
\def\\{\letterstylevalue\v!closing\c!separator}%
\executeifdefined{\v!letter:\v!closing:\@@@@lsclosingalternative}{\getvalue{\v!letter:\v!closing:\v!a}}%
\stopsetups

\startsetups[letter:appendices]
\let\\\crlf
\doflushletterdescription
\stopsetups

\dodefineletterdescription[\v!enclosure]

\startsetups[letter:enclosure]
\processaction
  [\lettervalue\c!enclosure]
  [  \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi,
   \s!unknown=>\lettervalue\c!enclosure]
\stopsetups

\dodefineletterdescription[\v!copy]

\startsetups[letter:copy]
\processaction
  [\lettervalue\c!copy]
  [  \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi,
   \s!unknown=>\lettervalue\c!copy]
\stopsetups

\dodefineletterdescription[\v!postscript]

\startsetups[letter:postscript]
\processaction
  [\lettervalue\c!postscript]
  [  \v!empty=>\vrule\!!height\zeropoint\!!depth\zeropoint\!!width\hsize\relax\ifvmode\nowhitespace\fi,
   \s!unknown=>\lettervalue\c!postscript]
\stopsetups

\setvalue{\v!letter:\v!backaddress:\v!yes}%
  {\lettervalue\c!fromname
   \doiflettervalue\c!fromaddress\\
   \lettervalue\c!fromaddress}

\resetvalue{\v!letter:\v!backaddress:\v!no}

\setvalue{\v!letter:\v!backaddress:\v!auto}%
  {\doifelselettervalue\c!backaddress
     {\lettervalue\c!backaddress}
     {\lettervalue\c!fromname
      \doiflettervalue\c!fromaddress\\
      \lettervalue\c!fromaddress}}

\startsetups[letter:backaddress]
\def\\{\letterstylevalue\c!backaddress\c!separator}%
\executeifdefined{\v!letter:\v!backaddress:\@@@@lsbackaddressalternative}{\getvalue{\v!letter:\v!backaddress:\v!no}}%
\stopsetups

%D To prevent a pagebreak between the last line of the text and
%D the siganture a nonbreakable vertical space is necessary.
%D The vertical space is inserted in the style file with the normal
%D before and after commands where we control the distance between
%D the elements.

\defineblankmethod [\v!nobreak] {\penalty\plustenthousand}
\defineblankmethod [\v!endgraf] {\endgraf}

%D \subject{Additional settings}
%D 
%D I set alternative a as default value for alternative, the only content
%D is the date with a label. f you dont want a label choose alternative c
%D or change the label.

\startsetups[letter:optimize]

  \setbox\scratchbox\hbox % trial typesetting to get the heigth of the reference line
    {\executeifdefined{\v!letter:\v!reference:\@@@@lsreferencealternative}{\getvalue{\v!letter:\v!reference:\v!a}}}

  %\setups[letter:reference:\@@@@lsreferencealternative]

\stopsetups

%D We have at the moment only the values from the core module, I use the settings
%D from the dinb file as default settings, you could replace them in your own
%D document but I won't change the default style.
%D 
%D The labels are stored in a common file, you could use them in your own interface
%D but you have to live with my names.

\useletterstyle    [dinb]    % layout
\useletterextension[label]   % labels

\protect \endinput