unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Felician Nemeth <felician.nemeth@gmail.com>
Cc: 62198@debbugs.gnu.org
Subject: bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request
Date: Wed, 15 Mar 2023 20:38:10 +0000	[thread overview]
Message-ID: <87pm994uod.fsf@gmail.com> (raw)
In-Reply-To: <87v8j28c2x.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Wed, 15 Mar 2023 12:53:58 +0100")

Felician Nemeth <felician.nemeth@gmail.com> writes:

> I originally posted this patch on github:
> https://github.com/joaotavora/eglot/pull/818
>
> João requested to resubmit it here.
>
> To recap: clientInfo arrived in LSP 3.15.0.  LSP clients can use
> clientInfo to identify themselves in the initialize request.  This is
> generally useful for various debugging tasks.
>
> From 5fe9d054845382ce74c29bb338ffc737b0770542 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@gmail.com>
> Date: Wed, 15 Mar 2023 12:34:06 +0100
> Subject: [PATCH] Eglot: Send clientInfo during the initialize request
>
> clientInfo arrived in LSP 3.15.0.  LSP clients can use clientInfo to
> identify themselves in the initialize request.  This is generally
> useful for various debugging tasks.
>
> * lisp/progmodes/eglot.el (eglot--version): New defconst.
> (eglot--connect): Send clientInfo using eglot--version.
> * test/lisp/progmodes/eglot-tests.el
> (eglot-test-client-info): New test.
> ---
>  lisp/progmodes/eglot.el            | 12 ++++++++++++
>  test/lisp/progmodes/eglot-tests.el | 18 ++++++++++++++++++
>  2 files changed, 30 insertions(+)
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 037cc87148..f89c47ac4f 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -410,6 +410,14 @@ eglot-withhold-process-id
>  \f
>  ;;; 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.")

I'm not familiar with this lisp-mnt.el library.  Is it the kosher way to
get version introspection for Elisp libs?  Why is it nil if Eglot is not
byte-compiled, couldn't we get it by looking at load-file-name?

Can we somehow get the Emacs.git SHA in there as well?

> @@ -1310,6 +1318,10 @@ eglot--connect
>                                          (eq (jsonrpc-process-type server)
>                                              'network))
>                                (emacs-pid))
> +                            :clientInfo (if eglot--version
> +                                            `(:name "Eglot"
> +                                              :version ,eglot--version)
> +                                          '(:name "Eglot"))

I'd rather just :name "Eglot" :version "unknown" if we don't have it.

> +  (eglot--with-fixture
> +   `(("project" . (("coiso.py" . "def coiso: pass"))))
> +   (with-current-buffer
> +       (eglot--find-file-noselect "project/coiso.py")
> +     (eglot--sniffing (:client-requests c-reqs)
> +       (should (eglot--tests-connect 10))
> +       (eglot--wait-for (c-reqs 10)
> +           (&key _id method params &allow-other-keys)
> +         (when (string= method "initialize")
> +           (let* ((clientInfo (plist-get params :clientInfo))
> +                  (name (plist-get clientInfo :name))
> +                  (version (plist-get clientInfo :version)))
> +             (should (equal name "Eglot"))
> +             (should (version<= "1.8" (or version "0"))))))))))

Thanks.  Do we really need a test for this?  I suppose it's good
practice, but seems a but too much.  We could put this check in some
other "basic" test, save a bit of time.

João








  reply	other threads:[~2023-03-15 20:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 11:53 bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request Felician Nemeth
2023-03-15 20:38 ` João Távora [this message]
2023-03-16 16:47   ` Felician Nemeth
2023-03-17  8:25     ` Michael Albinus
2023-03-19 12:15       ` Felician Nemeth
2023-03-19 13:23         ` João Távora
2023-03-22 16:05           ` Felician Nemeth
2023-03-22 18:40             ` João Távora
2023-03-23 16:03               ` Felician Nemeth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pm994uod.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=62198@debbugs.gnu.org \
    --cc=felician.nemeth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).