This question has the following form: 'I know how to do X using Y. I can also do X using Z but not so elegantly as using Y. Can I do X using Z in the same way that I can do X using Y, for a more elegant Z-based solution?'
In this case, Y is TikZ/PGF and Z is expl3 syntax.
Using PGF keys, I can define and/or set a group of keys under a particular path without having to repeatedly specify the path. One way to do this is to use .cd to change the current path until further notice.
<path specification>/.cd, <definition of key 1>, <definition of key 2>, <set key 1>, <set key 2>, This makes it possible to provide an easy interface for setting a group of keys.
<group key name>/.code={ \tikzset{% <path specification>/.cd, #1 } }, Does the expl3 syntax offer an equivalent of .cd and, if so, what is it?
I can emulate the effect I want by using distinct \keys_define:nn commands for each relevant path, but this seems a somewhat inelegant solution so I'm wondering if I'm missing a more straightforward facility.
MWE showing TikZ case and Expl3 emulation:
\documentclass{article} \usepackage{tikz,xparse} \tikzset{% my keys/.code={ \tikzset{% /top/middle/bottom/.cd, #1 } }, /top/middle/bottom/.cd, key 1/.store in=\keyone, key 2/.store in=\keytwo, } \ExplSyntaxOn \keys_define:nn { top / middle / bottom } { key~1 .tl_set:N = \l_module_keyone_tl, key~2 .tl_set:N = \l_module_keytwo_tl, } \keys_define:nn { top } { my~keys .code:n = { \keys_set:nn { top / middle / bottom } { #1 } } } \NewDocumentCommand \topset { m } { \keys_set:nn { top } { #1 } } \NewDocumentCommand \showkeyone {} { \l_module_keyone_tl } \NewDocumentCommand \showkeytwo {} { \l_module_keytwo_tl } \ExplSyntaxOff \begin{document} \tikzset{% my keys={% key 1=Arrangement, key 2=Ascension, }, }% \topset{% my keys={% key 1=Arrangement, key 2=Ascension, }, }% TikZ/PGF: \keyone{} \keytwo Expl3: \showkeyone{} \showkeytwo \end{document} Output:
