eglot 在 windows 上部分语言(如:python) connecting 错误的原因分析

在 windows 系统中,使用 eglot 时经常会遇到未连接成功的警告

 "[eglot] (warning) Not auto-reconnecting, last one didn't last long"



经过尝试,偶然发现 无论是在加载 eglot 前后,只要在 emacs 中配置好 emax 就可以解决这个问题。

正常 connecting 的效果

emax 配置可以参考 子龙山人 @guanghui.qu 提到过的配置方法 Master Emacs in 21 Days

(progn
  (defvar emax-root (concat (expand-file-name "~") "/emax"))
  (defvar emax-bin (concat emax-root "/bin"))
  (defvar emax-bin64 (concat emax-root "/bin64"))

  (setq exec-path (cons emax-bin exec-path))
  (setenv "PATH" (concat emax-bin ";" (getenv "PATH")))

  (setq exec-path (cons emax-bin64 exec-path))
  (setenv "PATH" (concat emax-bin64 ";" (getenv "PATH")))

  (setq emacsd-bin (concat user-emacs-directory "bin"))
  (setq exec-path (cons  emacsd-bin exec-path))
  (setenv "PATH" (concat emacsd-bin  ";" (getenv "PATH")))

  ;;可选安装msys64
  ;;下载地址: http://repo.msys2.org/mingw/sources/
  (setenv "PATH" (concat "C:\\msys64\\usr\\bin;C:\\msys64\\mingw64\\bin;" (getenv "PATH")))

  ;; (dolist (dir '("~/emax/" "~/emax/bin/" "~/emax/bin64/" "~/emax/lisp/" "~/emax/elpa/"))
  ;;   (add-to-list 'load-path dir))
  )

此解决方案不一定能适用所有语言,目前只尝试解决了python语言连接失败的情况。