I'd like to be able to make a macro \foo whose definition would look something like
\newcommand{\foo}{
\ifintextmode{abc}
\ifinmathmode{x\cdot y\otimes z}
}
so that
\foo $\foo$
produces

This TeX.SE question seems somewhat related, but I didn't quite understand the answer and it does not directly solve my issue. I'm sorry I don't have anything more to offer, in terms of making any progress myself.
\adelesproducead\'elesin text mode and\mathbb{A}in math mode. I generally try to abstract such specifics away in my questions, if they don't seem like they'd be important. – Zev Chonoles Apr 02 '13 at 22:09\adeletextand\adelesymbol; though maybe TeX would like it, I think it would be harder for me to parse when reading the code directly. – Zev Chonoles Apr 02 '13 at 22:43\mathbb{A}? Semantically, the name of a class of objects is different from the name of an object in the class. By the way, "adèle" is spelled with a grave accent:ad\`ele. – egreg Apr 02 '13 at 22:47\adeleto represent the word this whole time, my mistake will be easy to clean up! :) – Zev Chonoles Apr 02 '13 at 22:49\newcommand{\ringofadeles}[1][]{\mathbb{A}_{#1}}and\newcommand{\adeles}{ad\\eles}` be okay? – Zev Chonoles Apr 02 '13 at 22:57