ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Benjamin Buchmuller via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Benjamin Buchmuller <benjamin.buchmuller@gmail.com>
Subject: How to make \def accept block or buffer as part of (long) command argument
Date: Sun, 2 Jan 2022 11:47:52 +0100	[thread overview]
Message-ID: <2D694B3A-8462-42B5-9288-8E89A8C7A618@gmail.com> (raw)
In-Reply-To: <98599453-51E7-4E62-805E-C94008E896E8@gmail.com>

Hi list,

I'm playing around with blocks and buffers again, realizing that I cannot use them inbetween a \start...\stop that I defined myself. Apparently, they work between \startsection...\stopsection and the like, so I was wondering how I should define or expand #2 in the MWE below to make TeX happily accept these useful features?

Thanks a lot


Benjamin


\starttext

\let\stopMyCommand\relax

\tolerant\protected\def\startMyCommand[#1]#2\stopMyCommand{

	Optional argument #1
	
	Content #2

}

\bf Here we test the command: Works \tf

\startMyCommand[is optional]
gets processed!
\stopMyCommand

\bf Here we test the block: Works \tf

\defineblock[MyBlock]

\beginMyBlock
Block for something else.
\endMyBlock

\useblocks[MyBlock][criterium=text]

\bf Here we test the block inside command: Fails \tf

% UNCOMMENT BELOW FAILS: tex error > runaway error: end of file encountered
%
% \startMyCommand[is optional]
% Still?
%
% \beginMyBlock
% Block for something else.
% \endMyBlock
% \stopMyCommand

\definebuffer[MyBuffer]

\bf Here we test the buffer: Works \tf

\startbuffer[MyBuffer]
Buffer for something else.
\stopbuffer

\getbuffer[MyBuffer]

\bf Here we test the buffer inside command: Fails \tf

% UNCOMMENT BELOW FAILS: tex error > runaway error: end of file encountered
%
% \startMyCommand[is optional]
% Still?
%
% \startbuffer[MyBuffer]
% Buffer for something else.
% \endbuffer
% \stopMyCommand

\stoptext
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2022-01-02 10:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.440.1641107345.1172.ntg-context@ntg.nl>
2022-01-02 10:30 ` Dangerous bends symbol in manfnt.afm accidentally chopped by LMTX? Benjamin Buchmuller via ntg-context
2022-01-02 10:47   ` Benjamin Buchmuller via ntg-context [this message]
2022-01-02 11:19     ` How to make \def accept block or buffer as part of (long) command argument Hans Hagen via ntg-context
2022-01-02 13:14       ` Benjamin Buchmuller via ntg-context
2022-01-02 13:43         ` Hans Hagen via ntg-context
2022-01-02 17:06           ` Benjamin Buchmuller via ntg-context
2022-01-02 11:43   ` Dangerous bends symbol in manfnt.afm accidentally chopped by LMTX? Hans Hagen via ntg-context

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=2D694B3A-8462-42B5-9288-8E89A8C7A618@gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=benjamin.buchmuller@gmail.com \
    /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).