Possible Duplicate:
Are we inside an edef?
I've defined a macro that changes its behaviour depending on the next character, so it uses \@ifnextchar. This makes it behave badly inside things like \edefs. I'd like to define a "failsafe" behaviour, something like:
\ifExpansionOnly
\doSomethingSensibleButSafe
\else
\doTheRealThing
\fi
Is that possible to detect? It feels like something to do with "fragile" and "robust" commands, but my experimental skills are failing me here.
(Edit: removed motivation from using hyperref; turned out the behaviour that I was seeing there was due to using \Hy@WrapperDef in the wrong place.)