I would like to save a command with its two arguments in an external file. I use LaTeX3 (I am learning LaTeX3). Here is a minimal file:
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand{\saveDataToFile}{}
{
\iow_new:N \g_data_stream
\iow_open:Nn \g_data_stream { data-file.tex }
\exp_args:NNx \iow_now:Nn \g_data_stream
{
\exp_not:N \myCommand
{\exp_not:V \AA}
{\exp_not:V \BB}
}
\iow_close:N \g_data_stream
}
\ExplSyntaxOff
\begin{document}
\def\AA{My first argument}
\def\BB{My \emph{second} argument}
\saveDataToFile
\end{document}
In the eternal file data-file.tex I get
\myCommand {My first argument}{My \emph {second} argument}
which is close to what I want. But I would like to get rid of the extra space between \myCommand and the first argument, as well as the one between \emph and its argument. At least I would like to understand why such spaces appear (fortunately they do not prevent my code to work). Thanks
\myCommandis easy as you have full control there (use\token_to_str:Ninstead of\exp_not:N), but whatever is in\AAand\BBis already tokenised. There might be solutions, but they are not fast, and it's simply not worth it, as TeX ignores these spaces anyway during tokenisation.\exp_args:NNx \iow_now:Nnyou should use\iow_now:Ne.