From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request Date: Wed, 15 Mar 2023 20:38:10 +0000 Message-ID: <87pm994uod.fsf@gmail.com> References: <87v8j28c2x.fsf@betli.tmit.bme.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30005"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62198@debbugs.gnu.org To: Felician Nemeth Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 15 21:37:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcXs1-0007Wj-9Y for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Mar 2023 21:37:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcXrt-0006zJ-EM; Wed, 15 Mar 2023 16:37:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcXrr-0006wU-30 for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 16:37:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcXrq-0006ml-Qa for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 16:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pcXrq-00016g-IH for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 16:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Mar 2023 20:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62198 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62198-submit@debbugs.gnu.org id=B62198.16789125784186 (code B ref 62198); Wed, 15 Mar 2023 20:37:02 +0000 Original-Received: (at 62198) by debbugs.gnu.org; 15 Mar 2023 20:36:18 +0000 Original-Received: from localhost ([127.0.0.1]:40618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcXr8-00015S-Bu for submit@debbugs.gnu.org; Wed, 15 Mar 2023 16:36:18 -0400 Original-Received: from mail-wm1-f53.google.com ([209.85.128.53]:41532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcXr5-00015C-UC for 62198@debbugs.gnu.org; Wed, 15 Mar 2023 16:36:16 -0400 Original-Received: by mail-wm1-f53.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso2119060wmo.0 for <62198@debbugs.gnu.org>; Wed, 15 Mar 2023 13:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678912569; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+FQvPtCc+rWP5fxM2uqfCggdFdE6PWX47EwxPxSMPqU=; b=WKhu5AY3EWnNPUvAD8pdAN6JWqoUJVDv4iGhLm3JN4vwK/RNBVkpq2UKhZuxBAbCLN dZTQAugxRoAk9YEgxBH2YNNImTeGWebWbz0eezzK8yzAhldMKMwF3qEhAZni1qTt1Ieq VYKBxt3XT97ip+K6+pOKMaf3Hj4xcIt4zHfzITEbcFCSRNhLXpmvz4Cm3g+jU6G273Ck 0SVxvxpLcztNhdCVL5th6jyPyqeIaVsmtvC6BJNPSTHJjmHIdtB1o47I7s+KT+OiDx65 kgLABNuEDn3cq92gOEQcBUhPsz0ssSc+tNntahYqCWHnlVUBf5Nt6/ibl6kyRWBwHzJx XiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678912569; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+FQvPtCc+rWP5fxM2uqfCggdFdE6PWX47EwxPxSMPqU=; b=Vf02kIPiP8mBHdMSO/aUPl03PiN77Ci8/Rsv/wejJPx0wdbLuFD1NxZLXPZ1khs16C rpZIsMFTG+PVxz+YLZqfeN7aapKou9dUnqTiHZDV8ySWmt2L4FysJfFUgeo36ZU1mLHa ta0Ur5pu+u49D1I8QtEouEZBgE0fjZSDY/o10ByyP6OenxF28mFeqD+RtlvGP5zwt/GT Lxfi4vmKt2GR7hJa4HMItW047la4zJ8luI/7TdqQW6tyelLdFMnLDLSWPzc+4d2JIxv9 DhNVhus9AxlFGqradai13bCUwB47Z6L6GHGPudB8jw4zfFv4r+Wvogd5a66s8Jg4o5KD qemQ== X-Gm-Message-State: AO0yUKW0T5cYg6x88JJ0VKIeiUlmrg/0gQ2eZGIVwXHiXQjV1SBp0pCs p2ZQPFSozObQ20+vS1aHNzKYONrILpI= X-Google-Smtp-Source: AK7set/PdtsGC2SAidUr12Li0iiVlGRQhAZ50Kdl7hYaBW9iKN2ZBhIm0phhl3WazXjezmr7cTviCw== X-Received: by 2002:a05:600c:1c27:b0:3ed:2619:6485 with SMTP id j39-20020a05600c1c2700b003ed26196485mr10507620wms.3.1678912569683; Wed, 15 Mar 2023 13:36:09 -0700 (PDT) Original-Received: from krug (87-196-72-142.net.novis.pt. [87.196.72.142]) by smtp.gmail.com with ESMTPSA id o9-20020a05600c4fc900b003ea57808179sm3322458wmq.38.2023.03.15.13.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 13:36:09 -0700 (PDT) In-Reply-To: <87v8j28c2x.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Wed, 15 Mar 2023 12:53:58 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257986 Archived-At: Felician Nemeth writes: > I originally posted this patch on github: > https://github.com/joaotavora/eglot/pull/818 > > Jo=C3=A3o 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: =3D?UTF-8?q?Felici=3DC3=3DA1n=3D20N=3DC3=3DA9meth?=3D > 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 > > ;;; 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=3D method "initialize") > + (let* ((clientInfo (plist-get params :clientInfo)) > + (name (plist-get clientInfo :name)) > + (version (plist-get clientInfo :version))) > + (should (equal name "Eglot")) > + (should (version<=3D "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=C3=A3o