Hi, Eli,

`ImmGetOpenStatus` and `ImmGetOpenStatus` are functions uesd for internationalization for Windows Applications.

Function `w32-get-ime-open-status` determines whether the IME is open or closed, If return 1, IME is open. If return 0, IME is closed.

Function `w32-set-ime-open-status` opens or closes the IME. This function has one argument.
If the argument is not nil, open or enable IME, we can type some words, IME will translate them into native language like chinese.
If the argument is nil, close IME, we can type some words in english, IME will not translate them into chinese.

I try to figure out how to do this without static variables. Static variable is the simplest way to do the job between window thread and lisp thread right now.
------------------ 原始邮件 ------------------
发件人: "Eli Zaretskii"<eliz@gnu.org>;
发送时间: 2020年4月13日(星期一) 中午12:53
收件人: "Albert"<georgealbert@qq.com>;
抄送: "emacs-devel"<emacs-devel@gnu.org>;
主题: Re: [PATCH] Add IME status change support on windows natively

> From: "Albert" <georgealbert@qq.com>
> Date: Mon, 13 Apr 2020 12:09:00 +0800
>
>     I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows
> natively like gVim did. gVim can change IME status to chinese mode  in insert mode and switch back to
> english mode when in normal mode natively.

Thanks.  Can you please tell more about the uses of this feature?  How
would a user of Emacs use this, and what is the effect of using this
on editing inside Emacs?

I'm asking because we probably need to say something about this in the
manual.

>       (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
>       (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

I don't use Evil, so I'm not sure I understand what this does.  If you
describe the typical uses of this feature, I will probably understand
better.  In particular, why is this placed on a hook?

> +/* emacs ime status change flag, used in mainThread and windowsThread */
> +static int w32_ime_status_changed = 0;
> +static int w32_emacs_ime_status = 0;

Can we do this without static variables?  E.g., can you use the 2
parameters of the PostThreadMessage API to pass these flags?  I think
that would be cleaner.

> +DEFUN ("w32-get-ime-open-status",
> +       Fw32_get_ime_open_status, Sw32_get_ime_open_status,
> +       0, 0, 0,
> +       doc: /* Return ime open status on Windows. */)

The doc string is too terse, it should say something about the
returned status and its significance.

> +DEFUN ("w32-set-ime-open-status",
> +       Fw32_set_ime_open_status, Sw32_set_ime_open_status,
> +       1, 1, 0,
> +       doc: /* Set emacs IME open status on Windows. */)

Likewise here.  AFAIU, this function doesn't "set the status", it
actually opens or closes the IME.  If so, the doc string should say
that, and it should explicitly mention the argument of the function
and its significance.

Thank you for working on this.