I would like to send a serie of tikz keys to a tikz path with the pgfkeys interface. I succeeded with the following code but is there a simpler way to do that ? Can I do the same thing with something like \draw[\prop] ... ? Actually I would like to avoid the scope environment.
\documentclass[a4paper]{article}
\usepackage{tikz}
\pgfkeys{
/test/pgfkeys/.cd,
nom/.store in = \nom,
prenom/.store in = \prenom,
prop/.store in = \prop
%prop/.code = \tikzset{#1}
}
\newcommand{\qui}[1][]{
\pgfkeys{/test/pgfkeys/.cd,#1}
I am \prenom{} \nom{} !
\begin{tikzpicture}
\begin{scope}
\tikzset{\prop}
\draw (0,0) -- (1,0);
\end{scope}
\end{tikzpicture}
}
\begin{document}
\qui[prenom = toto, nom = titi, prop = {very thick, color = red!80, -stealth}]
\end{document}
EDIT :
New code using Andrew Stacey answer. This code works now :
\documentclass[a4paper]{article}
\usepackage{tikz}
\pgfkeys{
/tikz/.cd,
execute style/.style = {#1},
execute macro/.style = {execute style/.expand once=#1},
/test/pgf/.cd,
nom/.store in = \nom,
prenom/.store in = \prenom,
prop/.store in = \prop
}
\newcommand{\qui}[1][]{
\pgfkeys{/test/pgf/.cd,#1}
I am \prenom{} \nom{} !
\begin{tikzpicture}
\draw[execute macro = \prop] (0,0) -- (1,0);
\end{tikzpicture}
}
\begin{document}
\qui[prenom = toto, nom = titi, prop = {very thick, color = red!80, -stealth}]
\end{document}
Here is the output :

\begin{tikzpicture}toend{tikzpicture}with\tikz \draw \expandafter[\prop] (0,0) -- (1,0);. Does that do what you want? – Jake Dec 05 '12 at 16:25