I'm pursuing the Math Expectation operator (\mathbb{E}).
As \DeclareMathOperator is not very good for one-letter operators (since it adds some spacing after itself), I use a plain \newcommand. But here comes the problem that there's no space before it, so writing something like X \MyExpct X turns into something without spaces, while I would like to see a space between the first X and \MyExpct.
But adding a spacing into \newcommand before \mathbb{E}, like
\newcommand{\MyExpct}{\,\mathbb{E}}
fails when my operator stand in the beginning of an expression! So what I want is a space which would be added before the operator if something (but not a binary operation or a opening bracket!) stands before it, and which would be removed otherwise.
I tried to play with \unskip, \ignorespaces, and even looked into how \DeclareMathOperator deals with it (via \kern) but failed to find the solution.

\newcommand{\MyExpct}{\mathop{}\!\mathbb{E}}should do. – egreg Oct 25 '13 at 15:22