This is a start for experimenting:
<assign|testxmacro2|<xmacro|var|<if|<equal|<get-arity|<quote-arg|var>>|2>|2 arguments|different from 2; value of first argument <arg|var|0>>>>
The get-arity
macro counts arguments. The quote-arg
macro is necessary to be able to use the argument, I do not know why, it was a suggestion by @mgubi when I got stuck with a macro of mine. Also I do not know how to type in <arg|var|0>
(if you try to type it in in an xmacro
context you will see what happens), so I copy-pasted it from the manual
On-topic, when macros become complicated they are best written in Scheme. For this macro I did not do any Scheme experiment on the translation of the constructs which you need (move
) but the translation from TeXmacs to TeXmacs Scheme is mechanical and I expect it to work nicely.