# Hooking into $$and$$

Joseph Wright mentions in an comment to this tex.SE answer that it is possible to “hook into” the $$and$$ commands to change their behaviour. Say that I'd like to force a cramped style on all inline equations by e.g. wrapping them in \cramped (from the mathtools package) by hooking into the $$and$$ commands. How would I do that? Or is there perhaps an easier way to force a cramped style?

-

\def$$#1$${$\cramped{#1}$}
@Konrad Yes, it has no check like the default $$...$$. –  egreg Jul 20 '11 at 7:38