GNU bug report logs - #60557
[PATCH] Fix eglot prompt when connection already exists

Previous Next

Package: emacs;

Reported by: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>

Date: Wed, 4 Jan 2023 15:46:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#60557: closed ([PATCH] Fix eglot prompt when connection
 already exists)
Date: Mon, 16 Jan 2023 14:55:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 16 Jan 2023 16:54:14 +0200
with message-id <83h6wq4jjd.fsf <at> gnu.org>
and subject line Re: bug#60557: [PATCH] Fix eglot prompt when connection already exists
has caused the debbugs.gnu.org bug report #60557,
regarding [PATCH] Fix eglot prompt when connection already exists
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
60557: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60557
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: joaotavora <at> gmail.com
Subject: [PATCH] Fix eglot prompt when connection already exists
Date: Wed, 4 Jan 2023 17:44:27 +0200
[CC-ing João Távora, author of eglot]

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

The patch is below.

commit f7626c070d4bd63fab1df33153ab9deaec0a3f7b (HEAD -> master)
Author: Evgeni Kolev <evgenysw <at> gmail.com>
Date:   Wed Jan 4 17:36:30 2023 +0200

    Fix eglot prompt when connection already exists

    When M-x eglot is executed twice, the second time it prompts whether
    to reconnect. Answering "no" was not working correctly - the existing
    LSP process was still reconnected.

    This behavior is fixed, answering "no" results in keeping the existing
    connection.

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 6d192d9b333..7ac123f3c09 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1116,10 +1116,9 @@ eglot
   (setq managed-major-mode (eglot--ensure-list managed-major-mode))
   (let* ((current-server (eglot-current-server))
          (live-p (and current-server (jsonrpc-running-p current-server))))
-    (if (and live-p
-             interactive
-             (y-or-n-p "[eglot] Live process found, reconnect instead? "))
-        (eglot-reconnect current-server interactive)
+    (if (and live-p interactive)
+        (when (y-or-n-p "[eglot] Live process found, reconnect instead? ")
+          (eglot-reconnect current-server interactive))
       (when live-p (ignore-errors (eglot-shutdown current-server)))
       (eglot--connect managed-major-mode project class contact language-id))))


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: João Távora <joaotavora <at> gmail.com>
Cc: evgeni.d.kolev <at> gmail.com, 60557-done <at> debbugs.gnu.org
Subject: Re: bug#60557: [PATCH] Fix eglot prompt when connection already exists
Date: Mon, 16 Jan 2023 16:54:14 +0200
> From: João Távora <joaotavora <at> gmail.com>
> Date: Mon, 16 Jan 2023 14:42:25 +0000
> Cc: evgeni.d.kolev <at> gmail.com, 60557 <at> debbugs.gnu.org
> 
> >   In eglot:
> >   progmodes/eglot.el:1078:44: Warning: Unused lexical argument `interactive'
> >
> > because the INTERACTIVE argument is now unused. 
> 
> You're right, I missed that. Sorry.
>  
> > Should it be renamed to _interactive?
> 
> Yes, that would be fine.  As would removing  the argument entirely. 
> 
> M-x eglot is _not_ meant  to be called from Lisp at at all, but some time 
> ago I found at least one user on emacs-devel was doing so.  So removing 
> it may break some code (that is probably already broken anyway, but still...).

I renamed it and updated the doc string to that effect.

Closing.


This bug report was last modified 2 years and 125 days ago.

Previous Next


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