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