Index: emacs/context.c =================================================================== --- emacs/context.c (revision 5052) +++ emacs/context.c (working copy) @@ -69,11 +69,8 @@ /* discard current context */ clear_candidate(ua->cand); clear_preedit(ua->pe); - uim_release_context(ua->context); - ua->context = create_context(ua->encoding, ua); - - update_context_im(ua); + uim_switch_im_with_client_encoding(ua->context, ua->im, ua->encoding); } Index: uim/uim-im-switcher.h =================================================================== --- uim/uim-im-switcher.h (revision 5052) +++ uim/uim-im-switcher.h (working copy) @@ -71,6 +71,18 @@ void uim_switch_im(uim_context uc, const char *engine); +/** + * Switch input method engine of the uc. (We should use the word + * "module" here?) + * + * @param uc input context to switch the input method of + * @param engine name of input method engine + * @param encoding name of client encoding + */ +void +uim_switch_im_with_client_encoding(uim_context uc, + const char *engine, const char *encoding); + /* * Set callback functions called when IM-switching of specific set of context * is requested. Index: uim/uim.c =================================================================== --- uim/uim.c (revision 5052) +++ uim/uim.c (working copy) @@ -588,6 +588,27 @@ } void +uim_switch_im_with_client_encoding(uim_context uc, + const char *engine, const char *client_encoding) +{ + if (UIM_CATCH_ERROR_BEGIN()) + return; + + assert(uim_scm_gc_any_contextp()); + assert(uc); + assert(engine); + assert(client_encoding); + + free(uc->client_encoding); + uc->client_encoding = uim_strdup(client_encoding); + + uim_scm_callf("uim-switch-im", "py", uc, engine); + + UIM_CATCH_ERROR_END(); +} + + +void uim_switch_im(uim_context uc, const char *engine) { if (UIM_CATCH_ERROR_BEGIN())