* \startuserdata syntax questions
@ 2018-08-28 20:40 Rik Kabel
2018-08-29 7:15 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Rik Kabel @ 2018-08-28 20:40 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1103 bytes --]
Wolfgang, Hans, et al,
The new \startuserdata macro looks very promising, and can simplify some
work I have in progress.
The first question: the wiki example and the source use
\userparameter{optionkey}
\userparameter{anotherkey}
to retrieve the value of optionkey and anotherkey. Is there a way to
provide the key/value pairs in a manner that they can be retrieved with
the getparameters mechanism, as:
\getrawparameters [XX] [optionkey=,anotherkey=,#1]
This has the added advantage of allowing the setting of a default value, as
\getrawparameters [XX] [optionkey=2em,anotherkey=,#1]
Or is there a reason not to use getparameters in this setting?
The second question: Is there the possibility to enhance the syntax so
that one can write
\startMyStuff [optionalkey=value, anotherkey=value]
stuff
\stopMyStuff
instead of
\startuserdata [MyStuff] [optionalkey=value, anotherkey=value]
stuff
\stopuserdata
Such syntactic sugar makes sweeter reading of the text, and makes
clearer what is being done when nesting the macro.
--
Rik Kabel
[-- Attachment #1.2: Type: text/html, Size: 1748 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: \startuserdata syntax questions
2018-08-28 20:40 \startuserdata syntax questions Rik Kabel
@ 2018-08-29 7:15 ` Hans Hagen
2018-08-29 15:19 ` Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2018-08-29 7:15 UTC (permalink / raw)
To: mailing list for ConTeXt users, Rik Kabel
On 8/28/2018 10:40 PM, Rik Kabel wrote:
> Wolfgang, Hans, et al,
>
> The new \startuserdata macro looks very promising, and can simplify some
> work I have in progress.
>
> The first question: the wiki example and the source use
>
> \userparameter{optionkey}
> \userparameter{anotherkey}
>
> to retrieve the value of optionkey and anotherkey. Is there a way to
> provide the key/value pairs in a manner that they can be retrieved with
> the getparameters mechanism, as:
>
> \getrawparameters [XX] [optionkey=,anotherkey=,#1]
>
> This has the added advantage of allowing the setting of a default value, as
>
> \getrawparameters [XX] [optionkey=2em,anotherkey=,#1]
>
> Or is there a reason not to use getparameters in this setting?
hardly any of the core mechanisms in mkiv uses get(raw)parameters
define a category and then clone it ...
> The second question: Is there the possibility to enhance the syntax so
> that one can write
>
> \startMyStuff [optionalkey=value, anotherkey=value]
> stuff
> \stopMyStuff
>
> instead of
>
> \startuserdata [MyStuff] [optionalkey=value, anotherkey=value]
> stuff
> \stopuserdata
>
> Such syntactic sugar makes sweeter reading of the text, and makes
> clearer what is being done when nesting the macro.
for such Named environments there are probably other alternatives
(depending on what you need it for), like blocks
also, user dat picks up its content (they're buffers) so that would also
mean more nested buffers .. it's meant as a simple mechanism
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: \startuserdata syntax questions
2018-08-29 7:15 ` Hans Hagen
@ 2018-08-29 15:19 ` Wolfgang Schuster
2018-08-29 16:56 ` Rik Kabel
2018-08-29 17:29 ` Aditya Mahajan
0 siblings, 2 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2018-08-29 15:19 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hans Hagen schrieb am 29.08.18 um 09:15:
> On 8/28/2018 10:40 PM, Rik Kabel wrote:
>> Wolfgang, Hans, et al,
>>
>> The new \startuserdata macro looks very promising, and can simplify
>> some work I have in progress.
>>
>> The first question: the wiki example and the source use
>>
>> \userparameter{optionkey}
>> \userparameter{anotherkey}
>>
>> to retrieve the value of optionkey and anotherkey. Is there a way to
>> provide the key/value pairs in a manner that they can be retrieved
>> with the getparameters mechanism, as:
>>
>> \getrawparameters [XX] [optionkey=,anotherkey=,#1]
>>
>> This has the added advantage of allowing the setting of a default
>> value, as
>>
>> \getrawparameters [XX] [optionkey=2em,anotherkey=,#1]
>>
>> Or is there a reason not to use getparameters in this setting?
>
> hardly any of the core mechanisms in mkiv uses get(raw)parameters
>
> define a category and then clone it ...
\defineuserdata [rik] [name=Rik,alternative=rik]
\defineuserdataalternative [rik] [renderingsetup=userdata:rik]
\startsetups [userdata:rik]
\starttabulate[|l|p|]
\NC \userdataparameter{name} \NC \getuserdata \NC\NR
\stoptabulate
\stopsetups
\starttext
\startuserdata [rik]
\samplefile{greenfield}
\stopuserdata
\startuserdata [rik] [name=Greenfield]
\samplefile{greenfield}
\stopuserdata
\stoptext
> The second question: Is there the possibility to enhance the syntax so
> that one can write
>>
>> \startMyStuff [optionalkey=value, anotherkey=value]
>> stuff
>> \stopMyStuff
>>
>> instead of
>>
>> \startuserdata [MyStuff] [optionalkey=value, anotherkey=value]
>> stuff
>> \stopuserdata
I can generated environment commands but I haven’t done this at the
beginning because I prefer to pass the name of the environment as
argument because this allows me to check if the used instance exists.
>> Such syntactic sugar makes sweeter reading of the text, and makes
>> clearer what is being done when nesting the macro.
> for such Named environments there are probably other alternatives
> (depending on what you need it for), like blocks
>
> also, user dat picks up its content (they're buffers) so that would
> also mean more nested buffers .. it's meant as a simple mechanism
Yes, the environment is meant for short blocks of text (e.g. a
blockquote) where you have to set different texts (e.g. the name of a
author) for each use of the environment.
I thought about adding a switch to change between buffer mode and normal
start/stop commands which work like the startstop environment but it
wasn’t worth the effort.
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: \startuserdata syntax questions
2018-08-29 15:19 ` Wolfgang Schuster
@ 2018-08-29 16:56 ` Rik Kabel
2018-08-29 17:29 ` Aditya Mahajan
1 sibling, 0 replies; 5+ messages in thread
From: Rik Kabel @ 2018-08-29 16:56 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 8/29/2018 11:19, Wolfgang Schuster wrote:
>
>
> Hans Hagen schrieb am 29.08.18 um 09:15:
>> On 8/28/2018 10:40 PM, Rik Kabel wrote:
>>> Wolfgang, Hans, et al,
>>>
>>> The new \startuserdata macro looks very promising, and can simplify
>>> some work I have in progress.
>>>
>>> The first question: the wiki example and the source use
>>>
>>> \userparameter{optionkey}
>>> \userparameter{anotherkey}
>>>
>>> to retrieve the value of optionkey and anotherkey. Is there a way to
>>> provide the key/value pairs in a manner that they can be retrieved
>>> with the getparameters mechanism, as:
>>>
>>> \getrawparameters [XX] [optionkey=,anotherkey=,#1]
>>>
>>> This has the added advantage of allowing the setting of a default
>>> value, as
>>>
>>> \getrawparameters [XX] [optionkey=2em,anotherkey=,#1]
>>>
>>> Or is there a reason not to use getparameters in this setting?
>>
>> hardly any of the core mechanisms in mkiv uses get(raw)parameters
>>
>> define a category and then clone it ...
>
> \defineuserdata [rik] [name=Rik,alternative=rik]
>
> \defineuserdataalternative [rik] [renderingsetup=userdata:rik]
>
> \startsetups [userdata:rik]
> \starttabulate[|l|p|]
> \NC \userdataparameter{name} \NC \getuserdata \NC\NR
> \stoptabulate
> \stopsetups
>
> \starttext
>
> \startuserdata [rik]
> \samplefile{greenfield}
> \stopuserdata
>
> \startuserdata [rik] [name=Greenfield]
> \samplefile{greenfield}
> \stopuserdata
>
> \stoptext
>
Ahh, that does nicely to set defaults. Thank you.
>> The second question: Is there the possibility to enhance the syntax
>> so that one can write
>>>
>>> \startMyStuff [optionalkey=value, anotherkey=value]
>>> stuff
>>> \stopMyStuff
>>>
>>> instead of
>>>
>>> \startuserdata [MyStuff] [optionalkey=value, anotherkey=value]
>>> stuff
>>> \stopuserdata
>
> I can generated environment commands but I haven’t done this at the
> beginning because I prefer to pass the name of the environment as
> argument because this allows me to check if the used instance exists.
>
>>> Such syntactic sugar makes sweeter reading of the text, and makes
>>> clearer what is being done when nesting the macro.
>> for such Named environments there are probably other alternatives
>> (depending on what you need it for), like blocks
>>
>> also, user dat picks up its content (they're buffers) so that would
>> also mean more nested buffers .. it's meant as a simple mechanism
>
> Yes, the environment is meant for short blocks of text (e.g. a
> blockquote) where you have to set different texts (e.g. the name of a
> author) for each use of the environment.
>
> I thought about adding a switch to change between buffer mode and
> normal start/stop commands which work like the startstop environment
> but it wasn’t worth the effort.
>
Very well. It is what it is. The ability to set defaults goes a long way.
> Wolfgang
>
--
Rik
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: \startuserdata syntax questions
2018-08-29 15:19 ` Wolfgang Schuster
2018-08-29 16:56 ` Rik Kabel
@ 2018-08-29 17:29 ` Aditya Mahajan
1 sibling, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2018-08-29 17:29 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]
On Wed, 29 Aug 2018, Wolfgang Schuster wrote:
>> The second question: Is there the possibility to enhance the syntax so
>> that one can write
>>>
>>> \startMyStuff [optionalkey=value, anotherkey=value]
>>> stuff
>>> \stopMyStuff
>>>
>>> instead of
>>>
>>> \startuserdata [MyStuff] [optionalkey=value, anotherkey=value]
>>> stuff
>>> \stopuserdata
>
> I can generated environment commands but I haven’t done this at the
> beginning because I prefer to pass the name of the environment as
> argument because this allows me to check if the used instance exists.
Perhaps adding a `command=yes` key, which can be set to `no` by default.
Aditya
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-29 17:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28 20:40 \startuserdata syntax questions Rik Kabel
2018-08-29 7:15 ` Hans Hagen
2018-08-29 15:19 ` Wolfgang Schuster
2018-08-29 16:56 ` Rik Kabel
2018-08-29 17:29 ` Aditya Mahajan
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).