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#60557: [PATCH] Fix eglot prompt when connection already exists Date: Thu, 12 Jan 2023 10:53:35 +0000 Message-ID: <87sfggrplc.fsf@gmail.com> References: <83cz7kksd2.fsf@gnu.org> 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="6932"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Evgeni Kolev , 60557@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 12 12:19:41 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 1pFvcR-0001cZ-9Q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Jan 2023 12:19:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFvCi-0001vC-Rn; Thu, 12 Jan 2023 05:53:04 -0500 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 1pFvCh-0001uI-Cj for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 05:53:03 -0500 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 1pFvCh-00067E-4V for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 05:53:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFvCg-0000dk-Bx for bug-gnu-emacs@gnu.org; Thu, 12 Jan 2023 05:53:02 -0500 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: Thu, 12 Jan 2023 10:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60557 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60557-submit@debbugs.gnu.org id=B60557.16735207312385 (code B ref 60557); Thu, 12 Jan 2023 10:53:02 +0000 Original-Received: (at 60557) by debbugs.gnu.org; 12 Jan 2023 10:52:11 +0000 Original-Received: from localhost ([127.0.0.1]:44785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFvBr-0000cP-Dq for submit@debbugs.gnu.org; Thu, 12 Jan 2023 05:52:11 -0500 Original-Received: from mail-wm1-f42.google.com ([209.85.128.42]:50742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFvBm-0000bp-Kr for 60557@debbugs.gnu.org; Thu, 12 Jan 2023 05:52:10 -0500 Original-Received: by mail-wm1-f42.google.com with SMTP id m3so12905562wmq.0 for <60557@debbugs.gnu.org>; Thu, 12 Jan 2023 02:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=an0w+T5vHW9BB7wODVMiOm654Rzn0OqK/IeCaRQIYK8=; b=cnZjSTRqiODxpVg6OYORLPHKJXC8hP3r5Q6UwGIv5QT/FdqLJZioKBwhDE2Rvhigy/ GlkC30tzLmqcETP+eN602j+QYWtBa2dP8HEy3YV7ettehqMuzcCoQ5CYExgp+m/8dZNJ 06xY5uYA88Rsxbny7vADZYxAdjnjSgSyxFyDrGEdgFv76TPpbyCHtbnNrbGr5zDn82hx w3B0Do6u58L3GRWXaYIYlZVdmJkYkm3BsqmguNTIZyNOXI/OxJziT37T5HDDh5jtp/4g mdyxrRzq3l1iEf9Y6O8VkxutTROQ2HGq8DSTqtlqkKAiuIZrFYhfNSS6FFSS6xk3PMep yNIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=an0w+T5vHW9BB7wODVMiOm654Rzn0OqK/IeCaRQIYK8=; b=6Fx0WycvPF96/s0e9Hl2xBWC8sUjE0IuOp8XpzEku6BZxn2QznfoWT5P3vtaWbflwG WCz4XOSezGfkStl+qJTwfCDuajIMaidcNPTEci+R/sK3tqsGKTPRmpxkTrrFUjnYhksm KEY/NE9nlrAGKHFiYVr84p/N9IBy1tiR3KY2gNobYBjkIG2ye/xDK07Z49MdpTtvwxVD hYfg8mPJFtfEsf9ptSZZ0yJffIQSvagzNo0jfE0KBmRWQPpPxwwWqwpfea0NiW/cqiNh X8wDy0RB0l0dWVmofSySEqOqj8g2iFvWB9161s1Y6y9ebLqduMDv7ikMWfjtQN3/kFya LrqA== X-Gm-Message-State: AFqh2kqvnSBIVUOn/iAjhpoXNlEEZwHYHke8bMoJfKc+k/xZXvDTQGlL anyI8wT+xinB2/MR6+l7sXGH62oSY34= X-Google-Smtp-Source: AMrXdXsVRhA2SRHKRzqo8PdUEYIL7qqj5UxREzY6tOUaFwWhiSrQmzVCrYeghvaZsgxRjpuvuCsy0w== X-Received: by 2002:a05:600c:601e:b0:3d0:7fee:8a70 with SMTP id az30-20020a05600c601e00b003d07fee8a70mr57468340wmb.19.1673520720160; Thu, 12 Jan 2023 02:52:00 -0800 (PST) Original-Received: from krug (87-196-72-225.net.novis.pt. [87.196.72.225]) by smtp.gmail.com with ESMTPSA id v10-20020a05600c444a00b003d998412db6sm28006940wmn.28.2023.01.12.02.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 02:51:59 -0800 (PST) In-Reply-To: <83cz7kksd2.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 12 Jan 2023 11:35:37 +0200") 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:253213 Archived-At: Eli Zaretskii writes: >> Cc: joaotavora@gmail.com >> From: Evgeni Kolev >> Date: Wed, 4 Jan 2023 17:44:27 +0200 >>=20 >> [CC-ing Jo=C3=A3o T=C3=A1vora, author of eglot] >>=20 >> This patch fixes an incorrect behavior of eglot. To reproduce: >> - run M-x eglot >> - run M-x eglot (again) >> - eglot now prompts whether to reconnect to the existing LSP >> - enter "n" (for no) >> - now eglot shuts down the LSP process and reconnects - this is not >> correct, the expected behavior is to not reconnect >>=20 >> The patch is below. > > Jo=C3=A3o, any comments? Yes, sorry for the delay. Evgeni Kolev writes: > This patch fixes an incorrect behavior of eglot. To reproduce: > - run M-x eglot > - run M-x eglot (again) > - eglot now prompts whether to reconnect to the existing LSP > - enter "n" (for no) > - now eglot shuts down the LSP process and reconnects - this is not > correct, the expected behavior is to not reconnect Well you _are_ seing the expected behaviour! To "disconnect and connect again" is different from "reconnect". Thought often not much in practice, the former means you can use different command arguments to the server, like when doing C-u M-x eglot or when M-x eglot can't guess a command and lets you type one in. So in a way, it's like the message should be: "Do you want to reconnect to same language server or do you want to disconnect and connect again with whatever new things you've passed to M-x eglot?" However, I agree 100% with you that this message is very confusing. I've been baffled by it before. So we should attempt a fix. Unfortunately, your patch introduces a problem, so I don't think it should be merged. If we install it, it means that a user doing: M-x eglot RET /path/to/some/server-that-works-but/not-very-well RET M-x eglot RET /this/one/is/much-better RET will never have an interactive chance to actually try the 'much-better' server. For this user, it's either reconnect to 'not-very-well' or don't do anything at all. And that's probably not what the user meant, and she has wasted the effort of typing "/this/one/is/much-better". Do you understand? Going forward, we must ask: do we want to keep the "do you want to reconnect instead" possibility? 1) if yes, then there probably has to be a three-way query somewhere offering options a) reconnect, b) disconnect-then-connect, and c) do nothing. This is a bit akward, but it is doable. This query should happen sooner than it does not, probably in 'eglot--guess-contact', _before_ asking the user about any interactive arguments to 'M-x eglot' 2) if no, then we are saying that an interactive 'M-x eglot' is either going to tear down any current connection or do anything at all. That's fine by me. A simple reconnect is still just an 'M-x eglot-reconnect' away. If we 2.1) don't touch 'eglot--guess-contact' it'll still be a bit akward to be given the possiblity to answer "no" after typing in the new server path. If we 2.2) adjust 'eglot--guess-contact', that quirk could be solved. I think 2.1 and 2.2 are the best solutions here, 2.2 being clearly better. But 2.1 is less disruptive and easier to code than 2.2. Jo=C3=A3o