GNU bug report logs - #76423
Major-mode provided LSP server for Eglot

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Stefan Monnier <monnier@HIDDEN>; Keywords: patch; dated Wed, 19 Feb 2025 20:34:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 21 Feb 2025 09:49:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 04:49:30 2025
Received: from localhost ([127.0.0.1]:53691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlPez-0000NA-R0
	for submit <at> debbugs.gnu.org; Fri, 21 Feb 2025 04:49:30 -0500
Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:49357)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>)
 id 1tlPew-0000Ld-A3
 for 76423 <at> debbugs.gnu.org; Fri, 21 Feb 2025 04:49:27 -0500
Received: by mail-ej1-x634.google.com with SMTP id
 a640c23a62f3a-aaecf50578eso374409466b.2
 for <76423 <at> debbugs.gnu.org>; Fri, 21 Feb 2025 01:49:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740131360; x=1740736160; darn=debbugs.gnu.org;
 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=GLQQw8yA05xgEXcegGfGHPz95ll4jF1NlnoGIjWQXP0=;
 b=OCzwXgqC0Eymhom1SqtZLysdycnzu8fH4drXrTkSOQ+hw7lqtZE3Hy7c7rkU+qg6wk
 wpbczLIJXDM6243vD4+UMz/tWaRoI24XWL7jLZ4n+ptDaDrb+41bABkwW/iEKO7H0LT5
 ksFyPaxBsvXyEWlDaL9AJvpUmE8rDCtErHHrmDndld7MOFZGOxdY7eVVeyYHKgULbH6R
 3PsFO8CK0fzNPS0P3CceBW3dyT2tsqGPNGHqxnp1oG/CWjhXKr4XYxY07aaslOksDrX4
 pKfoU09Ud5wgFsEN5juIGS9AyabcipTx66oso5+RDr4tJ2ccA4lByq0zfWCQUvRLi8Qp
 8sag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740131360; x=1740736160;
 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=GLQQw8yA05xgEXcegGfGHPz95ll4jF1NlnoGIjWQXP0=;
 b=tlBu3NMl4fUy3KAeH7yw7EMw01XDVprhIkooK+CayfL12n04tMITDCdSoH+wGAFKvv
 91eh1iEfVFPbW6H5+ae2hKEsSpusv7RZ2xG9aNUXaca127ZMYk7xnWPq85OkuM+tDobR
 H3dMYo1BcRF8UrGGPMjddpWdyzyAoN+OhpdeCsRTw2wBctn5omXIYI9YCwbvQnRUjKWX
 +xr5haxEp5YZGoT9ql0XfDaQaMTZvyEWBgeQjVePQVEj/3dmi83ws7t/ZDNSyFxX0KLQ
 PQZdt1XjKW5Q7Nl+NMNoJeLo5OTq/8BVJhejmFw3hqi2MqT9kCWOfoMqgl2Xgvz0HUo2
 8Ukg==
X-Gm-Message-State: AOJu0YwZoYQ+gOrsQz9K/DzD5MKGegTMdXmhnvusKKa22WzcwIdvWz5q
 +QpGqbjD069mhzg2Z1sl+8Ioo1NSwuvHFwatVMiD+hE8aUVcAqML
X-Gm-Gg: ASbGncvpHSo0eaAN3VRsO+vkcd1xtyIwjRz4cSxYupiwnUxJTdRUx68unFxD46IbWYX
 kOPRkCXichxMo0BeKe3+AzqRR26BwXpk/klM7XeVT6DepcR17eOJYFz2Meoh5+HOcqXmFehJOBI
 jN1np4DlOk+Qx/2nVBvEJxxY43hS1fYb3tUvs/lxsWlY+87vTCg5hyR8UCWgYQyqFkgI0UEbOF2
 TGy+xQIBjN4NuS0PXHtdWyVn9cJMmrp0C0WmmX7Tf1ohTEBkHc1VKGcvQr197qzM+qlD3qeZ5vj
 +j6ij74ta/balQ0BT+iTQ9qR/jgcHCBQuuoBzbIE
X-Google-Smtp-Source: AGHT+IGkrkVORujR1aejKxQWhA5OV5cgxVGeu7J3ApmOg5V4JNYdHL7tsE5SaKO1tYzFX3weF1nYNg==
X-Received: by 2002:a17:907:97d5:b0:ab3:4c32:aa6c with SMTP id
 a640c23a62f3a-abc0d9e5b0amr176232966b.20.1740131359494; 
 Fri, 21 Feb 2025 01:49:19 -0800 (PST)
Received: from krug (87-196-75-87.net.novis.pt. [87.196.75.87])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-abbab9e9863sm819202566b.64.2025.02.21.01.49.18
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 21 Feb 2025 01:49:18 -0800 (PST)
From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <jwv5xl4yp6b.fsf-monnier+emacs@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN> <87r03sfkun.fsf@HIDDEN>
 <jwvcyfcpbx5.fsf-monnier+emacs@HIDDEN>
 <CALDnm53OczvuPVDW0A9k8YfLBmFZwMd707mrCaLLoLJXKf+f7g@HIDDEN>
 <jwv5xl4yp6b.fsf-monnier+emacs@HIDDEN>
Date: Fri, 21 Feb 2025 09:49:32 +0000
Message-ID: <87ikp3fx03.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier <monnier@HIDDEN> writes:

>> As it stands, looking at the `eval-after-load' code for bicep-ts-mode,
>> I wonder if it is really a "funny dance" or just the way it should be
>> until past decisions are revisited (but not by me :-))
>
> Having to play such games just to update some kind of central DB of all
> the modes seems really silly when the DB is only ever consulted for the
> major mode of current buffer.

Let see:

- Is it so?  Something is only really "silly" if it serves no purpose
  beyond its exhuberance or idiosyncrasy.  If you were to take away the
  "silly" centralized e-s-programs db now -- like someone recently
  naively suggested -- you would break eglot.el as loaded in older
  Emacsen, and that would upset a fair number of people.  Of course, you
  could move it into compat.el (no longer in use by Eglot) and maintain
  it there.  You would only be increasing the level of silliness.

- Everything in Emacs happens in a buffer and in a major mode, and the
  only useful hookage we get to set things up before minor modes kick in
  is tied to those, so any db -- centralized or not -- is going to be
  consulted within those boundaries.

- LSP stands for Language Server Protocol, and its mapped to the concept
  of "language".  As is much other tooling outside the Emacs ecosystem
  (frequently utterly uninterested in what a "major mode" is).
  Snippets, syntax highlighters, linters etc.  The fact that there is no
  easy way to "run this bit of code if the current buffer is in this
  language" is IMO a very glaring omission in an editor which is
  frequently used for source code.

- Your patch would probably work for biceps-ts-mode and whatever
  "Biceps" is but when dealing with major modes that must cooperate with
  each other (c-mode and c-ts-mode ... json-mode and json-js-mode,
  tuareg-mode and ocaml-mode, many others) etc, it would lead to
  repetition and duplication: a newcomer mode would always need to beg
  the maintainers of other major modes to reference it.  Dead modes
  would linger around scattered.  Duplication, at least in my book,
  always tips the pendulum of silliness towards it.

So, again, until past decisions are revisited (that bug#somesuch of 1/2
years ago) and there exists a way for a major mode to say "I serve this
language and I want to suggest a language server for it so that other
modes that also serve it can use it" I think the current state of
affairs is the best we have.

What real problem is there in the current biceps-ts-mode.el code?
Doesn't it work?  There is no duplication.  It's a DRY and idempotent
statement.  It is a dislike of eval-after-load?  In that case, if
loading order is the problem, maybe `add-hook` semantics (which solves
the same problem by other means) could be leveraged.  But unless a real
problem (and a real solution) can be presented just calling out the
formal exhuberance of a solution is no real argument for change.

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 21 Feb 2025 03:05:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 22:05:10 2025
Received: from localhost ([127.0.0.1]:47816 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlJLg-0003Ay-Qn
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 22:05:09 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45027)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1tlJLW-000383-KG
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 22:05:03 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id DDBD0442AEC;
 Thu, 20 Feb 2025 22:04:51 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1740107090;
 bh=KGPXqn2MGmDgmuXTSVkjwUinuSvMLEu2DARSvy/Ii4A=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=aP9ooa5zt46tmjHBlXTSQGbjrGxPZr3FFicOJwtMIydKxW4f6/gMkPlHiKD3EXGkL
 oh8p4ghIeb6foWjuCJv585kP4W8yurZP8sHXMkU9+UnIxf/MI/I4qXXemLBVS0HErl
 bV1VYnunTJA6G23neK05PrZtH4pxtqpdP0ENyPWTterxLoL6Yu87Q7d6O9/EjWs8om
 WLTqSm8dxJ78ZhtzuzYjPsIPrPt6DWLWMRGQmtCVYyXdNXikICDoJPIs/AnMq1KEyb
 jJeTw5DEcK3m7ariqh71Q2+HOD4fI5QUtQFzcKUcYzuEnMfmeQNiyzejcUoiIhgQMb
 yl8NDGxlwnT9g==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D7B64442AE9;
 Thu, 20 Feb 2025 22:04:50 -0500 (EST)
Received: from pastel (unknown [104.247.242.5])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A818812045A;
 Thu, 20 Feb 2025 22:04:50 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= <joaotavora@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <CALDnm53OczvuPVDW0A9k8YfLBmFZwMd707mrCaLLoLJXKf+f7g@HIDDEN>
 (=?windows-1252?Q?=22Jo=E3o_T=E1vora=22's?= message of "Thu, 20 Feb 2025
 23:55:48 +0000")
Message-ID: <jwv5xl4yp6b.fsf-monnier+emacs@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN> <87r03sfkun.fsf@HIDDEN>
 <jwvcyfcpbx5.fsf-monnier+emacs@HIDDEN>
 <CALDnm53OczvuPVDW0A9k8YfLBmFZwMd707mrCaLLoLJXKf+f7g@HIDDEN>
Date: Thu, 20 Feb 2025 22:04:50 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.494 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> As it stands, looking at the `eval-after-load' code for bicep-ts-mode,
> I wonder if it is really a "funny dance" or just the way it should be
> until past decisions are revisited (but not by me :-))

Having to play such games just to update some kind of central DB of all
the modes seems really silly when the DB is only ever consulted for the
major mode of current buffer.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 23:55:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 18:55:55 2025
Received: from localhost ([127.0.0.1]:45228 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlGOX-0002Sd-TX
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 18:55:55 -0500
Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]:47475)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>)
 id 1tlGOV-0002RN-4P
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 18:55:51 -0500
Received: by mail-oi1-x234.google.com with SMTP id
 5614622812f47-3f404933b1cso393862b6e.3
 for <76423 <at> debbugs.gnu.org>; Thu, 20 Feb 2025 15:55:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740095745; x=1740700545; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=jFaThYZdS8OOUx44MeI+RBwupGOlsJczhdmgrwEuGq0=;
 b=bdlCEpfjDGl/j+C0KTgq09QkJOdSySWCy6x3IuXsY8rIqkrVs/eV9dbUm/0vk+mJWT
 TWt3RYdKzBMksHInafXcR8flzeqrToN7diWlsdukRVvMIigIGIu37f224NhwKenaI4iR
 rSXrSM3c4YO7mRwO+Ia3IxIn1pczYSTBLDsD1JKD4WqqDkgxxOZNXZqw0k0TexY6G33A
 S1uN7cJjbW7Euozj6ZUn6xS4Dh/ruGc+BWjXCqugXvaR6l/LuaqNRDCes6CvdnNlx3z4
 t+kHGsxiJfu9l1sM/x7DdphlCp96QrKW4Y86m6Y9XqQSLF7LTdGMuPOCTaxJ6KMJQX2J
 n+Ng==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740095745; x=1740700545;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=jFaThYZdS8OOUx44MeI+RBwupGOlsJczhdmgrwEuGq0=;
 b=UHLy3nENGA8z0zO7UFPpn5YVIFjdN2khCRVbRtdP+zeIlYZ4sTojeO6ssT0KavCrv6
 +chDNvzcjtBWbRRodL8OLJABG+ia/jfbWJglCn3S+w2GASgHvCef73DuF2hNqvg0Sts/
 9qUq/b4ocfq3zJ0yHB24rb67M5czQ11u57fLBOUujPFYt+GyDIBqn0D4GMOW9pXgoQ+2
 K0UZZ7DLKS43kL2gtgwSrD1mEP1rzN+NdMA+fY5VusWyr1gPeASgkfRoImUjQNiPMRUM
 ZF8AHo/AhhJ1KTzh9V/Bp7kfFa/NBkU36Mp85A3Om7JGGYNU35qQM1suf3oRmSRJsMAc
 ohXQ==
X-Gm-Message-State: AOJu0YyDtsE7BgWOik8IbeqGX4brvko1GYCnI5+EMT1k6pVHezDbkl/b
 4jKIfiKxpdvZJ4Y9coaQB0MlBV6yTGAWfmKEU1EPVCTMw5CN82cOuBIVxrq04bdhGzZGpw/044T
 CQLQ47Y5PZ7bQO2FuEYQIVo0kNlU=
X-Gm-Gg: ASbGncs+8V1Adu0AbIZJZx4RmX2gpUX7su/9goA3ifAmMDkeTdXqGm0vZYvRB2tw2cD
 1vYv0rVsiwYN1xGR8tfN//FHJKWpHLQg4p1JTNXdIB3c3ykcXc1wtLRVr2DAxrGYqZSh98aM=
X-Google-Smtp-Source: AGHT+IE0D4c1zBiuCWnRphaejOP7AA1OXGpEDEXvY3uEkQDkEJFnTO8HayNStvl0YI5ndak5Z/hy7QkCDtIG7dZnSks=
X-Received: by 2002:a05:6808:1513:b0:3f3:f90b:f1b3 with SMTP id
 5614622812f47-3f425a658admr540820b6e.5.1740095744982; Thu, 20 Feb 2025
 15:55:44 -0800 (PST)
MIME-Version: 1.0
References: <jwvcyfd7jzw.fsf@HIDDEN> <87r03sfkun.fsf@HIDDEN>
 <jwvcyfcpbx5.fsf-monnier+emacs@HIDDEN>
In-Reply-To: <jwvcyfcpbx5.fsf-monnier+emacs@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Thu, 20 Feb 2025 23:55:48 +0000
X-Gm-Features: AWEUYZnAx8fnEvqnnYx0q9jhi-_Oy3_Qr9jSqTVV10-bKmMK97b2dS5hDMFmElg
Message-ID: <CALDnm53OczvuPVDW0A9k8YfLBmFZwMd707mrCaLLoLJXKf+f7g@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Thu, Feb 20, 2025 at 9:12=E2=80=AFPM Stefan Monnier <monnier@HIDDEN=
al.ca> wrote:
>
> >>       (setq-local eglot-server-programs
> >>                   `(bicep-ts-mode . ("dotnet"
> >>       ,(bicep-langserver-path))))
> >
> > You mean eglot-server-program, singular (that's what your patch propose=
s)
>
> Oops, yes.
>
> > Anyway, your patch is more or less what I had in mind altough:
> >
> > * The name should probably be something less confusable with
> >   e-s-programs, like eglot-suggested-servers or eglot-preferred-servers
> >   (note that it can still be "servers!" unless we purposedly cap that
> >   ability, which we maybe should).
>
> I have no opinion on the name.
>
> > * It's a bit silly to repeat the major-mode symbol in it.  So the
> >   setting in the major-mode function should be something like
> >
> >     (setq eglot-suggested-servers '("dotnet" ,(bicep-langserver-path)))
>
> That's what I started with but then I saw that `eglot--lookup-mode`
> returns info that includes part of the `car` of the elements in
> `eglot-server-programs` (IIUC it's so as to know which other buffers and
> major modes could share the same server), so rather than try and learn
> how that part of Eglot really works, I went for a simpler change.

Right, I see. But to do these kinds of changes to Eglot, "how Eglot
really works" is a prerequisite :-)  And you have understood it,
in essence.

The thing is, we're going to bump into that old "mapping the language"
can of worms eventually. Language servers are for languages, so
as it stands what major modes may want to say is "I want to participate
in managing this language".  But even that is fairly awkward.  To do
this right, we'd really need a language hook. And I have 0 time to open
that can of worms.

As it stands, looking at the `eval-after-load' code for bicep-ts-mode,
I wonder if it is really a "funny dance" or just the way it should be
until past decisions are revisited (but not by me :-))

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 21:12:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 16:12:40 2025
Received: from localhost ([127.0.0.1]:43034 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlDqZ-0004Z1-W2
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 16:12:40 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12543)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1tlDqY-0004Xk-5Z
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 16:12:38 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4F2D0442AD3;
 Thu, 20 Feb 2025 16:12:30 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1740085948;
 bh=Nb6I6+LVqvBJHt1nFELiMzLXI4ZPQbIdqZoYTwk5I70=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=kRDoBVM+/sEheixH4cBYH9/YaMAPXq0BxuFc1AP5rzh0SRMKPt24StgJLAi0Pahbf
 1cwkEXAzT2a2Wt+/LnF1dDzL4TMAit0/VErAvVW42xNQ6aG4zQTZTUpaxYc6Is0CnY
 7F/e/FN/5N9dSw64etNwS5xGAu+NZo9dlxMQidTuOTJ+9Ir/cd/uxfn3fIrKe20kUe
 GSLcJ/K8g/uViP/jLcsrfkv0DjJ1vUG8rlrX/OvGrAKv9YkT9vZr3B3LB/2vU9X+F8
 ZNvrEFIH7x+35HE8/iJgNhS7a+Skfb8bLm883/T8ebHV0SLk4qhgnK3zAPl3iGYOsV
 3/6BAvd/8++BQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BE5CA44299D;
 Thu, 20 Feb 2025 16:12:28 -0500 (EST)
Received: from alfajor (unknown [23.233.149.155])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A2271201BB;
 Thu, 20 Feb 2025 16:12:28 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= <joaotavora@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <87r03sfkun.fsf@HIDDEN> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?=
 =?windows-1252?Q?ra=22's?= message of "Thu, 20
 Feb 2025 19:59:44 +0000")
Message-ID: <jwvcyfcpbx5.fsf-monnier+emacs@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN> <87r03sfkun.fsf@HIDDEN>
Date: Thu, 20 Feb 2025 16:12:27 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.004 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>>       (setq-local eglot-server-programs
>>                   `(bicep-ts-mode . ("dotnet"
>>       ,(bicep-langserver-path))))
>
> You mean eglot-server-program, singular (that's what your patch proposes)

Oops, yes.

> Anyway, your patch is more or less what I had in mind altough:
>
> * The name should probably be something less confusable with
>   e-s-programs, like eglot-suggested-servers or eglot-preferred-servers
>   (note that it can still be "servers!" unless we purposedly cap that
>   ability, which we maybe should).

I have no opinion on the name.

> * It's a bit silly to repeat the major-mode symbol in it.  So the
>   setting in the major-mode function should be something like
>
>     (setq eglot-suggested-servers '("dotnet" ,(bicep-langserver-path)))

That's what I started with but then I saw that `eglot--lookup-mode`
returns info that includes part of the `car` of the elements in
`eglot-server-programs` (IIUC it's so as to know which other buffers and
major modes could share the same server), so rather than try and learn
how that part of Eglot really works, I went for a simpler change.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 20:01:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 15:01:14 2025
Received: from localhost ([127.0.0.1]:41874 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlCjR-0000uk-Bt
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 15:01:14 -0500
Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:57377)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>)
 id 1tlCjN-0000kD-Dk
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 15:01:10 -0500
Received: by mail-ej1-x629.google.com with SMTP id
 a640c23a62f3a-ab78e6edb99so194268366b.2
 for <76423 <at> debbugs.gnu.org>; Thu, 20 Feb 2025 12:01:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740081663; x=1740686463; darn=debbugs.gnu.org;
 h=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=iYztawKaqgCs1jBBL8aCGV4S7jTN2W8VewD3uAOZWFs=;
 b=Hx/tClCxanOOJTFYrl5FjDiFAc2VvZSTVE1VmzQwJxMMAtKJuZPMrgVBFlIuIMe6kN
 VmT++NBZN36bFOyviJv8KEv0p/lFkhSkdneQrvTwW3HdiMcBPC14wysyVZMjHPSG/uYl
 /40JA0apOAW7JKDlY/AGCbslFPiDrm2IkHdHtKv1ZZIEgiU9EEA3FVse2MaPmrhcFWA4
 N4CvuqnTTwKD5wkgmA08YiKN+KvZrW1pxGDyjHDUlPRxe10JKxsthw6Kxh0cOLRIdGWB
 GpTdflFKlfd+kQUdENC4N0QDHI4aVE2mm19dM5ff5fJNM5vcl/3Ke/cw6GqFZeMyrvp7
 f4fQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740081663; x=1740686463;
 h=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=iYztawKaqgCs1jBBL8aCGV4S7jTN2W8VewD3uAOZWFs=;
 b=uxYJMXFtMkHxYQGQbX4dSDL58a5eljWAooP0pgnIKRBIBM706tJfo44DujUUO9IHIj
 AU6jht+W7GDpIogpPUbPbf2RWF2Z2SKz9wkfBRXq9jPfptfBhB+rv4U9AWzDApMViP5G
 WyoYnW3Dgcvn7Laexk16kxRVupGqctxPVfx7XMObe69CLf+Df+2L+uyBbcI9os8Mr0V1
 cAtmgXri+G3fdMNibnokZOf5MHiNMfEKjRE9xdikfe0nGYM9PSsnlupGO+bzqDJ7SmBs
 GjA5Jew0VL9nanEY2c5hlWfu2OWUsEv+5OVHGYcv9Ab2T6DhDPCCWkOtkuWX+3QgawL4
 rD6g==
X-Forwarded-Encrypted: i=1;
 AJvYcCXpfTULQ8eDFMSpQFQdQ0V3UpCeMZaZyM+MxGQbljQAlwTV5qfGdN+qPmnVV1gzwTv23PTpHw==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YxN66Kl/UBE/fK8UImY/IUpFARu8A0BHv2NX46VjKY++TJsmXmG
 wQcy3WNFvr3+EP94DWZS6zeJUc/Xe57aF0iDZtUMCyRfKArQXDGq7BrT/Q==
X-Gm-Gg: ASbGncuYjm2dh+DUNI9rm4FEoeNEzIOPG2CkeVttVYJ+/CpBDeHTXXcmF/29uZAj0ky
 f3ikVsqYDKENkuJzDNZfsnlmdxzwyhW6dVM9wuDjLMY/EOgKG+1l0MwYSwQHMVib9oqqnNfM7Ho
 mDJNE9VNNcdh9HqJvV35JlB8S29s7NUj1rSXoTiZSnXhvCFxIiOfjCp/yHZhFwo3OtswodCHg33
 j1zfJew2r6B+PhjRH7AzU/AFrH2PbuwQFSkiLlPbIte5eEcRaogu+6yYpOJF4Aot9Aa52oSgAnB
 flq9byTZ4Wdx4kzZYSJCq9csR8kAqw==
X-Google-Smtp-Source: AGHT+IHDhn/RfjDyLVdUPqQ6KawG9tVYL9JeRJ/6JLEx1shcE8duMZ9LmrAhZq/urIKAuUSbOKjnUw==
X-Received: by 2002:a17:907:7242:b0:abc:4b7:e3d3 with SMTP id
 a640c23a62f3a-abc09abed3fmr62686366b.27.1740081662690; 
 Thu, 20 Feb 2025 12:01:02 -0800 (PST)
Received: from krug (87-196-76-63.net.novis.pt. [87.196.76.63])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-abb916db37bsm916307666b.165.2025.02.20.12.01.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Feb 2025 12:01:02 -0800 (PST)
From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
To: Kevin Brubeck Unhammer <unhammer@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <87v7t4evhy.fsf@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN>
 <87wmdl4n6u.fsf@HIDDEN>
 <jwv34g97fa8.fsf-monnier+emacs@HIDDEN>
 <875xl4udg7.fsf@HIDDEN> <87v7t4evhy.fsf@HIDDEN>
Date: Thu, 20 Feb 2025 20:01:15 +0000
Message-ID: <87msegfks4.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: 76423 <at> debbugs.gnu.org, Felician Nemeth <felician.nemeth@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Kevin Brubeck Unhammer <unhammer@HIDDEN> writes:

>>>> Wouldn't the patch make harder for the users to customize Eglot to use
>>>> their preferred LSP server instead of the server suggested by the major
>>>> mode?
>>>
>>> Could be, tho it depends.
>>
>> To me it seems both the current and the proposed approaches are too
>> complex for newbies, but quite straightforward to write with a little
>> bit of elisp knowledge.  So maybe it is enough to add some simple
>> examples to the documentation.

Who wrote this?  I agree :-)

>> Or we could have two variables defining server-programs:
>> eglot-user-server-programs and eglot-server-programs (alternatively
>> eglot-server-programs and eglot-default-server-programs.  Where the
>> former is only set by the users and it takes precedence over the latter
>> if there is a match in it.  But it is possible that I'm once again
>> overthinking this.

No.

> I would prefer that solution over users having to understand and/or
> copy-paste lambdas, eval-after-loads and setq-locals.

Please see my reply to Stefan.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 19:59:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 14:59:43 2025
Received: from localhost ([127.0.0.1]:41850 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tlChy-0007lD-Ss
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 14:59:43 -0500
Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:49391)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>)
 id 1tlChv-0007js-Q9
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 14:59:41 -0500
Received: by mail-ed1-x52b.google.com with SMTP id
 4fb4d7f45d1cf-5deb1266031so2480685a12.2
 for <76423 <at> debbugs.gnu.org>; Thu, 20 Feb 2025 11:59:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740081573; x=1740686373; darn=debbugs.gnu.org;
 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=oeJcMIAbp8o4m3M70VwUV4DIIKMqCUnhiCr2rj7tx1Y=;
 b=NdWKOVZ8HHYaVeXs3jbGYKAaspPTAXh0UQHliloabpkLfLL2wMBRxoF38mWvoz7Ik5
 VkVOtRVObEOl1xfM84y1eXcuGl2h/87CivobzH/h+EUjFrVSPbbDamPIxDfJjOMl+E30
 XgsqFBk7KSPkhWb/Cq47c+JDFDochVDPHSGesUHRKZMj8lBYZBe+KcaZIwApoG/2R5Cr
 4ho4NG9pDGlzIRyWNfZQ8RrtGF2SibSs3o6yjOfRlW00vDIsm5yMoh2G8Mwz2DZuTRjy
 J2hg04Zxje41kWwF+SslG53g7FGj+lxB35Qas/POhSMZwAow48+IFKPcrmbr9V9qfkl1
 +AWg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740081573; x=1740686373;
 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=oeJcMIAbp8o4m3M70VwUV4DIIKMqCUnhiCr2rj7tx1Y=;
 b=Cj8V6WGsGoIVohZPOglME7J7J35R0TuyUyJTZg/aS88DwrwF7hmQt9JUKUejUzvQ69
 CTRzGnqB8+DHkWAOrclku8boj35tQLrL/5bYCwJy8cD851Y3n6Wtr2R9T4ojpkrKbYpu
 OKEqibBgOCl21m6XO8+Tb0CjsH3oheIlnK1ShfRiRXcMUVeZcPaAecTLLDmFcWKkwIOi
 83ZOglEfTu2E5mejEYYT0NY41fCROGT37UJYhoU9YOhvzFqEJb2ZTKq7ESykUCvw306C
 5HdNkpt7kRMw2FS3dcW2ShcNuI2i3mGkE7sDOXAQREmOsMg1ZWWT8ZZ/hN808qUnDz3N
 +/iQ==
X-Gm-Message-State: AOJu0YxoFA+jsm+I81LctcEl/UJc9w9Fap+ryKWEiYd3vaoEQ71osmpK
 Cv0npOdvomj/RjZ6qG5WFV23i88bYdcMVguoK0YLn22pR0IuSATL
X-Gm-Gg: ASbGncuHpoezGTgsidYDRp+TZ58m4umprI75zlSVj2JDmyLsKFj50W3eu0cRC+6c7f0
 8XpprXL79jLcUhkE0CfoPmAtzqD90DBWYiThTT33jYYnhUMLasEjqa+KM1i+FB1tQRcmVn3qsTF
 q9qKtHEOeN12hrziikKbTU629ggN61LGC26XXQAj9QigmeVOELl/e8wVqPVgzAJs5VO1GvMwxvi
 tbZo7JA1Y3Q8xQEKGSkhARonMrMHXMgKqgo1QIK/hZrjni7UGeKYT+fZoRLnjGyq5wxURhnOfvU
 fRQOiBsPaaBXxD0HRJl/J1e4+rqvug==
X-Google-Smtp-Source: AGHT+IEdlu4hu8iLNPeSk9Uw6TvJ4qZDOUbMOsp8SA7xWb4DlU0hfl8Lf36iZQAp1ETBGH5Y8lZqxQ==
X-Received: by 2002:a05:6402:3583:b0:5e0:9ffa:1348 with SMTP id
 4fb4d7f45d1cf-5e0b70cb619mr171810a12.2.1740081573178; 
 Thu, 20 Feb 2025 11:59:33 -0800 (PST)
Received: from krug (87-196-76-63.net.novis.pt. [87.196.76.63])
 by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-5dece286861sm12345498a12.67.2025.02.20.11.59.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Feb 2025 11:59:31 -0800 (PST)
From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <jwvcyfd7jzw.fsf@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN>
Date: Thu, 20 Feb 2025 19:59:44 +0000
Message-ID: <87r03sfkun.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier <monnier@HIDDEN> writes:

Hi Stefan,

> The patch below would let this major modes do it with a simple:
>
>       (setq-local eglot-server-programs
>                   `(bicep-ts-mode . ("dotnet"
>       ,(bicep-langserver-path))))

You mean eglot-server-program, singular (that's what your patch proposes)

Anyway, your patch is more or less what I had in mind altough:

* The name should probably be something less confusable with
  e-s-programs, like eglot-suggested-servers or eglot-preferred-servers
  (note that it can still be "servers!" unless we purposedly cap that
  ability, which we maybe should).

* It's a bit silly to repeat the major-mode symbol in it.  So the
  setting in the major-mode function should be something like

    (setq eglot-suggested-servers '("dotnet" ,(bicep-langserver-path)))

As to the precedence logic which you all discussed in the following
emails, I think it is indeed a problem.  But I don't see a problem in
prioritizing eglot-suggested-servers.

* The user can always nullify it with a

   (add-hook 'foo-mode-hook
     (lambda () (setq eglot-suggested-server nil)))

  I don't see this as a hindrance and I don't want to add much extra
  logic to Eglot to manage this for users afraid of add-hook.  The Eglot
  manual already uses these add-hook snippets and as long as people know
  to copy-paste.  If people want to the use-package macro magic to keep
  themselves ignorant of how Emacs works, I think that's a mistake, but
  this shouldn't stop them.

* Nevertheless it should be possible to add some logic to eglot.el to
  discover if the e-s-programs variable has been modified.

* It's important to note that this effort by itself won't bring many
  advantages until major-modes can somehow know during their normal
  working that eglot-suggested-servers hasn't been touched and that a
  particularly friendly server has effectively been started (either by
  M-x eglot or by the major mode itself, with appropriate care).  Then,
  foo-mode will be able to provide specific `M-x foo-thingamabob`
  commands that make use of an LSP connection, much like python.el or
  ruby-mode.el provide commands to send a region to the interpreter,
  etc.

* I'm against adding eglot-server-user-programs or somesuch as someone
  is proposing.  I only want to add a new variable to be settable by the
  major mode.  And ideally it should come with examples of major-mode
  patches with such added functionality for the "friendly server", else
  what is the point of having the major mode even set it?

Jo=C3=A3o

PS: something that I didn't mention in my recent reply to a patch about
this in the mailing list by Philip Kaludercic (posted to emacs-devel I
think) is that none of these efforts shall break eglot.el from being
compiled and loaded in older Emacsen (his patch did that).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 10:55:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 05:55:19 2025
Received: from localhost ([127.0.0.1]:60948 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tl4D8-00073y-Dv
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 05:55:18 -0500
Received: from fforwardl-b2-smtp.messagingengine.com ([202.12.124.193]:45047)
 by debbugs.gnu.org with esmtps
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2)
 (envelope-from <unhammer@HIDDEN>) id 1tl4D5-0006y4-Cu
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 05:55:16 -0500
Received: from phl-compute-09.internal (phl-compute-09.phl.internal
 [10.202.2.49])
 by mailfforwardl.stl.internal (Postfix) with ESMTP id AD40322C064F;
 Thu, 20 Feb 2025 05:55:08 -0500 (EST)
Received: from phl-mailfrontend-02 ([10.202.2.163])
 by phl-compute-09.internal (MEProxy); Thu, 20 Feb 2025 05:55:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-type:content-type:date:date
 :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:subject:subject:to
 :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=
 1740048908; x=1740135308; bh=bQAtBiySYrNZL9ttucgnw5YbyKlVd8SNssA
 duLx1REY=; b=WqMkdy+Nioy8QhHi96AbtmXkmSFSR2R+SG+CkU3jKkzy28tFeVa
 M4BKozP4SV6tj7s5OLl2r1bFzC9B6tcipqaXxhdbVeCx0UTulPDr9FTSyi1Wscli
 jdaftpXTGzUveHGZtvEquB8V96owpLuXnO1mk5rmQ0bQKkmYyr//3vZDYDwgMF+7
 IAEQ4PgOLlgixBUTQVdkztMN7BctV1WL23U8+aM0X5QtKXfhoHE3Gu+78jMHgnPj
 J4Cw1NpcM4jpXolANzexWrWXUSfOQEOCsz1iXfH7fphaclk1mPdLmrgIrYwx3l95
 ZlKf/7J2kCKpuwQaq4q954veVNr55c5Li0g==
X-ME-Sender: <xms:Cwq3Z2AhpGW5roP75WABflJVHYEvY8TMmC7ngXMsxyRIDJ23-pAuCg>
 <xme:Cwq3ZwiSVAlfWNuZ5fFDgPwPLLT9hKvxdkIaPQsg0GgK1oboDqWUA73gCmMJe979z
 u8t0dTYiO_rFg3R>
X-ME-Received: <xmr:Cwq3Z5m19XrvLYHsLh_rD1Ks4zxlqHFDv2Gg-vmW0ptkLxCFYPFVFNyCzA_IewE>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeiieeliecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp
 uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg
 hnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfgfgggtsehttdertddtredt
 necuhfhrohhmpefmvghvihhnuceurhhusggvtghkucgfnhhhrghmmhgvrhcuoehunhhhrg
 hmmhgvrhesfhhsfhgvrdhorhhgqeenucggtffrrghtthgvrhhnpeegvdffvdekffekteel
 jeeutdeltedtvdejleevtdethefggffhfedtvdffieettdenucevlhhushhtvghrufhiii
 gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehunhhhrghmmhgvrhesfhhsfhgvrdho
 rhhgpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhope
 hjohgrohhtrghvohhrrgesghhmrghilhdrtghomhdprhgtphhtthhopeejieegvdefsegu
 vggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepmhhonhhnihgvrhesihhrohdruh
 hmohhnthhrvggrlhdrtggrpdhrtghpthhtohepfhgvlhhitghirghnrdhnvghmvghthhes
 ghhmrghilhdrtghomh
X-ME-Proxy: <xmx:Cwq3Z0w0tXdhdeoiwk6KP6DIe-vvbOuaIvjBeL_sfOPd2P7HhDKaXQ>
 <xmx:Cwq3Z7RQdx_Pl9q-coOrGLgWAy9cy_Z1GQ9JtD0epKxQ5BF-yX-e5w>
 <xmx:Cwq3Z_awJZdPoFe5sP4GYTGa5M9l2QD9umPagYR3UiEwAvppZ20jLQ>
 <xmx:Cwq3Z0TubiH5Ho24eWQ3g1qmACR2v9uQ41q47OsPQI1S61-Mr5twfg>
 <xmx:Cwq3Z9BXrY0cu8i-xXo3xUu138umtO66uB98FA0NtWGQ5p-NESsatQ>
 <xmx:DAq3Z6Ge3OFalraN963LnLztnFmZWSx8UCAgjym7sVFa1XenIJji0upt2-Th>
Feedback-ID: i26a44175:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 20 Feb 2025 05:55:06 -0500 (EST)
From: Kevin Brubeck Unhammer <unhammer@HIDDEN>
To: Felician Nemeth <felician.nemeth@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <875xl4udg7.fsf@HIDDEN> (Felician Nemeth's message of
 "Thu, 20 Feb 2025 11:18:16 +0100")
References: <jwvcyfd7jzw.fsf@HIDDEN>
 <87wmdl4n6u.fsf@HIDDEN>
 <jwv34g97fa8.fsf-monnier+emacs@HIDDEN>
 <875xl4udg7.fsf@HIDDEN>
Date: Thu, 20 Feb 2025 11:55:05 +0100
Message-ID: <87v7t4evhy.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 76423
Cc: 76423 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>,
 =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

>>> Wouldn't the patch make harder for the users to customize Eglot to use
>>> their preferred LSP server instead of the server suggested by the major
>>> mode?
>>
>> Could be, tho it depends.
>
> To me it seems both the current and the proposed approaches are too
> complex for newbies, but quite straightforward to write with a little
> bit of elisp knowledge.  So maybe it is enough to add some simple
> examples to the documentation.
>
> Or we could have two variables defining server-programs:
> eglot-user-server-programs and eglot-server-programs (alternatively
> eglot-server-programs and eglot-default-server-programs.  Where the
> former is only set by the users and it takes precedence over the latter
> if there is a match in it.  But it is possible that I'm once again
> overthinking this.

I would prefer that solution over users having to understand and/or
copy-paste lambdas, eval-after-loads and setq-locals.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 20 Feb 2025 10:18:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 05:18:26 2025
Received: from localhost ([127.0.0.1]:60588 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tl3dS-00038I-Fc
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2025 05:18:26 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:42492)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>)
 id 1tl3dQ-00037m-O7
 for 76423 <at> debbugs.gnu.org; Thu, 20 Feb 2025 05:18:25 -0500
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-4399ee18a57so4392235e9.1
 for <76423 <at> debbugs.gnu.org>; Thu, 20 Feb 2025 02:18:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740046699; x=1740651499; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=ieBboMO0SaS5Q0s/3ubaOEy/gkS/hYJEIZToi312f5Y=;
 b=QtR3nddfVY91dKkXbEWdkS0JPAwuFKhoFKu/8ByUT5iRt3SOdB6VOZgIoLRgl60sx3
 P/N2HrOPFLaEMSdlhgaw+FjtdSVdWhYOwfpT3KKVxzqWXqOQLipq/68Z2JqIpKBQRbKR
 oFjGFtnfyvp693zltvu6topPvJSNzUlB5gaPoMaXqZcVVxv9qiZiYSARFbP5VlfVrxC0
 Z1jDYgB2mBa/aE3mAfb+XGRtioYzN5vJLEHzN9eZG/ktqsGzvuP3+YpwqqiQClhGf87K
 4wJkRKieUmBaoxMR7vr6/xlbHVUQkld1fBasQPrjtLObJoC7c7KXl46FNzdhu0PDkDom
 2/qQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740046699; x=1740651499;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=ieBboMO0SaS5Q0s/3ubaOEy/gkS/hYJEIZToi312f5Y=;
 b=jzco8qLf31lLwQpM8TKfqHwzSzno+jGXfIVWYcto5yj0MamHZLNJ4ytS89MPYi6Y3C
 9k/p0cXpY8Yi81Idpqm3pDw42moBVJurlDFiOUR2/4xnw6OeoQnyia+GX1jrLQCUNPi9
 1pPCXNlUGeVTBFOs5MPN2dMkm6uQ9eBUbgNcZ5zp2D+fuZ7IIMKjcJkhx0GkCCawhjYH
 TRi71wz9NRAzjv3j+8i59NwTAl/353lRSVw6YXBk/Oln4qyapCGxOI97HQLXsZjKyT41
 t+gio+cqb8TF/QZLDGRHLvqOD3JkbTrnDHd95M4QOz9uIBatTQ6+W/Xga+LH3GfZ/P8a
 6xww==
X-Gm-Message-State: AOJu0Yw97ImAQP7ODxQf9D/me5lJlGiTRL5jSH/+mwJY9RaapSQhPNJn
 VJxrq9VKY1MFm3GZqpdgqnFy1RL/2UtO3iy+HFXFiZAZNNpxD8Yu
X-Gm-Gg: ASbGncuEkPmqNeJtRpc2fvJK4cfV39sfYwaMySIYe+To/qwoeOX2+IyONIwgXbcH3OF
 vf05JgUxZneg7Np8WDChd5SQpQ7lSdQCTrNpjaD4wM+yXxhg0kS0edxTXyMfXJ4QeTMPZpSxRdK
 IkH67E+ph2Fq2CVFsTgbCrWhNcdYKen+fGd1q69OeiVHnukYVyEDGcVoud0W3NNlcI+XxaEENlJ
 dxJPiZCNPWzuy6y+JXKmcEec8gKEWedbD6pP5wED/s8O2Zf3pGxXYsCzl6tCx2sAY0wBp50ZENy
 Ru9v0TEPiuXMPyqFw0za3jGUHTsf5A==
X-Google-Smtp-Source: AGHT+IE1PznVOwhJ3u+haDdNzZQiOZYzv7nU4NRqBqof55kqwhWRntg8sFe3xSRDuMP2ZSQDlFJNog==
X-Received: by 2002:a05:600c:4784:b0:439:8605:6d7c with SMTP id
 5b1f17b1804b1-439a2864c3cmr22018475e9.0.1740046698302; 
 Thu, 20 Feb 2025 02:18:18 -0800 (PST)
Received: from ulti.gmail.com ([2001:738:2001:407f:d329:3c92:fe6f:14c3])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4398a64febasm97411145e9.1.2025.02.20.02.18.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 20 Feb 2025 02:18:17 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
References: <jwvcyfd7jzw.fsf@HIDDEN>
 <87wmdl4n6u.fsf@HIDDEN>
 <jwv34g97fa8.fsf-monnier+emacs@HIDDEN>
Date: Thu, 20 Feb 2025 11:18:16 +0100
In-Reply-To: <jwv34g97fa8.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Wed, 19 Feb 2025 17:22:29 -0500")
Message-ID: <875xl4udg7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEWOdXElERN7LDLZs6/l
 0dDQq6TepMcqAAACW0lEQVQ4jWWSzY7bMAyEaSm6mypylxjkroTRvUW8d9lavf+r7NDOZotWQHzg
 lyGHP0Sn5ed9qKrLWWIWos9/QJWIeCSywPNTd/AE0LtwFj7A+3WT5PwfeBrQKcsBnkfwVcNySWQr
 3i34XN6gRNgis/v4uwSKHCD9lPitB0Aq9BHfHX4cgsI7cJJfLdZg/4bbCzoRmkD9MsagQSBDedZi
 CgNxkVSJmSOStTBUBKkywEnEoZzbwWj+ACiVJkF6pOpak2PMCqkMYDpaw+gatLR8atMOrB3JGzmm
 3rSQo+tkxU+UAbhQSgtslULhsXKk6+IyQ1QTzeQB0MzjlpkCEUCeUdviWrwBcxVqpZjP+v0MYPA0
 aq2rvIEZe4GRM0v+9QIB03rsABVSk5y+Mz3LSzExtJLlCCO6dV1uzDQFTBad+gO0TqqL9XE8x4ek
 +orvYiMJgzC8e+r6TqaPaK6QyqVNvoHtsRrooQ6tTi4vgaSkd8wIikodB3B0iIk58avsDdYNajpS
 bSKJ+mQnipGszB6zW4lGgsOkKHE2RWVcBpwhaIv3BYIAu3WsnC7YYKLRchp6w8fRGZIWiZuFsVai
 7gbcUcJEhiDZ3K1+uzZvBlfaEO8oH4MLu6/hrKVM7QpQcIXJFuC1XjfbfKRxNslk94l9cYcEihV2
 HWyNDQAXaLsvnrSyp7HaQhrAn13V6/XW11nh0XINBOEAV+tHK4EvAGNGvEwc0eZw8Vyr56imYEsV
 sOW9jxm/yb9AH1ufqGMviIK7A0Tc/723oM3tJ4HTOu9gDr3ftbdkxfdjsUv5AqWKwyfCYo5WAAAA
 AElFTkSuQmCC
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org,
 =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>> Wouldn't the patch make harder for the users to customize Eglot to use
>> their preferred LSP server instead of the server suggested by the major
>> mode?
>
> Could be, tho it depends.

To me it seems both the current and the proposed approaches are too
complex for newbies, but quite straightforward to write with a little
bit of elisp knowledge.  So maybe it is enough to add some simple
examples to the documentation.

Or we could have two variables defining server-programs:
eglot-user-server-programs and eglot-server-programs (alternatively
eglot-server-programs and eglot-default-server-programs.  Where the
former is only set by the users and it takes precedence over the latter
if there is a match in it.  But it is possible that I'm once again
overthinking this.

Felici=E1n




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 19 Feb 2025 22:22:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 19 17:22:44 2025
Received: from localhost ([127.0.0.1]:53932 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tksSp-0004eM-ME
	for submit <at> debbugs.gnu.org; Wed, 19 Feb 2025 17:22:44 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48107)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1tksSk-0004dJ-8n
 for 76423 <at> debbugs.gnu.org; Wed, 19 Feb 2025 17:22:40 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 26E8244290A;
 Wed, 19 Feb 2025 17:22:31 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1740003750;
 bh=XloWYEc4B534V+4qgxKaqkXEmm7zO5X0gOoRx46Z2+c=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=O6y9Oo9K97EfqG7rOlswD9oYQvtAy9Axsk+Ox7xxqEzlCxfp5njCbVnAuLBdp2ziI
 rv3KAN54pPjEQXhJjk9CDajrh5FJMj1GX3nFstwd5prg8x1HXoaraS6nEqv24s71gZ
 eh4w4jfU6CFEqstBmGBqr9Vkk8+PgqGWXuq3P/Dlat5XZmUkrCjBItlQSVp0CAvtpj
 9eQ9WFqQ5SCqyM7jMV0jeHG/kC/1opk7QziEbNBoTRV2V6aYMVotanYo/uc2qkTojZ
 2aBG6cOeeNaFwf0orazuklaxaw/eMa8slpEUur8vjKO4GYcQb2Nltwzh8jZ3Hj4Bgx
 1ccPYl2uJBSfw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 02709442906;
 Wed, 19 Feb 2025 17:22:30 -0500 (EST)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E5BA61200BA;
 Wed, 19 Feb 2025 17:22:29 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Felician Nemeth <felician.nemeth@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
In-Reply-To: <87wmdl4n6u.fsf@HIDDEN> (Felician Nemeth's message of
 "Wed, 19 Feb 2025 22:52:25 +0100")
Message-ID: <jwv34g97fa8.fsf-monnier+emacs@HIDDEN>
References: <jwvcyfd7jzw.fsf@HIDDEN>
 <87wmdl4n6u.fsf@HIDDEN>
Date: Wed, 19 Feb 2025 17:22:29 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.213 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org,
 =?windows-1252?B?Sm/jbyBU4XZvcmE=?= <joaotavora@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> Eglot should make it easier for major modes to suggest which LSP
>> server to use.
>
>> The patch below would let this major modes do it with a simple:
>>
>>       (setq-local eglot-server-programs
>>                   `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path))))
>
> Wouldn't the patch make harder for the users to customize Eglot to use
> their preferred LSP server instead of the server suggested by the major
> mode?

Could be, tho it depends.
AFAIK they can't use Customize to do that because packages (like
`bicep-ts-mode.el`) modify the variable outside of Customize's control,
so currently they have to do something like:

    (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER))

which may need to be adjusted to

    (with-eval-after-load 'eglot
      (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER)))

or

    (with-eval-after-load 'bicep-ts-mode
      (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER)))

With the variable I suggest I guess they'd have to do

    (add-hook 'bicep-ts-mode-hook
      (lambda () (setq-local eglot-server-program '(bicep-ts-mode . MYSERVER))))

I know some people find `add-hook` and `lambda` more scary than
`eval-after-load` and `add-to-list`, so I guess it would count as
"harder", yes.

Maybe we should offer an actual `defcustom` variable for user overrides,
if we care enough.  Personally, I prefer to work on making the
`add-hook+lambda` approach more accessible, because it's just very
flexible and powerful, so it's much more generally useful.
One such effort is to use `use-package` or `setup`.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at 76423 <at> debbugs.gnu.org:


Received: (at 76423) by debbugs.gnu.org; 19 Feb 2025 21:52:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 19 16:52:39 2025
Received: from localhost ([127.0.0.1]:53610 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tkrzj-0001E8-2f
	for submit <at> debbugs.gnu.org; Wed, 19 Feb 2025 16:52:39 -0500
Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:61619)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <felician.nemeth@HIDDEN>)
 id 1tkrzc-0001CW-S1
 for 76423 <at> debbugs.gnu.org; Wed, 19 Feb 2025 16:52:34 -0500
Received: by mail-ej1-x633.google.com with SMTP id
 a640c23a62f3a-abb8045c3f3so38775966b.2
 for <76423 <at> debbugs.gnu.org>; Wed, 19 Feb 2025 13:52:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740001947; x=1740606747; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=G5IJPmFHOK47IvwcsEMxENqs/1xYuNXcibBjxC+ZjTE=;
 b=bM/5I8UYjIAl8QudEepvmxBYhF4bT8TqOJw8V4wgqoPxGBM/cxHx83tHO1MKFi934W
 wdL/63EYFZTS7V/5eP+gJl6zMwKoqZhIdzTACg797kSAoTZa2lfqBsnSdgPv6jkeemzM
 4LkNKFE2e5LwkKcddUwCSbvy2gYsB5FkA4QugFpYXMX4AI1sQrFQyA3n5oQ0dYmtNAir
 f9LBzB7285RovE/hFBw3SLqqNxpJU5T1dVmvi8TkcHR0sQH2bqUY+o/9X8K2lVb56zg6
 IvHGMlidRn2pgTs4SZ7LYnWF96Mxg7vh4STAKg1kl59lukpW3lhVD9Bv5M7U85g/oNy+
 /HaA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740001947; x=1740606747;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=G5IJPmFHOK47IvwcsEMxENqs/1xYuNXcibBjxC+ZjTE=;
 b=Xw70Lhkj4UubtxnxGbnolhxk9+LwDzYhZW05Hj1tOXwH4J4dF4gvf5ByqbUpoEUTpH
 Crijw05R+zulW5GHRUd5yv3eGJXNB2/lifZvVhH84QF1ioxtYlLkNaFxHgpUuQiG/Wgh
 p0wLKRssCBi3+AXF4SRHkXZGg9aUSeeds4UGBE3bItTLUIDUHTipKArOxV8Ocr8ZKlQY
 fX5XCqe6gLUcSnCPCb0lZ4mwbQv47kGcImGt/JbJ99kXugGFWMHgoAARCAT2+Bi7XiSs
 ocOHR8QH0OhPYS3+UWZUAKAt+HnBxysNUB9rLqsdVd2+DdXxftq+0sOb+kSCUYpIrX+e
 CiDA==
X-Gm-Message-State: AOJu0Yx0j5yLnW5DPS1+5FvRhdZgwCGlIQM1F296+uYpM9s6gDUTDSTi
 GNiFdkClrNFxzclFzNS2IKwNy6F61Th2AMFS1AjQ1EJ9qbjFkmpp
X-Gm-Gg: ASbGncspKLih/nCAdqV/SQjvabxVDr2CfQW+O+C5OFIXCAFe/73qn92SIDwcE+2YJCd
 rfndM7txreXJ/hydmeZeqai6E4X4maqcp62odbEfylS+yxadkQSxqHET3dO8MmGNNW8mA8cj09y
 UN3aQLdmzcKTkU6lH6TFdFD8dklmrSTIc+tcl3e95GBHFGKdOJJTs7TC4b5zFAjCh9Q/QybIVae
 zMyeGFjqfGFJJSrWBVc5AB4XGXnTckEwe1rP36p1KAJo1nYZ1GApwis4QX6MOoNz5HJHLzsnNFZ
 UyGYRHKRDnhaM9RSJXZ8iOfymuUqs1NyeoZoJe2fj1yB1Au44HO6yD8yy2X9uZnXOoWK5XIn
X-Google-Smtp-Source: AGHT+IGQ2Jx0Oaiiie+LxngvkfqYs7Em51gOZxcHuaBMZHMKNVzACAC+qBTWJB0+H2YHRhF8fsrXEQ==
X-Received: by 2002:a17:907:6ea9:b0:abb:b294:6a2d with SMTP id
 a640c23a62f3a-abbcd0b9393mr487948166b.53.1740001946527; 
 Wed, 19 Feb 2025 13:52:26 -0800 (PST)
Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.one.hu.
 [213.222.160.137]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-abbac3242dcsm528066366b.107.2025.02.19.13.52.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 19 Feb 2025 13:52:26 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#76423: Major-mode provided LSP server for Eglot
References: <jwvcyfd7jzw.fsf@HIDDEN>
Date: Wed, 19 Feb 2025 22:52:25 +0100
In-Reply-To: <jwvcyfd7jzw.fsf@HIDDEN> (Stefan Monnier via's message
 of "Wed, 19 Feb 2025 15:33:07 -0500")
Message-ID: <87wmdl4n6u.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/
 //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f
 onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd
 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO
 Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh
 LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody
 JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br
 LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4
 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA
 AAAASUVORK5CYII=
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 76423
Cc: Kevin Brubeck Unhammer <unhammer@HIDDEN>, 76423 <at> debbugs.gnu.org,
 =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@HIDDEN> writes:

> Eglot should make it easier for major modes to suggest which LSP
> server to use.

> The patch below would let this major modes do it with a simple:
>
>       (setq-local eglot-server-programs
>                   `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path))))

Wouldn't the patch make harder for the users to customize Eglot to use
their preferred LSP server instead of the server suggested by the major
mode?

Thanks,
Felici=E1n

>
> - Stefan
>
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index bd28174e7da..3aff922be1d 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -235,6 +235,10 @@ eglot-alternatives
>                        when probe return (cons probe args)
>                        finally (funcall err)))))))
>=20=20
> +(defvar-local eglot-server-program nil
> +  "Description of the server to use.
> +Follows the same syntax as any element of `eglot-server-programs', ")
> +
>  (defvar eglot-server-programs
>    ;; FIXME: Maybe this info should be distributed into the major modes
>    ;; themselves where they could set a buffer-local `eglot-server-progra=
m'
> @@ -354,7 +358,7 @@ eglot-server-programs
>=20=20
>  * In the most common case, a symbol such as `c-mode';
>=20=20
> -* A list (MAJOR-MODE-SYMBOL :LANGUAGE-ID ID) where
> +* A list (MAJOR-MODE-SYMBOL :language-id ID) where
>    MAJOR-MODE-SYMBOL is the aforementioned symbol and ID is a
>    string identifying the language to the server;
>=20=20
> @@ -1331,7 +1335,9 @@ eglot--lookup-mode
>                                          (replace-regexp-in-string
>                                           "\\(?:-ts\\)?-mode$" ""
>                                           (symbol-name sym))))))
> -   for (modes . contact) in eglot-server-programs
> +   for (modes . contact) in (if (null eglot-server-program)
> +                                eglot-server-programs
> +                              (cons eglot-server-program eglot-server-pr=
ograms))
>     for llists =3D (mapcar #'eglot--ensure-list
>                          (if (or (symbolp modes) (keywordp (cadr modes)))
>                              (list modes) modes))




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Feb 2025 20:33:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 19 15:33:32 2025
Received: from localhost ([127.0.0.1]:52698 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tkql9-0000JM-P0
	for submit <at> debbugs.gnu.org; Wed, 19 Feb 2025 15:33:32 -0500
Received: from lists.gnu.org ([2001:470:142::17]:51280)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1tkql7-0000IT-09
 for submit <at> debbugs.gnu.org; Wed, 19 Feb 2025 15:33:29 -0500
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 <monnier@HIDDEN>)
 id 1tkql1-0008Uo-IF
 for bug-gnu-emacs@HIDDEN; Wed, 19 Feb 2025 15:33:23 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <monnier@HIDDEN>)
 id 1tkqkz-0004A1-LQ
 for bug-gnu-emacs@HIDDEN; Wed, 19 Feb 2025 15:33:23 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 240074428CF
 for <bug-gnu-emacs@HIDDEN>; Wed, 19 Feb 2025 15:33:19 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1739997197;
 bh=ZJSqmm56wUUic/2fvwbav46Wn6iQHGGEeW8f21Pnvi8=;
 h=From:To:Subject:Date:From;
 b=oHQltZxpQ46EHRX38lMqnl9wjHNPHjWl3fKHoKkCn5vPPhF2ihgRXkVCqFi1HNKyD
 4HSzGPty38UpJduAPzq1A0KEzkcx7iLKKUjQx1fu1Y+qgBncoZVdCI4X16JA/zz0K7
 SsrYaZ6y3KA/dT9iE2gdmUjzjrlfVO2yzbEo88dAhpp6SrfX5ReV6aYF28Kk1q/TnD
 Ad6+hb28belyAahzPRnlPisSjzw/g0A//nRKYLlUyVIM+TCmslAN2efOmge3FW1Ts4
 qlFc3lT0SD3fmef9OJh6FW8tMK3teSwKlSZyu8nzl3RhecBNtsxWCxCXFLD47N1VAn
 UCxi+lOjF0zHg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B7A024428CD
 for <bug-gnu-emacs@HIDDEN>; Wed, 19 Feb 2025 15:33:17 -0500 (EST)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A5CE012005D
 for <bug-gnu-emacs@HIDDEN>; Wed, 19 Feb 2025 15:33:17 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Major-mode provided LSP server for Eglot
X-Debbugs-Cc: monnier@HIDDEN,
 =?iso-8859-1?Q?Jo=E3o_T=E1vora?= <joaotavora@HIDDEN>,
 Kevin Brubeck Unhammer <unhammer@HIDDEN>
Date: Wed, 19 Feb 2025 15:33:07 -0500
Message-ID: <jwvcyfd7jzw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.534 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
 KAM_STOCKGEN              1.5 Email Contains Generic Pump & Dump Stock Tip
X-SPAM-LEVEL: 
Received-SPF: pass client-ip=132.204.25.50;
 envelope-from=monnier@HIDDEN; helo=mailscanner.iro.umontreal.ca
X-Spam_score_int: -42
X-Spam_score: -4.3
X-Spam_bar: ----
X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Tags: patch

Tags: patch

Eglot should make it easier for major modes to suggest which LSP
server to use.
Currently major modes end up doing funny dances like:

    branch: externals/bicep-ts-mode
    commit 8192a400fae45cdde32526f96bb7ed5158d98008
    Author: Kevin Brubeck Unhammer <unhammer@HIDDEN>
    Commit: Kevin Brubeck Unhammer <unhammer@HIDDEN>
    
        Wait with altering eglot-server-programs until eglot loaded
    ---
     bicep-ts-mode.el | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/bicep-ts-mode.el b/bicep-ts-mode.el
    index 204629b4c6..f047bccae0 100644
    --- a/bicep-ts-mode.el
    +++ b/bicep-ts-mode.el
    @@ -205,11 +205,11 @@ Return nil if there is no name or if NODE is not a defun node."
                                            . bicep-ts-mode))))
     
     ;;;###autoload
    -(and (boundp 'eglot-server-programs)
    -     (file-exists-p (bicep-langserver-path))
    -     (progn
    -       (add-to-list 'eglot-server-programs
    -                    `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path))))))
    +(eval-after-load 'eglot
    +  '(and (file-exists-p (bicep-langserver-path))
    +        (progn
    +          (add-to-list 'eglot-server-programs
    +                       `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path)))))))
     
     (provide 'bicep-ts-mode)

The patch below would let this major modes do it with a simple:

      (setq-local eglot-server-programs
                  `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path))))


- Stefan



--=-=-=
Content-Type: text/patch
Content-Disposition: attachment; filename=eglot-server.patch

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index bd28174e7da..3aff922be1d 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -235,6 +235,10 @@ eglot-alternatives
                       when probe return (cons probe args)
                       finally (funcall err)))))))
 
+(defvar-local eglot-server-program nil
+  "Description of the server to use.
+Follows the same syntax as any element of `eglot-server-programs', ")
+
 (defvar eglot-server-programs
   ;; FIXME: Maybe this info should be distributed into the major modes
   ;; themselves where they could set a buffer-local `eglot-server-program'
@@ -354,7 +358,7 @@ eglot-server-programs
 
 * In the most common case, a symbol such as `c-mode';
 
-* A list (MAJOR-MODE-SYMBOL :LANGUAGE-ID ID) where
+* A list (MAJOR-MODE-SYMBOL :language-id ID) where
   MAJOR-MODE-SYMBOL is the aforementioned symbol and ID is a
   string identifying the language to the server;
 
@@ -1331,7 +1335,9 @@ eglot--lookup-mode
                                         (replace-regexp-in-string
                                          "\\(?:-ts\\)?-mode$" ""
                                          (symbol-name sym))))))
-   for (modes . contact) in eglot-server-programs
+   for (modes . contact) in (if (null eglot-server-program)
+                                eglot-server-programs
+                              (cons eglot-server-program eglot-server-programs))
    for llists = (mapcar #'eglot--ensure-list
                         (if (or (symbolp modes) (keywordp (cadr modes)))
                             (list modes) modes))

--=-=-=--





Acknowledgement sent to Stefan Monnier <monnier@HIDDEN>:
New bug report received and forwarded. Copy sent to monnier@HIDDEN, joaotavora@HIDDEN, unhammer@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to monnier@HIDDEN, joaotavora@HIDDEN, unhammer@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#76423; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 23 Feb 2025 00:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.