If I have previously set up a .meta:n key with
\keys_define:nn { module } { key .meta:n = { … } }
then it's easy to replace the key with new values by calling \kerys_define:nn with new meta options.
But what if I want to append to the current meta options for the key?
MWE
In this MWE, I want \setstyle to replace the meta options for style and \setstyle* to append to the meta options for style. How can I do this?
\documentclass{article}
\ExplSyntaxOn
\keys_define:nn { dcp }
{
keya .tl_set:N = \l__dcp_keya_tl ,
keyb .tl_set:N = \l__dcp_keyb_tl ,
keyc .tl_set:N = \l__dcp_keyc_tl ,
style .choice:
}
\NewDocumentCommand \setstyle { s m }
{
\bool_if:NTF #1
{
% how can I append to style?
}
{
% set style
\keys_define:nn { dcp } { style .meta:n = {#2} }
}
}
\NewDocumentCommand \showstyle { }
{
\keys_show:nn { dcp } { style }
}
\ExplSyntaxOff
\setstyle{keya=x,keyb=y}
\begin{document}
\showstyle
\setstyle{keya=x,keyb=yy}
\showstyle
\setstyle*{keyc=z}
\showstyle
\end{document}
\bool_if:NTF #1as a substitute for\IfBooleanTF{#1}when testing whether a function defined by\NewDocumentCommandis starred or unstarred? – User23456234 Dec 27 '23 at 05:36