ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Fresh install & t-letter module
Date: Fri, 15 May 2009 15:34:43 +0200	[thread overview]
Message-ID: <8FEAEC19-36A9-4F26-B7E7-BF1FB4BA2D90@gmail.com> (raw)
In-Reply-To: <1a3190fd0905150623k2cd0a2a1m665621b5c4f41e5b@mail.gmail.com>

[-- Attachment #1: default.nli --]
[-- Type: application/octet-stream, Size: 24510 bytes --]

%D \module
%D   [       file=default,
%D        version=2009.05.10,
%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]

\unprotect

%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}

\defineletterelement[\v!reference][\v!a]
  {\setbox\scratchbox\hbox\!!to\hsize
     {\getcommacommandsize[\@@@@lsreferencelist]% \@@@@ldreference?
      \ifnum\commalistsize<\plustwo\hfill\fi
      \processcommacommand[\@@@@lsreferencelist]\formatreferencelista\unskip}%
   \global\letter!height!reference\htdp\scratchbox
   \box\scratchbox}

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

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

\setupletterstyle
  [\v!firstpage]
  [\c!topspace=\dimexpr\letterstylevalue{\v!reference\v!layer}\c!voffset+\letterstylevalue\v!reference\c!spaceafter+\letter!height!reference\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}

\defineletterelement[\v!reference][\v!b]
  {\vtop % why not \vbox?
     {\processcommacommand[\@@@@lsreferencelist]\formatreferencelistb}}

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

\setupletterstyle
  [\v!reference]
  [\v!layer]
  [\c!hoffset=125.7mm,
   \c!voffset=\letterstylevalue{\v!address\v!layer}\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}

\defineletterelement[\v!reference][\v!c]
  {\hbox\!!to\hsize
     {\processcommacommand[\@@@@lsreferencelist]\formatreferencelistc}}

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

\setups[\v!letter:\v!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} % why did \TB not work?
     {\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}

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

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

\setupletterstyle
  [\v!reference]
  [\v!layer]
  [\c!hoffset=125.7mm,
   \c!voffset=\letterstylevalue{\v!address\v!layer}\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}

\defineletterelement[\v!reference][\v!e]
  {\hbox\!!to\hsize
     {\processcommacommand[\@@@@lsreferencelist]\formatreferenceliste\hss}}

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

\setups[\v!letter:\v!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.

\resetletterelement[\v!reference][\v!none]

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

  % Use the topspace value from the style file

\stopsetups

%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}.

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

\long\def\dostartletter[#1][#2]#3\stopletter
  {\ifsecondargument
     \getparameters[\????ld][#1]%
     \doifundefinedelse{\????ld\????ld#2}
       {\setvalue{\????ld\c!toaddress}{#2}}
       {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#2}}}%
   \else\iffirstargument
     \doifassignmentelse{#1}
       {\getparameters[\????ld][#1]}
       {\doifundefinedelse{\????ld\????ld#1}
          {\setvalue{\????ld\c!toaddress}{#1}}
          {\setvalue{\????ld\c!toaddress}{\getvalue{\????ld\????ld#1}}}}%
   \fi\fi
   \setbuffer[lettercontent]#3\endbuffer
   \processlettervalues
   \directsetup{\v!letter:\v!place}\egroup}

\newtoks\letter!local!commands

\def\processlettervalues
  {\globalletempty\letter!list!descriptions
   \global\letter!local!commands\emptytoks
   \def\opening##1{\doglobal\appendtoks\setvalue{\????ld\c!opening   }{##1}\to\letter!local!commands}%
   \def\closing##1{\doglobal\appendtoks\setvalue{\????ld\c!closing   }{##1}\to\letter!local!commands}%
   \def\ps     ##1{\doglobal\appendtoks\setvalue{\????ld\c!postscript}{##1}\to\letter!local!commands\doglobal\appendtocommalist\c!postscript\letter!list!descriptions}%
   \def\cc     ##1{\doglobal\appendtoks\setvalue{\????ld\c!copy      }{##1}\to\letter!local!commands\doglobal\appendtocommalist\c!copy      \letter!list!descriptions}%
   \def\encl   ##1{\doglobal\appendtoks\setvalue{\????ld\c!enclosure }{##1}\to\letter!local!commands\doglobal\appendtocommalist\c!enclosure \letter!list!descriptions}%
   \setbox\scratchbox\hbox{\getbuffer[lettercontent]}%
   \flushtoks\letter!local!commands}

\def\gobblelettervalues
  {\def\dogobblelettervalues##1{\letcsnamecs\csname##1\endcsname\gobbleoneargument}%
   \processcommalist[\c!opening,\c!closing,\c!ps,\c!cc,\c!encl]\dogobblelettervalues}

%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.

\defineletterelement[\v!head][\v!a]
  {\lettervalue\c!fromname
   \doiflettervalue\c!fromname\\
   \lettervalue\c!fromaddress}

\setvalue{@@head@@\c!rule\v!no    }{0}
\setvalue{@@head@@\c!rule\v!none  }{0}
\setvalue{@@head@@\c!rule\v!off   }{0}
\setvalue{@@head@@\c!rule\v!top   }{1}
\setvalue{@@head@@\c!rule\v!before}{1}
\setvalue{@@head@@\c!rule\v!bottom}{2}
\setvalue{@@head@@\c!rule\v!after }{2}
\setvalue{@@head@@\c!rule\v!yes   }{2}
\setvalue{@@head@@\c!rule\v!on    }{2}

\def\simpleexecuteifdefined#1#2{\ifcsname#1\endcsname\csname#1\endcsname\else#2\fi}% -> t-correspondence?
  
\defineletterelement[\v!head][\v!left]
  {\normalhbox
     {\def\!!fromrule{\simpleexecuteifdefined{@@head@@\c!rule\letterstylevalue\v!head\c!fromrule}{0}}%
      \framed[frame=off,location=bottom,align=right,width=\hsize]
        {\dostartattributes{\????ld\c!fromname}\c!style\c!color
         \lettervalue\c!fromname
         \ifnum\!!fromrule=\plusone
           \doifelselettervalue\c!fromlogo
             {\setbox\scratchbox\hbox{\lettervalue\c!fromlogo}%
              \scratchdimen\dimexpr\letterstylevalue\v!head\c!rulewidth-\wd\scratchbox\relax}
             {\scratchdimen\letterstylevalue\v!head\c!rulewidth}%
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes
         \\
         \dostartattributes{\????ld\c!fromaddress}\c!style\c!color
         \lettervalue\c!fromaddress
         \doiflettervalue\c!fromphone{\\\lettervalue\c!fromphone}%
         \doiflettervalue\c!fromfax  {\\\lettervalue\c!fromfax  }%
         \doiflettervalue\c!frommail {\\\lettervalue\c!frommail }%
         \doiflettervalue\c!fromurl  {\\\lettervalue\c!fromurl  }%
         \ifnum\!!fromrule=\plustwo
           \ifzeropt\letterstylevalue\v!head\c!rulewidth
             \scratchdimen\hsize
           \else
             \scratchdimen\letterstylevalue\v!head\c!rulewidth
           \fi
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes}%
      \doiflettervalue\c!fromlogo{\llap{\lettervalue\c!fromlogo}}}}%

\defineletterelement[\v!head][\v!middle]
  {\normalhbox
     {\def\!!fromrule{\simpleexecuteifdefined{@@head@@\c!rule\letterstylevalue\v!head\c!fromrule}{0}}%
      \framed[frame=off,location=bottom,align=middle,width=\hsize]
        {\dostartattributes{\????ld\c!fromname}\c!style\c!color
         \lettervalue\c!fromname
         \ifnum\!!fromrule=\plusone
           \ifzeropt\letterstylevalue\v!head\c!rulewidth
             \scratchdimen\hsize
           \else
             \scratchdimen\letterstylevalue\v!head\c!rulewidth
           \fi
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes
         \\
         \dostartattributes{\????ld\c!fromaddress}\c!style\c!color
         \lettervalue\c!fromaddress
         \doiflettervalue\c!fromphone{\\\lettervalue\c!fromphone}%
         \doiflettervalue\c!fromfax  {\\\lettervalue\c!fromfax  }%
         \doiflettervalue\c!frommail {\\\lettervalue\c!frommail }%
         \doiflettervalue\c!fromurl  {\\\lettervalue\c!fromurl  }%
         \ifnum\!!fromrule=\plustwo
           \ifzeropt\letterstylevalue\v!head\c!rulewidth
             \scratchdimen\hsize
           \else
             \scratchdimen\letterstylevalue\v!head\c!rulewidth
           \fi
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes}}}

\defineletterelement[\v!head][\v!right]
  {\normalhbox
     {\def\!!fromrule{\simpleexecuteifdefined{@@head@@\c!rule\letterstylevalue\v!head\c!fromrule}{0}}%
      \doiflettervalue\c!fromlogo{\rlap{\lettervalue\c!fromlogo}}%
      \framed[frame=off,location=bottom,align=left,width=\hsize]
        {\dostartattributes{\????ld\c!fromname}\c!style\c!color
         \lettervalue\c!fromname
         \ifnum\!!fromrule=\plusone
           \ifzeropt\letterstylevalue\v!head\c!rulewidth
             \scratchdimen\hsize
           \else
             \doifelselettervalue\c!fromlogo
               {\setbox\scratchbox\hbox{\lettervalue\c!fromlogo}%
                \scratchdimen\dimexpr\letterstylevalue\v!head\c!rulewidth-\wd\scratchbox\relax}
               {\scratchdimen\letterstylevalue\v!head\c!rulewidth}%
           \fi
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes
         \\
         \dostartattributes{\????ld\c!fromaddress}\c!style\c!color
         \\\lettervalue\c!fromaddress
         \doiflettervalue\c!fromphone{\\\lettervalue\c!fromphone}%
         \doiflettervalue\c!fromfax  {\\\lettervalue\c!fromfax  }%
         \doiflettervalue\c!frommail {\\\lettervalue\c!frommail }%
         \doiflettervalue\c!fromurl  {\\\lettervalue\c!fromurl  }%
         \ifnum\!!fromrule=\plustwo
           \ifzeropt\letterstylevalue\v!head\c!rulewidth
             \scratchdimen\hsize
           \else
             \scratchdimen\letterstylevalue\v!head\c!rulewidth
           \fi
           \vskip-.5\lineheight\blackrule
             [width=\scratchdimen,
              height=\letterstylevalue\v!head\c!rulethickness,
              color=\letterstylevalue\v!head\c!rulecolor]%
         \fi
         \dostopattributes}}}

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

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

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

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

\defineletterelement[\v!nexthead][\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}}}}

\defineletterelement[\v!nexthead][\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\c!page\pagenumber}}\hss}

\defineletterelement[\v!nexthead][\v!semiblock]
  {\hbox\!!to\hsize
     {\rlap{\lettervalue\c!toname}%
      \midaligned{\pagenumber}%
      \llap{\lettervalue\c!date}}}

\copyletterelement[\v!nexthead][\v!simplified][\v!fullblock]
\copyletterelement[\v!nexthead][\v!modified  ][\v!hanging  ]

%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[\v!letter:\v!place:\v!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{\directsetup{\v!letter:\v!address:\v!dispatch}}}

\stopsetups

\startsetups[\v!letter:\v!place:\v!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{\directsetup{\v!letter:\v!address:\v!content}}}

\stopsetups

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

\startsetups[\v!letter:\v!address]
\offinterlineskip\endgraf
\executeifdefined{\v!letter:\v!address:\@@@@lsaddressalternative}{\letterelement[\v!address][\v!a]}%
\stopsetups

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

\startsetups[\v!letter:\v!address:\v!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[\v!letter:\v!reference]
\executeifdefined{\v!letter:\v!reference:\@@@@lsreferencealternative}{\letterelement[\v!reference][\v!a]}
\stopsetups

\resetletterelement[\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[\v!letter:\v!location]
\executeifdefined{\v!letter:\v!location:\@@@@lslocationalternative}{\letterelement[\v!location][\v!a]}
\stopsetups

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

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

\defineletterelement[\v!opening][\v!a]
  {\doifelselettervalue\c!opening
     {\lettervalue\c!opening}
     {\doiflettervalue\c!salutation
        {\lettervalue\c!salutation}}}

\defineletterelement[\v!opening][\v!french]
  {\ExpandSecondAfter\doifsomething{\letterstylevalue\v!option\c!indenting}
     {\setupindenting[\@@@@lsoptionindenting]}%
   \letterelement[\v!opening][\v!a]}

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

\startsetups[\v!letter:\v!content]
\gobblelettervalues\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.

\defineletterelement[\v!closing][\v!a]
  {\lettervalue\c!closing
   \doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}%
   \lettervalue\c!signature}

\defineletterelement[\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}

\defineletterelement[\v!closing][\v!simplified]
  {\doiflettervalue\c!signature{\letterstylevalue\v!closing\c!inbetween}%
   \lettervalue\c!signature}

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

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

\dodefineletterdescription[\v!enclosure]

\startsetups[\v!letter:\v!enclosure]
\lettervalue\c!enclosure
\stopsetups

\dodefineletterdescription[\v!copy]

\startsetups[\v!letter:\v!copy]
\lettervalue\c!copy
\stopsetups

\dodefineletterdescription[\v!postscript]

\startsetups[\v!letter:\v!postscript]
\lettervalue\c!postscript
\stopsetups

\defineletterelement[\v!backaddress][\v!yes]
  {\lettervalue\c!fromname
   \doiflettervalue\c!fromaddress\\
   \lettervalue\c!fromaddress}

\resetletterelement[\v!backaddress][\v!no]

\defineletterelement[\v!backaddress][\v!auto]
  {\doifelselettervalue\c!backaddress
     {\lettervalue\c!backaddress}
     {\lettervalue\c!fromname
      \doiflettervalue\c!fromaddress\\
      \lettervalue\c!fromaddress}}

\startsetups[\v!letter:\v!backaddress]
\def\\{\letterstylevalue\c!backaddress\c!separator}
\executeifdefined{\v!letter:\v!backaddress:\@@@@lsbackaddressalternative}{\letterelement[\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[\v!letter:\v!optimize]

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

  \setups[\v!letter:\v!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
\useletterextension[addrentry] % database

\protect \endinput

[-- Attachment #2: Type: text/plain, Size: 1938 bytes --]



Fixed version is only (don't know how long it takes till you get it  
with the minimals),
for the moment use the attached file. Sorry for the crash (which was  
my fault) but
a few features I use in my module depend on the ConTeXt version  
(especially when
you use MkIV).

Wolfgang

Am 15.05.2009 um 15:23 schrieb Markus Hubig:

> Hi @all,
>
> I did a fresh install @linux.
>
> mkdir context && cd context
> wget http://minimals.contextgarden.net/setup/first-setup.sh
> first-setup.sh --extras="t-letter"
>
> Wrote a letter:
>
> \usemodule[letter]
> \starttext
> \startletter
> Thus, I came to the conclusion ...
> \stopletter
> \stoptext
>
> Compiled it:
>
> texexec --lua brief.tex
>
> Aaaand -> bum!
>
> system          : brief.top loaded
> (brief.top)
> fonts           : preloading latin modern fonts
> bodyfont        : 12pt rm is loaded
> language        : language en is active
> system          : module letter not found
> systems         : begin file brief at line 2
> ! Undefined control sequence.
> l.3 \startletter
>
> texexec --xtx brief.tex
>
> ! Undefined control sequence.
> \dosetbuffer ...setcurrentbuffer {#1}\mksetbuffer
>
> texexec brief.tex
>
> ! Undefined control sequence.
> \dosetbuffer ...setcurrentbuffer {#1}\mksetbuffer
>
> Why can't something like this not "just work"!
>
> Markus
>
> --
> -------------------"it's like this"------
> even samurai have teddy bears
> and even teddy bears get drunk
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an  
> entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #3: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2009-05-15 13:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 13:23 Markus Hubig
2009-05-15 13:34 ` Wolfgang Schuster [this message]
2009-05-18 12:55   ` Markus Hubig
2009-05-18 13:25     ` Aditya Mahajan
2009-05-18 14:41       ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8FEAEC19-36A9-4F26-B7E7-BF1FB4BA2D90@gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).