Vladimir,

 > there is a solution for this problem used in the mathtext package
 > available from
 > CTAN:macros/latex/contrib/supported/t2/etc/mathtext.{dtx,ins}
 >

do you mind outlining the solution in a few sentences? how do you want
to be able to find out that you are not in math but will be once
something (eg tha actual letter) triggered the \halign u part without
actually triggering it (with something like \relax which kills
ligaturing)?

thanks
frank