Buffers and commands with optional arguments
Hi Hans, I got yesterday a bug report for my letter module if the \startletter command takes no arguments. The following example show the problem without the module. \def\startletter {\dosingleempty\dostartletter} \def\dostartletter[#1]% {\dostartbuffer[letter][startletter][stopletter]} \starttext % This did work \startletter Text \stopletter \getbuffer[letter] % But this did create a error message from TeX \startletter Text \stopletter \getbuffer[letter] \stopletter One solution for the second text can be solved when I add a \relax after the \startletter command but I wanted a better solution. Because TeX mentions \flushbufferline in error message I tried to modify the macro and came to the following solution. %\def\flushbufferline#1% \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{\string#1}}% \immediate\write\tmpblocks{#1}}% \fi} The macro has to be defined as long and the \string in the \write command has to be removed. I made a few short tests and saw no negative sideeffects from my changes. Another problem could arise with a few commands in the letter environment if no empty line is written after \startletter. The following result also in a error message. \startletter \dorecurse{2}{\input knuth\par} \stopbuffer With another modification of \flushbufferline also this example could work, my final patch was now: \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 \convertargument#1\to\ascii %\doifsomething{#1} \doifsomething\ascii {\tmpblockstartedtrue %\immediate\write\tmpblocks{\string#1}}% %\immediate\write\tmpblocks{#1}}% \immediate\write\tmpblocks{\ascii}}% \fi} Could my seond or at least my first patched version of the \flushbufferline macro integrated into core-buf.mkii because I won't force users of my letter module to put a \relax after \startletter only because they use MkII. Greetings Wolfgang
Wolfgang Schuster wrote:
\doifsomething{#1} {\tmpblockstartedtrue %\immediate\write\tmpblocks{\string#1}}% \immediate\write\tmpblocks{#1}}%
i have no problem with the \long but changing the \string ... it's there for a reason so i need to look into it
\convertargument#1\to\ascii %\doifsomething{#1} \doifsomething\ascii {\tmpblockstartedtrue %\immediate\write\tmpblocks{\string#1}}% %\immediate\write\tmpblocks{#1}}% \immediate\write\tmpblocks{\ascii}}%
this may introduce spaces after \cs and therefore renders buffers useless for verbatim usage
because I won't force users of my letter module to put a \relax after \startletter only because they use MkII.
did you try \definebuffer[letter] Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Hans,
On Sat, May 31, 2008 at 12:33 PM, Hans Hagen
Wolfgang Schuster wrote:
\doifsomething{#1} {\tmpblockstartedtrue %\immediate\write\tmpblocks{\string#1}}% \immediate\write\tmpblocks{#1}}%
i have no problem with the \long but changing the \string ... it's there for a reason so i need to look into it
I removed it because the output from \startletter text \stopletter was written as "\partext" to the temp file and I got "\par text" after I removed the \string.
\convertargument#1\to\ascii %\doifsomething{#1} \doifsomething\ascii {\tmpblockstartedtrue %\immediate\write\tmpblocks{\string#1}}% %\immediate\write\tmpblocks{#1}}% \immediate\write\tmpblocks{\ascii}}%
this may introduce spaces after \cs and therefore renders buffers useless for verbatim usage
This hack is not so importand because a empty line before the \dorecurse did help.
because I won't force users of my letter module to put a \relax after \startletter only because they use MkII.
did you try
\definebuffer[letter]
Seems to be work in my example, I will try it later with my module but it looks good for the moment. Thanks Wolfgang
Wolfgang Schuster wrote:
Hi Hans,
I got yesterday a bug report for my letter module if the \startletter command takes no arguments.
The following example show the problem without the module.
\def\startletter {\dosingleempty\dostartletter}
\def\dostartletter[#1]% {\dostartbuffer[letter][startletter][stopletter]}
either use \definebuffer, or do \def\startletter {\bgroup\obeylines\dosingleempty\dostartletter} \def\dostartletter[#1]% {\egroup\dostartbuffer[letter][startletter][stopletter]} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Sat, May 31, 2008 at 12:51 PM, Hans Hagen
Wolfgang Schuster wrote:
Hi Hans,
I got yesterday a bug report for my letter module if the \startletter command takes no arguments.
The following example show the problem without the module.
\def\startletter {\dosingleempty\dostartletter}
\def\dostartletter[#1]% {\dostartbuffer[letter][startletter][stopletter]}
either use \definebuffer, or do
Did not work in my case.
\def\startletter {\bgroup\obeylines\dosingleempty\dostartletter}
\def\dostartletter[#1]% {\egroup\dostartbuffer[letter][startletter][stopletter]}
This has the unwanted side effect I expected to allow the argument only on the same line as the \startletter command or is otherwise shown in the output. I will now include a modified version from the \flushbufferline macro with my package in will look for the first person with a problem. Greetings Wolfgang
Wolfgang Schuster wrote:
I will now include a modified version from the \flushbufferline macro with my package in will look for the first person with a problem.
keep in mind that such low level macros are not part of the official interface and their name and/or the way of calling them may change Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Mon, Jun 2, 2008 at 10:05 AM, Hans Hagen
Wolfgang Schuster wrote:
I will now include a modified version from the \flushbufferline macro with my package in will look for the first person with a problem.
keep in mind that such low level macros are not part of the official interface and their name and/or the way of calling them may change
I keep a eye on this but I won't force users a put \relax after \startletter only because they use MkII. Wolfgang
participants (2)
-
Hans Hagen
-
Wolfgang Schuster