0

From the documentation,

⟨key⟩ .inherit:n = {⟨parents⟩}
Specifies that the ⟨key⟩ path should inherit the keys listed as ⟨parents⟩.

Because may parents are collected in \l_MY_parents_clist, I would benefit from

⟨key⟩ .inherit:V = \l_MY_parents_clist,

Unfortunately, the .inherit:V key variant does not exist, what can I do instead?

Below is a working code that uses an auxiliary function to create a keyval list from scratch and an auxiliary variable to store it. Isn't there something more efficient?

% !TeX program = lualatex
\documentclass{article}
\begin{document}
\noindent
\ExplSyntaxOn
\clist_set:Nn \l_tmpa_clist { parent, grand_parent }
\cs_set:Npn \MY_helper:Nn #1 #2 {
  \tl_put_right:Nn #1 {
    child .inherit:n = { #2 },
  }
}
\tl_clear:N \l_tmpa_tl
\exp_args:NNV
\MY_helper:Nn \l_tmpa_tl \l_tmpa_clist
\exp_args:NnV 
\keys_define:nn { } \l_tmpa_tl

TESTING:\ \keys_define:nn { parent } { test .code:n = TEST: #1\, } \keys_set:nn { child } { test = blah, } \keys_define:nn { grand_parent } { grand-test .code:n = GRAND-TEST: #1\, } \keys_set:nn { child } { grand-test = blah, } \end{document}

  • Although key properties have expl3-like signatures, they have to be created internally a bit differently (as keyvals need delimited macros). As such, there's no interface to add this, although I can look at including in the next expl3 release. – Joseph Wright Mar 07 '22 at 12:02

1 Answers1

1

You could structure it more like

\documentclass{article}
\begin{document}

\ExplSyntaxOn \clist_set:Nn \l_tmpa_clist { parent, grand_parent }

\cs_set:Npn \MY_helper:nnn #1 #2 #3 { \keys_define:nn { #1 } {#2 .inherit:n = { #3 }} }

\cs_generate_variant:Nn \MY_helper:nnn {nnV}

\MY_helper:nnV {} {child} \l_tmpa_clist

TESTING:\ \keys_define:nn { parent } { test .code:n = TEST: #1\, } \keys_set:nn { child } { test = blah, } \keys_define:nn { grand_parent } { grand-test .code:n = GRAND-TEST: #1\, } \keys_set:nn { child } { grand-test = blah, } \end{document}

David Carlisle
  • 757,742