I have just managed to create my first command with pgfkeys. I defined a command \myset, whose purpose is to make (for example)
\myset[big]{abc}
correspond to
\bigl\{abc\bigr\}
Part of my goal was to do this in a way that would easily let me create variants later, using different delimiters; in particular, I didn't want my \pgfkeys code to refer to the \{ and \}.
Working from this TeX.SE thread and the relevant section of the PGF manual, here is what I came up with:
\documentclass{article}
\usepackage{pgfkeys}
\pgfkeys{/delimitersizes/.is family, /delimitersizes,
default/.style = {auto},
auto/.style = {leftsize = auto, rightsize = auto},
big/.style = {leftsize = big, rightsize = big},
bigg/.style = {leftsize = bigg, rightsize = bigg},
Big/.style = {leftsize = Big, rightsize = Big},
Bigg/.style = {leftsize = Bigg, rightsize = Bigg},
leftsize/.style = {leftdictionary/#1/.get = \leftdelimitersize},
rightsize/.style = {rightdictionary/#1/.get = \rightdelimitersize},
leftdictionary/.cd,
big/.initial = \bigl,
bigg/.initial = \biggl,
Big/.initial = \Bigl,
Bigg/.initial = \Biggl,
auto/.initial = \left, }
\pgfkeys{/delimitersizes, rightdictionary/.cd,
big/.initial = \bigr,
bigg/.initial = \biggr,
Big/.initial = \Bigr,
Bigg/.initial = \Biggr,
auto/.initial = \right, }
\newcommand{\myset}[2][]{
\pgfkeys{delimitersizes, default, #1}
\leftdelimitersize\{#2\rightdelimitersize\} }
\begin{document}
$\myset[big]{abc}$
\end{document}
This functions as it is supposed to, but considering the finished product, it seems like there's a significant amount of "code duplication", and shuffling around of information before getting to use it. I realize this is a rather open-ended question, but can people suggest how to improve this code to make it more compact and streamlined?

\DeclarePairedDelimiterfrom themathtoolspackage. – Qrrbrbirlbel Apr 03 '13 at 19:07