Am 17.02.2026 um 21:36 schrieb Henning Hraban Ramm:
Hi,
Pablo and I were discussing possibilities for code examples.

We’d like to copy a code example to a comment (annotation) because it’s easier to copy from there, esp. if line numbers are involved.

The example tries 3 ways, but only the first works, i.e. using a named buffer and calling it by name.

I don’t understand why the version with a defined buffer doesn’t work. Isn’t “CodeExample” the name of the buffer?

In the third case, I tried to hook the comment in typing; here I don’t know the name of the buffer. I tried \currenttype and \currentbuffer, but that didn’t work.


"""
\setupinteraction[state=start,]

% this works:
\protected\def\CodeBuffer[#1]{%
\comment[location=inmargin,space=yes,buffer=#1]{}%
\typebuffer[#1]\blank\getbuffer[#1]}

% comment is empty:
\definebuffer[CodeExample]
\define\stopCodeExample{%
\comment[buffer=CodeExample,location=inmargin,space=yes,color=orange]{}%

\comment[buffer=\thedefinedbuffer{CodeExample},...]{}

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
___________________________________________________________________________________

Reply via email to