Re: [NTG-context] Language dependency in environment-project file

2018-11-29 Thread Marco Patzer
On Thu, 29 Nov 2018 20:30:53 +0100
Wolfgang Schuster  wrote:

> Below is a improved version of the token method which works with the
> new beta.
> 
> \startenvironment [*]
> 
> \definetokenlist [english] % optional because \starttokenlist
> \definetokenlist [swedish] % checks if the token lists exists
> 
> \starttokenlist [english]
>    \setupitemgroup [itemize] [i]
> \stoptokenlist
> 
> \starttokenlist [swedish]
>    \setupitemgroup [itemize] [a]
> \stoptokenlist
> 
> \startsetups [document:start]
> 
> \doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
> 
>    \startmodeset
>      [*en] {\gettokenlist[english]}
>      [*sv] {\gettokenlist[swedish]}
>    \stopmodeset
> 
> \stopsetups
> 
> \stopenvironment

So that's basically a glorified \appendtoks … \to\… using the
usual context syntax? Very neat.

Marco
___
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] Language dependency in environment-project file

2018-11-29 Thread Wolfgang Schuster

Marco Patzer schrieb am 28.11.18 um 08:38:

On Tue, 27 Nov 2018 22:41:25 +0100
Wolfgang Schuster  wrote:


With named setups I need to specify a name for each occurrence and
gather them at the end. This is not as clean. Is it possible e.g. to
add something to an already existing setup instead of creating a new
one every time?

No, this is only possible with a token list.

Works perfectly.

Your first solution is technically better since it works even if the
language is changed mid document (something not used in this
project). However, the second solution is cleaner. I'll make up my mind.


Below is a improved version of the token method which works with the new 
beta.



\startenvironment [*]

\definetokenlist [english] % optional because \starttokenlist
\definetokenlist [swedish] % checks if the token lists exists

\starttokenlist [english]
  \setupitemgroup [itemize] [i]
\stoptokenlist

\starttokenlist [swedish]
  \setupitemgroup [itemize] [a]
\stoptokenlist

\startsetups [document:start]

\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}

  \startmodeset
    [*en] {\gettokenlist[english]}
    [*sv] {\gettokenlist[swedish]}
  \stopmodeset

\stopsetups

\stopenvironment


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
___

Re: [NTG-context] Language dependency in environment-project file

2018-11-28 Thread Wolfgang Schuster

Marco Patzer schrieb am 28.11.18 um 08:38:

On Tue, 27 Nov 2018 22:41:25 +0100
Wolfgang Schuster  wrote:


With named setups I need to specify a name for each occurrence and
gather them at the end. This is not as clean. Is it possible e.g. to
add something to an already existing setup instead of creating a new
one every time?

No, this is only possible with a token list.

Works perfectly.

Your first solution is technically better since it works even if the
language is changed mid document (something not used in this
project). However, the second solution is cleaner. I'll make up my mind.


The solution with the token list would be nicer if there where a way
to store the content in a similar fashion as buffers (which allow adding
content but this requires Lua) or setups.


\unprotect

\installnamespace {tokenlist}

\unexpanded\def\definetokenlist[#1]%
  {\expandafter\newtoks\csname\tokenlist#1\endcsname}

\unexpanded\def\starttokenlist[#1]#2\stoptokenlist
  {\ifcsname\tokenlist#1\endcsname \else
 \expandafter\newtoks\csname\tokenlist#1\endcsname
   \fi
   \expandafter\toksapp\csname\tokenlist#1\endcsname{#2}}

\def\gettokenlist[#1]%
  {\ifcsname\tokenlist#1\endcsname
 \expandafter\the\csname\tokenlist#1\endcsname
   \fi}

% \unexpanded\def\definetokenlist[#1]%
%   {\expandafter\let\csname\tokenlist#1\endcsname\empty}
%
% \unexpanded\def\starttokenlist[#1]#2\stoptokenlist
%   {\ifcsname\tokenlist#1\endcsname \else
%  \expandafter\let\csname\tokenlist#1\endcsname\empty
%    \fi
%    \expandafter\edef\csname\tokenlist#1\endcsname
% 
{\normalunexpanded\expandafter\expandafter\expandafter{\csname\tokenlist#1\endcsname}%

%   \normalunexpanded\expandafter{#2}}}
%
% \def\gettokenlist[#1]%
%   {\ifcsname\tokenlist#1\endcsname
%  \csname\tokenlist#1\endcsname
%    \fi}

\protect

\starttext

% \definetokenlist[test]

\starttokenlist[test]
a
\stoptokenlist

b

\starttokenlist[test]
c
\stoptokenlist

\gettokenlist[test]

\stoptext


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
___

Re: [NTG-context] Language dependency in environment-project file

2018-11-28 Thread Marco Patzer
On Wed, 28 Nov 2018 09:20:49 +0100
Hans Hagen  wrote:

> An alternative is to use system modes:
> 
> \mainlanguage[nl]
> 
> % \startmode[*en]
> % \setupitemize[n]
> % \stopmode
> 
> % \startmode[*nl]
> % \setupitemize[a]
> % \stopmode
> 
> % \startmode[*de]
> % \setupitemize[i]
> % \stopmode
> 
> \startmodeset
>  [*en] {
>  \setupitemize[n]
>  }
>  [*nl] {
>  \setupitemize[a]
>  }
>  [*de] {
>  \setupitemize[i]
>  }
> \stopmodeset

I do use modes and modesets in this project, but mainly in the
components. In the environment files it's a bit more tricky because
the language is unknown at this point and the system modes trigger
the wrong language. But Wolfgang already provided a solution, which
works fine.

Marco
___
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] Language dependency in environment-project file

2018-11-28 Thread Hans Hagen

On 11/27/2018 10:05 PM, Wolfgang Schuster wrote:

Marco Patzer schrieb am 27.11.18 um 21:56:

On Tue, 27 Nov 2018 21:41:52 +0100
Wolfgang Schuster  wrote:


A nudge in the right direction appreciated.

\appendtoks
    \mainlanguage[\documentvariable{language}]%
%\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}% 


\to \everysetupdocument

That's basically what I've done in my project file (te-proj.tex). At
least the code is supposed to do exactly that.

But even your solution doesn't work here. Did you try it in the
example project file?


\startenvironment [*]

\startsetups [itemgroup:en]
   \setupitemgroup [itemize] [i]
\stopsetups

\startsetups [itemgroup:sv]
   \setupitemgroup [itemize] [a]
\stopsetups

\setuplanguage
   [en]
   [setups=itemgroup:en]

\setuplanguage
   [sv]
   [setups=itemgroup:sv]

\appendtoks
\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
\to \everysetupdocument

\stopenvironment

An alternative is to use system modes:

\mainlanguage[nl]

% \startmode[*en]
% \setupitemize[n]
% \stopmode

% \startmode[*nl]
% \setupitemize[a]
% \stopmode

% \startmode[*de]
% \setupitemize[i]
% \stopmode

\startmodeset
[*en] {
\setupitemize[n]
}
[*nl] {
\setupitemize[a]
}
[*de] {
\setupitemize[i]
}
\stopmodeset

\starttext

\startitemize
\startitem test \stopitem
\startitem test \stopitem
\stopitemize

\stoptext

where modesets have a sort of special syntax (so probably only wolfgang 
and i know that this one exists),


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
___

Re: [NTG-context] Language dependency in environment-project file

2018-11-27 Thread Marco Patzer
On Tue, 27 Nov 2018 22:41:25 +0100
Wolfgang Schuster  wrote:

> > With named setups I need to specify a name for each occurrence and
> > gather them at the end. This is not as clean. Is it possible e.g. to
> > add something to an already existing setup instead of creating a new
> > one every time?  
> 
> No, this is only possible with a token list.

Works perfectly.

Your first solution is technically better since it works even if the
language is changed mid document (something not used in this
project). However, the second solution is cleaner. I'll make up my mind.

Thanks for the quick help.

Marco
___
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] Language dependency in environment-project file

2018-11-27 Thread Wolfgang Schuster



Marco Patzer schrieb am 27.11.18 um 22:23:

On Tue, 27 Nov 2018 22:05:27 +0100
Wolfgang Schuster  wrote:


But even your solution doesn't work here. Did you try it in the
example project file?

\startenvironment [*]

\startsetups [itemgroup:en]
    \setupitemgroup [itemize] [i]
\stopsetups

\startsetups [itemgroup:sv]
    \setupitemgroup [itemize] [a]
\stopsetups

\setuplanguage
    [en]
    [setups=itemgroup:en]

\setuplanguage
    [sv]
    [setups=itemgroup:sv]

\appendtoks
\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
\to \everysetupdocument

\stopenvironment

That works, thanks.

One more question: I used to use modes, since I could just

   \startmode[*en]
 …
   \stopmode

any number of times. There are many language dependent settings in
the environment files.

With named setups I need to specify a name for each occurrence and
gather them at the end. This is not as clean. Is it possible e.g. to
add something to an already existing setup instead of creating a new
one every time?


No, this is only possible with a token list.


\startenvironment [*]

\newtoks\EnglishSettings
\newtoks\SwedishSettings

\appendtoks
  \setupitemgroup [itemize] [i]
\to \EnglishSettings

\appendtoks
  \setupitemgroup [itemize] [a]
\to \SwedishSettings

% the order of the following settings is important because you have
% to set the language before you can make the language dependant
% mode setting

\appendtoks
\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
\to \everysetupdocument

\appendtoks
  \startmodeset
    [**en] {\flushtoks\EnglishSettings}
    [**sv] {\flushtoks\SwedishSettings}
  \stopmodeset
\to \everysetupdocument

\stopenvironment


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
___

Re: [NTG-context] Language dependency in environment-project file

2018-11-27 Thread Marco Patzer
On Tue, 27 Nov 2018 22:05:27 +0100
Wolfgang Schuster  wrote:

> > But even your solution doesn't work here. Did you try it in the
> > example project file?  
> 
> \startenvironment [*]
> 
> \startsetups [itemgroup:en]
>    \setupitemgroup [itemize] [i]
> \stopsetups
> 
> \startsetups [itemgroup:sv]
>    \setupitemgroup [itemize] [a]
> \stopsetups
> 
> \setuplanguage
>    [en]
>    [setups=itemgroup:en]
> 
> \setuplanguage
>    [sv]
>    [setups=itemgroup:sv]
> 
> \appendtoks
> \doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
> \to \everysetupdocument
> 
> \stopenvironment

That works, thanks.

One more question: I used to use modes, since I could just

  \startmode[*en]
…
  \stopmode

any number of times. There are many language dependent settings in
the environment files.

With named setups I need to specify a name for each occurrence and
gather them at the end. This is not as clean. Is it possible e.g. to
add something to an already existing setup instead of creating a new
one every time?

Marco
___
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] Language dependency in environment-project file

2018-11-27 Thread Wolfgang Schuster

Marco Patzer schrieb am 27.11.18 um 21:56:

On Tue, 27 Nov 2018 21:41:52 +0100
Wolfgang Schuster  wrote:


A nudge in the right direction appreciated.

\appendtoks
    \mainlanguage[\documentvariable{language}]%
%\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}%
\to \everysetupdocument

That's basically what I've done in my project file (te-proj.tex). At
least the code is supposed to do exactly that.

But even your solution doesn't work here. Did you try it in the
example project file?


\startenvironment [*]

\startsetups [itemgroup:en]
  \setupitemgroup [itemize] [i]
\stopsetups

\startsetups [itemgroup:sv]
  \setupitemgroup [itemize] [a]
\stopsetups

\setuplanguage
  [en]
  [setups=itemgroup:en]

\setuplanguage
  [sv]
  [setups=itemgroup:sv]

\appendtoks
\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}
\to \everysetupdocument

\stopenvironment

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
___

Re: [NTG-context] Language dependency in environment-project file

2018-11-27 Thread Marco Patzer
On Tue, 27 Nov 2018 21:41:52 +0100
Wolfgang Schuster  wrote:

> > A nudge in the right direction appreciated.  
> 
> \appendtoks
>    \mainlanguage[\documentvariable{language}]%
> %\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}%
> \to \everysetupdocument

That's basically what I've done in my project file (te-proj.tex). At
least the code is supposed to do exactly that.

But even your solution doesn't work here. Did you try it in the
example project file?

Marco
___
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] Language dependency in environment-project file

2018-11-27 Thread Wolfgang Schuster



Marco Patzer schrieb am 27.11.18 um 21:37:

Hi,

I do have a project structure with environment, project and component files.
The language of the individual documents is defined in the components using

   \setupdocument
 [language=sv]

The environment needs to adjust language-dependent settings. However, when the
environment file is read, the language is not specified, yet. In the past I've
used

   \appendtoks
 …
   \to\everystarttext

and I belive it has worked that way. In any case, right now it doesn't. I have
attached a not-so-minimal example project.

How to set this up correctly? If possible I'd like to keep the language in the
document settings as shown above.

A nudge in the right direction appreciated.


\appendtoks
  \mainlanguage[\documentvariable{language}]%
%\doifdocumentvariable{language}{\mainlanguage[\documentvariable{language}]}%
\to \everysetupdocument

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
___

[NTG-context] Language dependency in environment-project file

2018-11-27 Thread Marco Patzer
Hi,

I do have a project structure with environment, project and component files.
The language of the individual documents is defined in the components using

  \setupdocument
[language=sv]

The environment needs to adjust language-dependent settings. However, when the
environment file is read, the language is not specified, yet. In the past I've
used

  \appendtoks
…
  \to\everystarttext

and I belive it has worked that way. In any case, right now it doesn't. I have
attached a not-so-minimal example project.

How to set this up correctly? If possible I'd like to keep the language in the
document settings as shown above.

A nudge in the right direction appreciated.

Marco
<>
___
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
___