ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: combining \definetyping and \definebuffer
Date: Sat, 29 Jul 2023 23:16:55 +0200	[thread overview]
Message-ID: <7ed6d747-bd2e-f807-4981-dee595c9bb60@xs4all.nl> (raw)
In-Reply-To: <9c4c3f9c-3335-8a24-fa3a-675626691ab7@fiee.net>

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]

On 7/29/2023 10:35 PM, Henning Hraban Ramm wrote:
> Am 29.07.23 um 22:06 schrieb Bruce Horrocks:
>> Your example seems to work: I see the \getbuffer[MyBuffer] command 
>> typed (not executed) with colour coding on the keyword and line 
>> numbered; then the block text fakewords from the visual module; then 
>> the \fakewords macro shown (again not executed) as per the default for 
>> typing.
> 
> The setup for MyCode is not applied to \typeMyBuffer, and I don’t know 
> how it could; something like \typeMyBuffer[MyCode] doesn’t work.

These commands inherit from buffer, so \setupbuffer will work. But as I 
need to prevent you to come up with some ugly hack (after all your 
upocoming book should be hack free) ...

... attached an extension that supports inheritance (via category), 
still honors 'buffer' otherwise and accepts an optional category instead 
of settings. take your choice ...

You can put the patch in cont-new.mkxl assuming you wikify it too.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: buffers-003.tex --]
[-- Type: text/plain, Size: 1279 bytes --]

\unprotect \pushoverloadmode

\appendtoks
    \frozen\instance\protected\edefcsname\e!type\currentbuffer\endcsname
      {\buff_verbatim_type_defined_buffer[\currentbuffer][\currentdefinedbuffer]}%
\to \everydefinebuffer

\tolerant\protected\def\buff_verbatim_type_defined_buffer[#1]#*[#2]#*[#3]% category name settings
  {\begingroup
   \cdef\currenttyping{\namedbufferparameter{#1}\c!category}%
   \ifempty\currenttyping
     \let\currenttyping\v!buffer
   \fi
   \ifhastok={#3}%
     \setupcurrenttyping[#3]%
   \orelse\ifempty{#3}\else
     \cdef\currenttyping{#3}
   \fi
   \buff_verbatim_type_buffer_indeed{\currenttyping}{#2}%
   \useindentnextparameter\typingparameter
   \endgroup
   \dorechecknextindentation}

\popoverloadmode \protect

\usemodule[visual]

\definetyping[MyCode]

\setuptyping
  [MyCode]
  [option=tex,
   numbering=file]

\definebuffer
  [MyBuffer]
  [category=MyCode]

\setuptyping
  [MyBuffer]
  [option=TEX,
   numbering=file]

% \setuptyping
%   [buffer]
%   [option=TEX,
%    numbering=file]

\startMyBuffer
\fakewords{10}{20}
\stopMyBuffer

\starttext

\startMyCode
\fakeword
\stopMyCode

\getMyBuffer

\typeMyBuffer

\typeMyBuffer[MyCode]

\typeMyBuffer[option=TEX]

\stoptext

[-- Attachment #3: Type: text/plain, Size: 495 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2023-07-29 21:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-29 19:09 [NTG-context] " Henning Hraban Ramm
2023-07-29 20:06 ` [NTG-context] " Bruce Horrocks
2023-07-29 20:35   ` Henning Hraban Ramm
2023-07-29 20:35   ` Henning Hraban Ramm
2023-07-29 20:49     ` Max Chernoff
2023-07-29 21:13       ` Henning Hraban Ramm
2023-07-29 21:16     ` Hans Hagen [this message]
2023-07-30 12:36       ` Henning Hraban Ramm

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=7ed6d747-bd2e-f807-4981-dee595c9bb60@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /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).