[NTG-context] \definenamespace and the list option

2017-05-15 Thread Henri Menke
Dear list,

Motivated by this question on TeX.SX
https://tex.stackexchange.com/questions/369778
I took a look at the \definenamespace mechanism in ConTeXt.

It seems that it permits a syntax like

\define[...,...][...=...,...=...]

where you can provide a list of instances to define in the first
argument.  I don't know about any \define command in ConTeXt that would
permit that and the implementation in mult-aux.mkiv does not even
support that properly.  My approach would actually be to remove the
list option from \definenamespace completely.

Cheers, Henri
___
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
___

Re: [NTG-context] \definenamespace

2010-11-19 Thread Hans Hagen

On 19-11-2010 9:12, Vianney le Clément wrote:


   {\edef#3{1}%<-- argument of \docommand


indeed



PS: just to learn some TeXnical details, could someone explain what
the \unexpanded is supposed to do here?


it is etex's \protected prefix and not to be confused with the etex 
primitive \unexpanded


it happens that before there was etex we already had \unexpanded but 
implemented differently


\unexpanded in context defined a macro as not expandable in some cases, 
like within an \edef


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Vianney le Clément
Could there also be a bug in the \setup command definition:

\unexpanded\def\doinstallsetuphandler#1#2#3#4#5%
  {\unexpanded\def#2{\dodoubleempty#4}%
   \newtoks#5%
   \def#4[##1][##2]%
 {\ifsecondargument
\def\docommand1% we will have a simple one as well
  {\edef#3{##1}%
   \getparameters[#1#3][##2]%
   \the#5}%
\processcommalist[##1]\docommand
  \else
\let#3\empty
\getparameters[#1][##1]%
\the#5%
  \fi}}

I would expect (difference is on the seventh line):

\unexpanded\def\doinstallsetuphandler#1#2#3#4#5%
  {\unexpanded\def#2{\dodoubleempty#4}%
   \newtoks#5%
   \def#4[##1][##2]%
 {\ifsecondargument
\def\docommand1% we will have a simple one as well
  {\edef#3{1}%<-- argument of \docommand
instead of the comma-separated list
   \getparameters[#1#3][##2]%
   \the#5}%
\processcommalist[##1]\docommand
  \else
\let#3\empty
\getparameters[#1][##1]%
\the#5%
  \fi}}

Vianney

PS: just to learn some TeXnical details, could someone explain what
the \unexpanded is supposed to do here?
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Wolfgang Schuster

Am 19.11.2010 um 18:56 schrieb Hans Hagen:

> or maybe:
> 
> \unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
>  {\unexpanded\def#2{\dotripleempty#5}%
>   \newtoks#6%
>   \newtoks#7%
>   \def#5[##1][##2][##3]%
> {\edef#4{##1}%
>  \the#6% predefine
>  \ifthirdargument
> \getparameters[#1#4][\s!parent=#1##2,##3]%
>  \else\ifsecondargument
> \getparameters[#1#4][\s!parent=#3,##2]
>  \fi\fi
>  \the#7}}

No, because you need \doifassignment. Your code allows only

   \define...[new][old][..=..]

and

   \define...[new][..=..]

but it’s not possible to write

   \define...[new][old]

because „new“ won’t use „old“ as parent with this defintion.

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Hans Hagen

On 19-11-2010 7:05, Aditya Mahajan wrote:


\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
{\unexpanded\def#2{\dotripleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2][##3]%
{\edef#4{##1}%
\the#6% predefine
\ifthirdargument
\getparameters[#1#4][\s!parent=#1##2,##3]%
\else\ifsecondargument
\getparameters[#1#4][\s!parent=#3,##2]
\fi\fi
\the#7}}


That one will be slightly faster, I think.


indeed, not that there is much defining going on but every millisecond 
counts as they add up


Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Aditya Mahajan

On Fri, 19 Nov 2010, Hans Hagen wrote:


On 19-11-2010 6:35, Wolfgang Schuster wrote:


Am 19.11.2010 um 02:05 schrieb Aditya Mahajan:


I am not sure how this is supposed to work. Consider this example:

[...]


There is a bug in the code for the \define... commands, you need this 
definition for \doinstalldefinehandler:


\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
   {\unexpanded\def#2{\dodoubleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2]%
  {\edef#4{##1}%
   \the#6% predefine
   \ifsecondargument
 \doifassignmentelse{##2}
   {\getparameters[#1#4][\s!parent=#3,##2]}
   {\getparameters[#1#4][\s!parent=#1##2]}%
   \fi
   \the#7}}

To have three arguments for the \define... commands like \defineenumeration 
change the above command to:


\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
   {\unexpanded\def#2{\dotripleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2][##3]%
  {\edef#4{##1}%
   \the#6% predefine
   \ifsecondargument
 \doifassignmentelse{##2}
   {\getparameters[#1#4][\s!parent=#3,##2]}
   {\getparameters[#1#4][\s!parent=#1##2,##3]}%
   \fi
   \the#7}}


or maybe:

\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
 {\unexpanded\def#2{\dotripleempty#5}%
  \newtoks#6%
  \newtoks#7%
  \def#5[##1][##2][##3]%
{\edef#4{##1}%
 \the#6% predefine
 \ifthirdargument
\getparameters[#1#4][\s!parent=#1##2,##3]%
 \else\ifsecondargument
\getparameters[#1#4][\s!parent=#3,##2]
 \fi\fi
 \the#7}}


That one will be slightly faster, I think.

Aditya
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Hans Hagen

On 19-11-2010 6:35, Wolfgang Schuster wrote:


Am 19.11.2010 um 02:05 schrieb Aditya Mahajan:


I am not sure how this is supposed to work. Consider this example:

[...]


There is a bug in the code for the \define... commands, you need this 
definition for \doinstalldefinehandler:

\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
   {\unexpanded\def#2{\dodoubleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2]%
  {\edef#4{##1}%
   \the#6% predefine
   \ifsecondargument
 \doifassignmentelse{##2}
   {\getparameters[#1#4][\s!parent=#3,##2]}
   {\getparameters[#1#4][\s!parent=#1##2]}%
   \fi
   \the#7}}

To have three arguments for the \define... commands like \defineenumeration 
change the above command to:

\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
   {\unexpanded\def#2{\dotripleempty#5}%
\newtoks#6%
\newtoks#7%
\def#5[##1][##2][##3]%
  {\edef#4{##1}%
   \the#6% predefine
   \ifsecondargument
 \doifassignmentelse{##2}
   {\getparameters[#1#4][\s!parent=#3,##2]}
   {\getparameters[#1#4][\s!parent=#1##2,##3]}%
   \fi
   \the#7}}


or maybe:

\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
  {\unexpanded\def#2{\dotripleempty#5}%
   \newtoks#6%
   \newtoks#7%
   \def#5[##1][##2][##3]%
 {\edef#4{##1}%
  \the#6% predefine
  \ifthirdargument
 \getparameters[#1#4][\s!parent=#1##2,##3]%
  \else\ifsecondargument
 \getparameters[#1#4][\s!parent=#3,##2]
  \fi\fi
  \the#7}}



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace

2010-11-19 Thread Wolfgang Schuster

Am 19.11.2010 um 02:05 schrieb Aditya Mahajan:

> I am not sure how this is supposed to work. Consider this example:
> 
> [...]

There is a bug in the code for the \define... commands, you need this 
definition for \doinstalldefinehandler:

\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
  {\unexpanded\def#2{\dodoubleempty#5}%
   \newtoks#6%
   \newtoks#7%
   \def#5[##1][##2]%
 {\edef#4{##1}%
  \the#6% predefine
  \ifsecondargument
\doifassignmentelse{##2}
  {\getparameters[#1#4][\s!parent=#3,##2]}
  {\getparameters[#1#4][\s!parent=#1##2]}%
  \fi
  \the#7}}

To have three arguments for the \define... commands like \defineenumeration 
change the above command to:

\unprotected\unexpanded\def\doinstalldefinehandler#1#2#3#4#5#6#7%
  {\unexpanded\def#2{\dotripleempty#5}%
   \newtoks#6%
   \newtoks#7%
   \def#5[##1][##2][##3]%
 {\edef#4{##1}%
  \the#6% predefine
  \ifsecondargument
\doifassignmentelse{##2}
  {\getparameters[#1#4][\s!parent=#3,##2]}
  {\getparameters[#1#4][\s!parent=#1##2,##3]}%
  \fi
  \the#7}}

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-18 Thread Aditya Mahajan

On Thu, 18 Nov 2010, Wolfgang Schuster wrote:


\parameter use the value from \current while \namedparameter
has two argument where the first argument is the name of a command or 
environment
created with \define. \detokenized... is important when you pass values
from tex to lua and the value contains a tex command, e.g. \thinspace which
is normally expanded in this case.


Thanks.


The command key has like the setup key the two values yes and list,
with „command=yes“ you can write

 \define[two][one]


I did not know that cloning was possible. The \defineenumeration commands 
allows for

\defineenumeration[new][old][..=..]

This clones a selected options from old to new (using copyparamters) and then 
sets the values of the third arguments.


\copyparameters is only used for code which doesn’t use the new parameter 
command
with the parent handling but this method isn’t necessary in mkiv


I am not sure how this is supposed to work. Consider this example:

\definenamespace
  [one]
  [type=module,
   name=one,
   setup=yes,
   parent=]

\definenamespace
  [two]
  [type=module,
   name=two,
   command=yes,
   parent=one]

\setupone[whatever=one]

\definetwo[test1]
\definetwo[test2][something=two]
\definetwo[test3][test2]

\starttext
\startlines

\namedtwoparameter{test1}{whatever}<<
\namedtwoparameter{test2}{whatever}<<
\namedtwoparameter{test2}{something}<<
\namedtwoparameter{test3}{something}<<

\stoplines
\stoptext


This gives


one<<
<<
two<<
<<


Why is the value of whatever not set for test2?

Why is the value of something not set for test3?


Would it make sense to add support for

\define[two,three][one][..=..]?


You can redefine \define or leave it out from \definenamespace.


I meant that why not \define as follows:

\def\define%
  {\dotripleargument\dodefine}

\def\dodefinename[#1][#2][#3]%
 {\doifassignmentelse{#2}
   {\getparameters[#1][parent=, #2]}
   {\getparameters[#1][parent=#2, #3]}}


What’s also is to write \define[clone][parent=\parent].


For parent it’s the best to give as argument always the same value
as you defined for the namespace, e.g. for the fancybreak module
one should write „parent=fancybreak“.


I thought that you have to write "parent=\fancybreak".


That happens in the backend hidden from the user/author.


Ah, I see. Thanks.

Aditya___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-18 Thread Wolfgang Schuster

Am 18.11.2010 um 22:20 schrieb Aditya Mahajan:

> Just a few points:
> 
>> The key “command“ creates a bunch of macros, besides the „\define...“
>> commands to create new environment and commands with your code it creates
>> the following macros to access the values from your setup commands:
>> 
>>  - \parameter
>>  - \namedparameter
>>  - \detokenizedparameter
> 
> In order to use these commads, you must set a value for \current. For 
> example, if you have
> 
> \define[one][width=10cm]
> 
> In order to access the value of width of "one", you must do:
> 
> \def\current{one}
> 
> \parameter{width}
> 
> (I do not remember the distinction between \parameter,
> \namedparamter, and \detokenizedparameters).

\parameter use the value from \current while \namedparameter
has two argument where the first argument is the name of a command or 
environment
created with \define. \detokenized... is important when you pass values
from tex to lua and the value contains a tex command, e.g. \thinspace which
is normally expanded in this case.

> 
>> The command key has like the setup key the two values yes and list,
>> with „command=yes“ you can write
>> 
>>  \define[two][one]
> 
> I did not know that cloning was possible. The \defineenumeration commands 
> allows for
> 
> \defineenumeration[new][old][..=..]
> 
> This clones a selected options from old to new (using copyparamters) and then 
> sets the values of the third arguments.

\copyparameters is only used for code which doesn’t use the new parameter 
command
with the parent handling but this method isn’t necessary in mkiv

> Would it make sense to add support for
> 
> \define[two,three][one][..=..]?

You can redefine \define or leave it out from \definenamespace.
What’s also is to write \define[clone][parent=\parent].

>> For parent it’s the best to give as argument always the same value
>> as you defined for the namespace, e.g. for the fancybreak module
>> one should write „parent=fancybreak“.
> 
> I thought that you have to write "parent=\fancybreak".

That happens in the backend hidden from the user/author.

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-18 Thread Aditya Mahajan

On Wed, 17 Nov 2010, Wolfgang Schuster wrote:


I’m not Aditya but i hope you will also accept my explanation.


This is a much better explanation than I could have written. Just a few 
points:



I will start with the first argument and the „type“ key, e.g.

  \definenamespace
[fancybreak]
[type=module]

will produce the namespace „fancybreak“ with the short form
(the name itself has the same length but for TeX it’s only a single
tokens instead of many with the ... form) \fancybreak.

The is currently only one argument with the name „module“ but
another one like „core“ or „base“ can appear in the future but
this will be then reserved for Hans to replace the \definesystemvariable
command from the core to produce a namespace in the form „@@xx“.

When you define a namespace you should use three or more letters
because two letter namespaces are reserved for Hans itself,
e.g. is already used by the database module.


The second key you need is „name“ because it’s argument is used
when all the „\setup...“ and „\define...“ commands are created.


The key „style“ creates the command „\dosetattributes“ which
takes two arguments where the first is to change the style (font)
in your new created command and the second for the color.

The setup

  \definenamespace
[fancybreak]
[type=module,
 name=fancybreak,
 style=yes]

creates the command \dosetfancybreakattributes which can be used like
\dosetfancybreakattributes\c!style\c!color and will take the „style“
and „color“ argument from the \setupfancybreak command.


The setup key creates the command „\setup“ where you can control
whether the commands accepts a list of environment in the two argument
form or only a single environment, e.g. „setup=yes“ let you write

  \setupfancybreak[one][..,..=..,..]

and

  \setupfancybreak[..,..=..,..]

while „setup=list“ let you use

  \setupfancybreak[one,two][..,..=..,..]

and

  \setupfancybreak[..,..=..,..]


The key “command“ creates a bunch of macros, besides the „\define...“
commands to create new environment and commands with your code it creates
the following macros to access the values from your setup commands:

  - \parameter
  - \namedparameter
  - \detokenizedparameter


In order to use these commads, you must set a value for \current. 
For example, if you have


\define[one][width=10cm]

In order to access the value of width of "one", you must do:

\def\current{one}

\parameter{width}

(I do not remember the distinction between \parameter,
\namedparamter, and \detokenizedparameters).


The command key has like the setup key the two values yes and list,
with „command=yes“ you can write

  \define[one][..,..=..,..]

or (clone a setup like \definehead[mysection][section])

  \define[two][one]

while „command=list“ allows

   \define[one,two][..,..=..,..]

or

  \define[two,three][one]



I did not know that cloning was possible. The \defineenumeration commands 
allows for


\defineenumeration[new][old][..=..]

This clones a selected options from old to new (using copyparamters) and 
then sets the values of the third arguments.


Would it make sense to add support for

\define[two,three][one][..=..]?



For parent it’s the best to give as argument always the same value
as you defined for the namespace, e.g. for the fancybreak module
one should write „parent=fancybreak“.


I thought that you have to write "parent=\fancybreak".

Aditya___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-18 Thread Philipp Gesang
On 2010-11-18 <04:56:27>, Wolfgang Schuster wrote:
> 
> Am 18.11.2010 um 01:36 schrieb Philipp Gesang:
> 
> > Hi Wolfgang,
> > 
> > of course you are always welcome to deliver this kind of
> > thorough discussion! The wiki is grateful …
> > 
> > Just two keys remain unexplained: “version” and “comment”. I
> > guess they are not as critical but for sake of completeness and
> > out of curiosity I wouldn’t mind having my guesses refuted or
> > confirmed:
> > 
> > comment -  string: non-functional information that will be
> >   stored along with the namespace?? 
> > version -  number: versioning information?? Functionality not
> >   yet known.
> 
> Both keys contain only information about the purpose of the module
> and version number of the file like you have a the top of the file
> in the „%D \module[...]“ block. They are used when you print
> the table of namespaces with the \listnamespaces command.

Yet another place to stuff away meta-info … alright, it’s been
wikified. Thanks! Philipp


> 
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments


pgphjhfZ8xvhF.pgp
Description: PGP signature
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-17 Thread Wolfgang Schuster

Am 18.11.2010 um 01:36 schrieb Philipp Gesang:

> Hi Wolfgang,
> 
> of course you are always welcome to deliver this kind of
> thorough discussion! The wiki is grateful …
> 
> Just two keys remain unexplained: “version” and “comment”. I
> guess they are not as critical but for sake of completeness and
> out of curiosity I wouldn’t mind having my guesses refuted or
> confirmed:
> 
> comment -  string: non-functional information that will be
>   stored along with the namespace?? 
> version -  number: versioning information?? Functionality not
>   yet known.

Both keys contain only information about the purpose of the module
and version number of the file like you have a the top of the file
in the „%D \module[...]“ block. They are used when you print
the table of namespaces with the \listnamespaces command.

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace (was: The visual counter module)

2010-11-17 Thread Philipp Gesang
On 2010-11-17 <22:53:20>, Wolfgang Schuster wrote:
> 
> Am 17.11.2010 um 20:10 schrieb Philipp Gesang:
> 
> > Hi Aditya,
> > 
> > you seem to be familiar with some of the features of the new
> > namespace model that I was not able to infer from Wolfgang’s
> > code. Could you please comment on what the keys ‘setup’, ‘type’,
> > and ‘command’ in ‘\definenamespace’ accomplish?
> 
> I’m not Aditya but i hope you will also accept my explanation.

Hi Wolfgang,

of course you are always welcome to deliver this kind of
thorough discussion! The wiki is grateful …

Just two keys remain unexplained: “version” and “comment”. I
guess they are not as critical but for sake of completeness and
out of curiosity I wouldn’t mind having my guesses refuted or
confirmed:

comment -  string: non-functional information that will be
   stored along with the namespace?? 
version -  number: versioning information?? Functionality not
   yet known.

Many thanks anyways, rewriting some module code will make
christmas _much_ more interesting.

Philipp



> I will start with the first argument and the „type“ key, e.g.
> 
>\definenamespace
>  [fancybreak]
>  [type=module]
> 
> will produce the namespace „fancybreak“ with the short form
> (the name itself has the same length but for TeX it’s only a single
> tokens instead of many with the ... form) \fancybreak.
> 
> The is currently only one argument with the name „module“ but
> another one like „core“ or „base“ can appear in the future but
> this will be then reserved for Hans to replace the \definesystemvariable
> command from the core to produce a namespace in the form „@@xx“.
> 
> When you define a namespace you should use three or more letters
> because two letter namespaces are reserved for Hans itself,
> e.g. is already used by the database module.
> 
> 
> The second key you need is „name“ because it’s argument is used
> when all the „\setup...“ and „\define...“ commands are created.
> 
> 
> The key „style“ creates the command „\dosetattributes“ which
> takes two arguments where the first is to change the style (font)
> in your new created command and the second for the color.
> 
> The setup
> 
>\definenamespace
>  [fancybreak]
>  [type=module,
>   name=fancybreak,
>   style=yes]
> 
> creates the command \dosetfancybreakattributes which can be used like
> \dosetfancybreakattributes\c!style\c!color and will take the „style“
> and „color“ argument from the \setupfancybreak command.
> 
> 
> The setup key creates the command „\setup“ where you can control
> whether the commands accepts a list of environment in the two argument
> form or only a single environment, e.g. „setup=yes“ let you write
> 
>\setupfancybreak[one][..,..=..,..]
> 
> and
> 
>\setupfancybreak[..,..=..,..]
> 
> while „setup=list“ let you use
> 
>\setupfancybreak[one,two][..,..=..,..]
> 
> and
> 
>\setupfancybreak[..,..=..,..]
> 
> 
> The key “command“ creates a bunch of macros, besides the „\define...“
> commands to create new environment and commands with your code it creates
> the following macros to access the values from your setup commands:
> 
>- \parameter
>- \namedparameter
>- \detokenizedparameter
> 
> The command key has like the setup key the two values yes and list,
> with „command=yes“ you can write
> 
>\define[one][..,..=..,..]
> 
> or (clone a setup like \definehead[mysection][section])
> 
>\define[two][one]
> 
> while „command=list“ allows
> 
> \define[one,two][..,..=..,..]
> 
> or
> 
>\define[two,three][one]
> 
> 
> For parent it’s the best to give as argument always the same value
> as you defined for the namespace, e.g. for the fancybreak module
> one should write „parent=fancybreak“.
> 
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments


pgpkGPD7Yryyh.pgp
Description: PGP signature
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] \definenamespace (was: The visual counter module)

2010-11-17 Thread Wolfgang Schuster

Am 17.11.2010 um 20:10 schrieb Philipp Gesang:

> Hi Aditya,
> 
> you seem to be familiar with some of the features of the new
> namespace model that I was not able to infer from Wolfgang’s
> code. Could you please comment on what the keys ‘setup’, ‘type’,
> and ‘command’ in ‘\definenamespace’ accomplish?

I’m not Aditya but i hope you will also accept my explanation.

I will start with the first argument and the „type“ key, e.g.

   \definenamespace
 [fancybreak]
 [type=module]

will produce the namespace „fancybreak“ with the short form
(the name itself has the same length but for TeX it’s only a single
tokens instead of many with the ... form) \fancybreak.

The is currently only one argument with the name „module“ but
another one like „core“ or „base“ can appear in the future but
this will be then reserved for Hans to replace the \definesystemvariable
command from the core to produce a namespace in the form „@@xx“.

When you define a namespace you should use three or more letters
because two letter namespaces are reserved for Hans itself,
e.g. is already used by the database module.


The second key you need is „name“ because it’s argument is used
when all the „\setup...“ and „\define...“ commands are created.


The key „style“ creates the command „\dosetattributes“ which
takes two arguments where the first is to change the style (font)
in your new created command and the second for the color.

The setup

   \definenamespace
 [fancybreak]
 [type=module,
  name=fancybreak,
  style=yes]

creates the command \dosetfancybreakattributes which can be used like
\dosetfancybreakattributes\c!style\c!color and will take the „style“
and „color“ argument from the \setupfancybreak command.


The setup key creates the command „\setup“ where you can control
whether the commands accepts a list of environment in the two argument
form or only a single environment, e.g. „setup=yes“ let you write

   \setupfancybreak[one][..,..=..,..]

and

   \setupfancybreak[..,..=..,..]

while „setup=list“ let you use

   \setupfancybreak[one,two][..,..=..,..]

and

   \setupfancybreak[..,..=..,..]


The key “command“ creates a bunch of macros, besides the „\define...“
commands to create new environment and commands with your code it creates
the following macros to access the values from your setup commands:

   - \parameter
   - \namedparameter
   - \detokenizedparameter

The command key has like the setup key the two values yes and list,
with „command=yes“ you can write

   \define[one][..,..=..,..]

or (clone a setup like \definehead[mysection][section])

   \define[two][one]

while „command=list“ allows

\define[one,two][..,..=..,..]

or

   \define[two,three][one]


For parent it’s the best to give as argument always the same value
as you defined for the namespace, e.g. for the fancybreak module
one should write „parent=fancybreak“.

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace and module setup (was: Info about creating modules for beginners.)

2010-09-27 Thread Philipp Gesang
Hi all!


On 2010-09-25 <19:35:31>, Wolfgang Schuster wrote:
> 
> Am 25.09.2010 um 17:07 schrieb Philipp Gesang:
> 
> > Could you please explain what these other parameters do:
> >  style=yes,
> >  parent=fb
> > Also, what other values would the parameter ‘setup’ accept
> > besides ‘list’?
> 
> I’ll come back to this later.

Thanks in advance! For now there’s question marks galore on the
wiki page.

> +---++--+-+
> | Namespace | Name   | File | Description |
> +---+-+
> | fb| fancybreak | t-fancybreak | …   |
> +---++--+-+
> | … | …  | …| …   |

Hmm, i was thinking with a proper hyperlink the description would
be superfluous. But as there’s plenty of horizontal space in the
table that is not a problem. (After all, it’s not wikipedia; can’t
hurt to have some real information.)

I think it has to be up to the maintainer of module to register
it on the wiki. If the module is orphaned, a regular user should
be fine as well.

The wiki page is written with mkiv in mind only. Now, should the
module list extend to mkii style modules as well or should we
wait for the modules to be adapted by the maintainers? An extra
column indicating the version could do as well.


Regards, Philipp

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments


pgppWTM1l9Eb1.pgp
Description: PGP signature
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \definenamespace and module setup (was: Info about creating modules for beginners.)

2010-09-25 Thread Wolfgang Schuster

Am 25.09.2010 um 17:07 schrieb Philipp Gesang:

> Could you please explain what these other parameters do:
>  style=yes,
>  parent=fb
> Also, what other values would the parameter ‘setup’ accept
> besides ‘list’?

I’ll come back to this later.

>> BTW: The two letter namespaces are reserved for Hams and me but
>> you’re free to use longer ones (we should collect them on a page
>> at the wiki).
> 
> What information should go into this list? In my dummy, the
> namespace ‘testns’ declares the \defineXX and \setupXX commands,
> where XX=name and name=TEST. Thus if I am not mistaken, namespace
> clashes might occur both a) among the \…, and b) among the
> \setup…|\define… commands.

- namespace (the first argument of \definenamespace)
- the value for the “name” key
- the name of the module (e.g. t-fancybreak)
- a short description (e.g. fancybreak is a module to insert thought breaks)

+---++--+-+
| Namespace | Name   | File | Description |
+---+-+
| fb| fancybreak | t-fancybreak | …   |
+---++--+-+
| … | …  | …| …   |


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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] \definenamespace and module setup (was: Info about creating modules for beginners.)

2010-09-25 Thread Philipp Gesang
On 2010-09-23 <23:43:15>, Wolfgang Schuster wrote:
> These are namespaces but you don't need these constructs
> anymore in mkiv because there is now a \definenamespace command
> which takes care of this.

Hi Wolfgang,

following your fancybreak module I put together dummy module.

··8<·
\startmodule[test]

\unprotect

\startinterface all
  \setinterfacevariable {TEST} {TEST}
\stopinterface

\definenamespace[testns] [
  type=module,
  name=TEST,
  command=yes,
  setup=list,
]

\unexpanded\def\typetest{%
  \TESTparameter{teststyle}
  This is a test.%
}

\defineTEST[\v!TEST]

\setupTEST[
  teststyle=\sc
]

\protect
\endinput
··8<·

When called like:
  \usemodule[test] \starttext \typetest \stoptext
it works as expected.

Could you please explain what these other parameters do:
  style=yes,
  parent=fb
Also, what other values would the parameter ‘setup’ accept
besides ‘list’?


> BTW: The two letter namespaces are reserved for Hams and me but
> you’re free to use longer ones (we should collect them on a page
> at the wiki).

What information should go into this list? In my dummy, the
namespace ‘testns’ declares the \defineXX and \setupXX commands,
where XX=name and name=TEST. Thus if I am not mistaken, namespace
clashes might occur both a) among the \…, and b) among the
\setup…|\define… commands.

A table on the wiki will need at least three columns:

+---++-+
| Namespace | Setup  | Reserved for module |
+===++=+
| fb| fancybreak | Fancy Break |
+---++-+
| … | …  | …   |

Is this OK so far? Anything critical I missed?

Philipp


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments


pgppN1u82gG5F.pgp
Description: PGP signature
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___