ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] combining \definetyping and \definebuffer
@ 2023-07-29 19:09 Henning Hraban Ramm
  2023-07-29 20:06 ` [NTG-context] " Bruce Horrocks
  0 siblings, 1 reply; 8+ messages in thread
From: Henning Hraban Ramm @ 2023-07-29 19:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,
I’d like to use a custom buffer ("MyBuffer") to use a custom typing 
style ("MyCode"). How does that work?


"""
\usemodule[visual]

\definetyping[MyCode]

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

\definebuffer[MyBuffer]

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

\starttext

\startMyCode
\fakeword
\stopMyCode

\getMyBuffer

\typeMyBuffer

\stoptext
"""

Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  2023-07-29 19:09 [NTG-context] combining \definetyping and \definebuffer Henning Hraban Ramm
@ 2023-07-29 20:06 ` Bruce Horrocks
  2023-07-29 20:35   ` Henning Hraban Ramm
  2023-07-29 20:35   ` Henning Hraban Ramm
  0 siblings, 2 replies; 8+ messages in thread
From: Bruce Horrocks @ 2023-07-29 20:06 UTC (permalink / raw)
  To: ntg-context mailing list

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.

What were you exepcting if not this?

(onTeXt  ver: 2023.07.18 22:07 LMTX)

> On 29 Jul 2023, at 20:09, Henning Hraban Ramm <texml@fiee.net> wrote:
> 
> Hi,
> I’d like to use a custom buffer ("MyBuffer") to use a custom typing style ("MyCode"). How does that work?
> 
> 
> """
> \usemodule[visual]
> 
> \definetyping[MyCode]
> 
> \setuptyping[MyCode][
>  option=tex,
>  numbering=file,
> ]
> 
> \definebuffer[MyBuffer]
> 
> \startMyBuffer
> \fakewords{10}{20}
> \stopMyBuffer
> 
> \starttext
> 
> \startMyCode
> \fakeword
> \stopMyCode
> 
> \getMyBuffer
> 
> \typeMyBuffer
> 
> \stoptext
> """

—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  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
  1 sibling, 0 replies; 8+ messages in thread
From: Henning Hraban Ramm @ 2023-07-29 20:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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 \typeMyCode, and I don’t know how 
it could; something like \typeMyBuffer[MyCode] doesn’t work.

Hraban

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  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:16     ` Hans Hagen
  1 sibling, 2 replies; 8+ messages in thread
From: Henning Hraban Ramm @ 2023-07-29 20:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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.

Hraban

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Max Chernoff @ 2023-07-29 20:49 UTC (permalink / raw)
  To: ntg-context

I'm on mobile now so I can't type out a complete solution, but I think that what you're looking for is in this file:

    https://github.com/gucci-on-fleek/unnamed-emoji/blob/master/documentation/unemoji-manual.mkxl

It doesn't exactly do what you specifically asked for, but I think that it's pretty similar to your end goal. There's a .tex file with example usage in the same folder and a link to the compiled PDF from the main repo page. 

Thanks,
-- Max
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  2023-07-29 20:49     ` Max Chernoff
@ 2023-07-29 21:13       ` Henning Hraban Ramm
  0 siblings, 0 replies; 8+ messages in thread
From: Henning Hraban Ramm @ 2023-07-29 21:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 29.07.23 um 22:49 schrieb Max Chernoff:
> I'm on mobile now so I can't type out a complete solution, but I think that what you're looking for is in this file:
> 
>      https://github.com/gucci-on-fleek/unnamed-emoji/blob/master/documentation/unemoji-manual.mkxl
> 
> It doesn't exactly do what you specifically asked for, but I think that it's pretty similar to your end goal. There's a .tex file with example usage in the same folder and a link to the compiled PDF from the main repo page.

Thank you!
Well, I’m sure it’s in there, and it’s an impressive module, but I don’t 
understand the code – too many commands I never heard of.

I’ll try again tomorrow when my head hopefully hurts less and there 
won’t be concerts on both sides of my quarter…

Hraban

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  2023-07-29 20:35   ` Henning Hraban Ramm
  2023-07-29 20:49     ` Max Chernoff
@ 2023-07-29 21:16     ` Hans Hagen
  2023-07-30 12:36       ` Henning Hraban Ramm
  1 sibling, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2023-07-29 21:16 UTC (permalink / raw)
  To: ntg-context

[-- 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [NTG-context] Re: combining \definetyping and \definebuffer
  2023-07-29 21:16     ` Hans Hagen
@ 2023-07-30 12:36       ` Henning Hraban Ramm
  0 siblings, 0 replies; 8+ messages in thread
From: Henning Hraban Ramm @ 2023-07-30 12:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 29.07.23 um 23:16 schrieb Hans Hagen:
> On 7/29/2023 10:35 PM, Henning Hraban Ramm wrote:

>> 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 
> upcoming book should be hack free) ...

;-D

I’m not sure my book will even go so deep, it’s already too big and will 
never contain everything I’d like it to.
For the code examples therein I used some hacks (getting rid of them one 
by one), but I’m working on a module (more like a LaTeX-style document 
class) for DANTE’s DTK, to be able to write my articles about ConTeXt in 
ConTeXt and have them included as PDFs. For other authors, I’d like the 
syntax to be as simple as possible (using generic ConTeXt macros), so I 
use \setuptyping for the general style with a background box. But that 
conflicts with the setups for special cases like code and result side by 
side.
I guess I’ll also include this in the CGJ setup.

> ... 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.

Thank you! Will do. I guess it’ll be in the next upload, too?

Hraban

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-30 12:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-29 19:09 [NTG-context] combining \definetyping and \definebuffer 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
2023-07-30 12:36       ` Henning Hraban Ramm

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).