I have a token list that includes (at least) one non-expandable command (defined by \NewDocumentCommand) and want to write the result to a log file (lets assume the critical command generates character tokens only). Is there any way to enforce the execution to get the result (before shipout)?
Edit
@jlab asked for a MnWE. Well, since I don't know a solution I can only provide code that obviously does not work.
\documentclass{scrartcl} \NewDocumentCommand{\foo}{m}{#1xyz} % Well, the original is more complicated and not by me \begin{document} \newwrite\myfile \immediate\openout\myfile=bar.txt \immediate\write\myfile{\foo{abc}} % I get "\foo {abc}", but want "abcxyz" \end{document}
tex.sprintetc.),\protectedso they simply expanded to characters). What is your actual use case here?