>  > there is no
 >  > \ifmmode and there is no expansion since i use the "mltex" option and
 >  > thus inputed chars belong to category "letter".
 > ah, so what you mean is you solved it for a subgroup of the clientele of
 > todays LaTeX

fallacious argument i heard for the first time 20 years ago, when accented
chars were only used by a subgroup of TeX users... Willing to solve
all world's problems often generates no solution, so having
complementary solutions is a good approach.

 > and only for the chars that are part of your base font (or can be
 > constructed from them), eg if you type $\texteuro$ what happens?

as we spoke about input encoding and math, \text constructs were
not concerned. If \DeclareMathMeaning can solve the pb of $\texteuro$
it's fine.

> One limited possibility would be
> \mathcode`\="8000

i confess this is also my trick along with the mltex option and
thus there is an expansion:

{the letter }
->\mathaccent "7012\relax a

> would require that input encoding and font encoding match...

no more than \catcode`\=\active of inputenc!
May be a \usepackage[...]{mathenc} should help...