为什么是否已有client frame对新建client frame的行为有影响

== Edit ==

设有这样的一个 elisp 函数:

(defun test ()
  (apply #'call-process "emacsclient" nil 0 nil
           '("-c")))

在命令行中这样执行:

emacsclient --eval "(test)"

其结果在取决于是否已有 client frame 存在。如果存在,那么执行成功并新建 client frame;如果目前没有 client frame 存在,那么这个命令则不会新建 client frame。

请问这个问题的原因是什么?有解决方法吗?

== 原帖 ==

最近几天在尝试给 emacs-everywhere 做 Windows 支持(仓库地址: Masellum/emacs-everywhere),但是遇到一个问题:

emacs-everywhere 是通过新建 client 来实现弹出 emacs 的功能,具体的方法是设置一个快捷键给命令 emacsclient --eval "(emacs-everywhere)",其中那个命令会创建一个新 client frame。我遇到的问题在于,如果 server 已经有对应的 client frame 存在,那么就可以正常运行并新建 frame;而如果 server 目前没有 client frame,那么 emacs-everywhere 也无法新建 client frame。已经用 emacs -Q 排查过没有找到原因,于是有了标题中的猜想。目前我除了不知道背后的原理,还有一个问题是因为这里出现问题的是要新建的唯一一个 client frame,所以也不知道如何在 emacs 中 debug。感谢可以解惑的坛友,谢谢!

突然想到这应该与 Windows 有关吧,因为 emacs-everywhere 本身肯定在别的平台上没有问题

问题暂时解决(或者说被绕过)了:不使用 call-process 而是使用 w32-shell-execute 创建新的 emacsclient 进程就没有问题,我猜测这里可能有 Windows 的进程和窗口机制的问题,具体原理就难以搞清了。