5

I would like to understand if pgfkeys already offers a way (although undocumented, as far as I could see) to obtain a list of defined keys in a path, that is

\pgfkeys{
    /my/path/a = 1,
    /my/path/b/c = x,
}
\pgfkeysdefinedat{/my/path}{\thekeyslist} % missing macro
\thekeyslist      -> {a,b/c} % also acceptable with full path
% also acceptable -> {a,b}

(Ideally this would be packaged into a handler /.ls=\macro)

If this is not supported, I would like to know what's an idiomatic way of defining an handler that explicitly accumulates key names:

\pgfkeys{
    /my/path/a/.track={code of key a},
    /my/path/b/.track={code of key b},
    /my/path/.ls/.get=\thekeyslist,
}
\thekeyslist -> {a,b}

Where /.track={code} is equivalent to /.code={code} but with the side-effect of accumulating the key name into /.ls.

Otherwise, as last resort,

\pgfkeys{
    /my/path/a/.track={\thekeyslist}{code of key a},
    /my/path/b/.track={\thekeyslist}{code of key b},
}
\thekeyslist -> {/my/path/a,/my/path/b}

1 Answer 1

1

MarmotGhost has developed an experimental package for a question on topanswers.xyz/tex which can track the usage of, say, the .code handler.

Code

\documentclass{article}
\usepackage{pgf-pathology}
\usepackage[edges]{forest}
\pgfkeys{install tracking for={.code}}
\pgfkeys{
  /my/path/a/.code = #1,
  /my/path/b/c/.code = #1
}
\begin{document}
\FolderForestContent{/my/path/}
\bracketset{action character=@}
\begin{forest} for tree={grow'=0,folder}
@\ForestContent
\end{forest}
\end{document}

Output

enter image description here

You must log in to answer this question.

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