* Buffers and commands with optional arguments
@ 2008-05-31 10:09 Wolfgang Schuster
2008-05-31 10:33 ` Hans Hagen
2008-05-31 10:51 ` Hans Hagen
0 siblings, 2 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2008-05-31 10:09 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-05-31 10:09 Buffers and commands with optional arguments Wolfgang Schuster
@ 2008-05-31 10:33 ` Hans Hagen
2008-05-31 10:51 ` Wolfgang Schuster
2008-05-31 10:51 ` Hans Hagen
1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2008-05-31 10:33 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-05-31 10:09 Buffers and commands with optional arguments Wolfgang Schuster
2008-05-31 10:33 ` Hans Hagen
@ 2008-05-31 10:51 ` Hans Hagen
2008-06-02 6:42 ` Wolfgang Schuster
1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2008-05-31 10:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-05-31 10:33 ` Hans Hagen
@ 2008-05-31 10:51 ` Wolfgang Schuster
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2008-05-31 10:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi Hans,
On Sat, May 31, 2008 at 12:33 PM, Hans Hagen <pragma@wxs.nl> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-05-31 10:51 ` Hans Hagen
@ 2008-06-02 6:42 ` Wolfgang Schuster
2008-06-02 8:05 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2008-06-02 6:42 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Sat, May 31, 2008 at 12:51 PM, Hans Hagen <pragma@wxs.nl> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-06-02 6:42 ` Wolfgang Schuster
@ 2008-06-02 8:05 ` Hans Hagen
2008-06-02 8:14 ` Wolfgang Schuster
0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2008-06-02 8:05 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Buffers and commands with optional arguments
2008-06-02 8:05 ` Hans Hagen
@ 2008-06-02 8:14 ` Wolfgang Schuster
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2008-06-02 8:14 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Mon, Jun 2, 2008 at 10:05 AM, Hans Hagen <pragma@wxs.nl> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-06-02 8:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-31 10:09 Buffers and commands with optional arguments Wolfgang Schuster
2008-05-31 10:33 ` Hans Hagen
2008-05-31 10:51 ` Wolfgang Schuster
2008-05-31 10:51 ` Hans Hagen
2008-06-02 6:42 ` Wolfgang Schuster
2008-06-02 8:05 ` Hans Hagen
2008-06-02 8:14 ` Wolfgang Schuster
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).