Is there a good way to store the key of an unknown
key-val in expl3? I can get \l_keys_key_tl
, but it gets overwritten before it's expanded. I suppose I need to expand it when I store it, but I'm having trouble making that work, especially because I don't want to expand the value yet. Also, I expect to get multiple unknowns, and the order is important, so l3prop isn't appropriate.
Here's a MWE:
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\seq_new:N \l_mymod_seq
\keys_define:nn { mymod } {
a .tl_set:N = \tmpa, % some keys are treated special
% others are grouped with unknowns
b .code:n = \seq_put_right:Nn \l_mymod_seq {(B~is~\f{#1})},
unknown .code:n = \seq_put_right:Nn \l_mymod_seq {(unknown~{\l_keys_key_tl}~is~\f{#1})},
}
\newcommand\setkeys[1]{\keys_set:nn { mymod } { #1 }}
\newcommand\printkeys{\seq_use:Nn \l_mymod_seq {,~}}
\ExplSyntaxOff
\begin{document}
\setkeys{a=5,b=6,c=7,d=8}
\newcommand\f[1]{\textbf{#1}}
A is \f{\tmpa}
\renewcommand\f[1]{\textit{#1}}
\printkeys
\end{document}