Dear List, I would like to ask how to define a command, \same, such that \same{\type{a b c}} produces the same result as its argument does \type{a b c} The naive way doesn't work because it makes all the spaces collapse: \define[1]\same{#1} I would also like to ask whether this could be achieved using the lua interface: \startluacode interfaces.definecommand { name="same", -- catcode/mode/arguments = ??? } Thanks in advance. Best, Sylvain
Sylvain Hubert schrieb am 08.11.2020 um 14:47:
Dear List,
I would like to ask how to define a command, \same, such that
\same{\type{a b c}}
produces the same result as its argument does
\type{a b c}
The naive way doesn't work because it makes all the spaces collapse:
\define[1]\same{#1}
\definetype [typeTEX] [option=tex] \starttext \type{\startsection[title=\tex{type}]} \typeTEX{\startsection[title=\tex{typeTEX}]} \stoptext Wolfgang
Hi Wolfgang, I'm sorry that the question was not clear enough. Let me ask in this way: how to define a \dorecurse, such that \dorecurse{10}{\type{a b c}} does not squash the spaces? Sylvain On Sun, 8 Nov 2020 at 15:03, Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Sylvain Hubert schrieb am 08.11.2020 um 14:47:
Dear List,
I would like to ask how to define a command, \same, such that
\same{\type{a b c}}
produces the same result as its argument does
\type{a b c}
The naive way doesn't work because it makes all the spaces collapse:
\define[1]\same{#1}
\definetype [typeTEX] [option=tex]
\starttext
\type{\startsection[title=\tex{type}]}
\typeTEX{\startsection[title=\tex{typeTEX}]}
\stoptext
Wolfgang
Sylvain Hubert schrieb am 08.11.2020 um 17:56:
Hi Wolfgang,
I'm sorry that the question was not clear enough. Let me ask in this way: how to define a \dorecurse, such that \dorecurse{10}{\type{a b c}} does not squash the spaces?
Verbatim in arguments of other commands is tricky because in case with \dorecurse the loop reads the content before it is passed to type, as a result of this process all spaces are collapsed. One way to work around this is to use a buffer for the content of the loop. \startbuffer[type] \type{a b c} \stopbuffer \starttext \dorecurse{10}{\inlinebuffer[type]\par} \stoptext Wolfgang
On Sun, 8 Nov 2020 at 18:27, Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote:
Sylvain Hubert schrieb am 08.11.2020 um 17:56:
Hi Wolfgang,
I'm sorry that the question was not clear enough. Let me ask in this way: how to define a \dorecurse, such that \dorecurse{10}{\type{a b c}} does not squash the spaces?
Verbatim in arguments of other commands is tricky because in case with \dorecurse the loop reads the content before it is passed to type, as a result of this process all spaces are collapsed.
One way to work around this is to use a buffer for the content of the loop.
\startbuffer[type] \type{a b c} \stopbuffer
\starttext \dorecurse{10}{\inlinebuffer[type]\par} \stoptext
Many thanks for the answer! It seems that the buffer mechanism is quite a powerful resort for the macro language. Sylvain
participants (2)
-
Sylvain Hubert
-
Wolfgang Schuster