Subject: Re: eglot feature request: set Initialize.ClientInfo.{Name,Version}

From: Felician Nemeth <[email-masked]>
Date: Sat, 15 Jul 2023 12:18:11 +0200

>> If Eglot is installed, then it is byte-compiled as well.  The earlier
>> patch in this bug report made sure that the helper library ('lisp-mnt)
>> was required only at compile time.  However, the patch worked even if
>> Eglot was not installed with package.el (but Eglot still needed to be
>> byte-compiled).

> I thinkt the lisp-mnt-at-compile-time solution is preferable, as I'm
> not sure 'eglot always lives in package-alist (sometimes it is a
> built-in and that is a royal pain).  Can you show an
> updated patch for it, when you have time, Felicián?

I've attached the updated patch.

>From df775108a9d0c5171ca6eeb19af752bec15c626a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <[email-masked]>
Date: Sat, 15 Jul 2023 12:02:49 +0200
Subject: [PATCH] Eglot: send version in clientInfo (bug#62198)

* lisp/progmodes/eglot.el (eglot--version): New defconst.
(eglot--connect): Use it.
---
 lisp/progmodes/eglot.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 8ac21638a5..0da4641fba 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -421,6 +421,14 @@ eglot-withhold-process-id
 
 ;;; Constants
 ;;;
+(defconst eglot--version
+  (eval-when-compile
+    (when byte-compile-current-file
+      (require 'lisp-mnt)
+      (lm-version byte-compile-current-file)))
+  "The version as a string of this version of Eglot.
+It is nil if Eglot is not byte-complied.")
+
 (defconst eglot--symbol-kind-names
   `((1 . "File") (2 . "Module")
     (3 . "Namespace") (4 . "Package") (5 . "Class")
@@ -1352,7 +1360,9 @@ eglot--connect
                                         (eq (jsonrpc-process-type server)
                                             'network))
                               (emacs-pid))
-                            :clientInfo '(:name "Eglot")
+                            :clientInfo
+                            `(:name "Eglot" ,@(when eglot--version
+                                                `(:version ,eglot--version)))
                             ;; Maybe turn trampy `/ssh:foo@bar:/path/to/baz.py'
                             ;; into `/path/to/baz.py', so LSP groks it.
                             :rootPath (file-local-name
-- 
2.39.2