Re: Yet Another buffer question

Wolfgang Schuster <[email protected]>
Newsgroups gmane.comp.tex.context
Message-ID <[email protected]>
Am 16.04.2026 um 19:46 schrieb Wolfgang Schuster:
> Am 16.04.2026 um 19:33 schrieb Jim via ntg-context:
>> Possibly the last buffer question for IBD 2026...
>>
>> Suppose someone wants to use a buffer in a solution to some typesetting
>> problem which involves more than a simple \getbuffer or \typebuffer or
>> \typesetbuffer.
>>
>> They could define something like
>>
>>          \def\usebuf#1{...use buffer #1 as needed...}
>>
>> and later do
>>
>>          \startbuffer[mybuf]
>>          <content>
>>          \stopbuffer
>>          \usebuf{mybuf}
>>
>> But this isn't in the spirit of the
>>          \startsomething
>>          <content>
>>          \stopsomething
>> paradigm.
>>
>> How does one define a \start-\stop "environment" that
>> -> collects some content into a buffer, and then
>> -> does whatever one needs to do with that content ?
> 
> There is
> 
> %%%% begin example
> \definebuffer[Jim]
> 
> \starttext
> 
> \startJim
> This is Jim’s buffer!
> \stopJim
> 
> \typeJim \getJim
> 
> \stoptext
> %%%% end example

You can also define a \stopXXX command where you can load the buffer 
content and do something with it once you reach the end of the buffer, 
this is a feature of the environment itself.

%%%% begin example
\definebuffer[Jim]

\protected\def\stopJim
   {\startframedtext
    \getJim
    \stopframedtext}

% alternative way to define \stopJim
%\starttexdefinition protected stopJim
%  \startframedtext
%  \getJim
%  \stopframedtext
%\stoptexdefinition

\starttext

\startJim
This is Jim’s buffer!
\stopJim

\stoptext
%%%% end example

Wolfgang

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

maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.