5

The l3keys documentation says:

.cs_set:Np ⟨key⟩ .cs_set:Np = ⟨control sequence⟩ ⟨arg. spec.⟩

Defines ⟨key⟩ to set ⟨control sequence⟩ to have ⟨arg. spec.⟩ and replacement text ⟨value⟩.

But I don't understand how this .cs_set:Np key property can be used. Indeed, in the following MCE:

  • key-one .code:n = \__mymodule_ditto:n #1 gives the expect result,
  • key-two .cs_set:Np = \__mymodule_ditto:n #1 gives an empty result.

Could you explain how to use the .cs_set:Np key property?

\documentclass{article}
\begin{document}
\ExplSyntaxOn
\keys_define:nn { mymodule }
{
  key-one .code:n    = \__mymodule_ditto:n #1 ,
  key-two .cs_set:Np = \__mymodule_ditto:n #1
}
\cs_set:Npn \__mymodule_ditto:n #1
  {
    #1
  }
\begin{enumerate}
\item \keys_set:nn { mymodule } { key-one = { Once~ upon~ a~ time,~ ... } }
\item \keys_set:nn { mymodule } { key-two = { Once~ upon~ a~ time,~ ... } }
\end{enumerate}
\ExplSyntaxOff
\end{document}

enter image description here

1 Answer 1

7

The key defines/redefines a command:

\documentclass{article}
\begin{document}
\ExplSyntaxOn
\keys_define:nn { mymodule } { 
  key-two .cs_set:Np = \__mymodule_ditto:nn #1 #2
 } 

\keys_set:nn { mymodule } { key-two = { Once~ upon~ a~ time,~ #1,~#2 
    ... } } 

\__mymodule_ditto:nn{hallo}{world}\par

\keys_set:nn { mymodule } { key-two = { #1!!!} }

\__mymodule_ditto:nn{hallo}{world}

\ExplSyntaxOff
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .