Maybe http://www.emacswiki.org/emacs/ScimBridge will help? It appears
to let Emacs control scim by talking to scim-bridge over a socket.
Perhaps you could adapt parts of it to switch input languages
programmatically.
no , it is between buffers. I want to revise cdlatex using function "texmathp" . Now I am studying elisp. Thanks