emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 67df34c143: Fix M-x eglot prompt when connection already exists


From: João Távora
Subject: emacs-29 67df34c143: Fix M-x eglot prompt when connection already exists (bug#60557)
Date: Mon, 16 Jan 2023 06:48:20 -0500 (EST)

branch: emacs-29
commit 67df34c143d1adbf6d2817abb5da5dcad06369bb
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Fix M-x eglot prompt when connection already exists (bug#60557)
    
    Before this change, if a current connection existed at the time of M-x
    eglot, user would be first asked to enter into M-x eglot's interactive
    spec details about new command line arguments, and only afterwards be
    prompted about what to do with the current connection (which could be
    to reconnect to it using the same arguments, or tear it down and make
    a new one).
    
    This is very confusing, as users may not be fully aware of the
    distinction between "reconnect" vs "disconnect-and-connect".  They
    might not know if any new command line arguments provided are taking
    effect or not.
    
    This change simplifies this and removes the option to "reconnect
    instead" from M-x eglot (users can do that at any time via M-x
    eglot-reconnect).  It also ensures that users are informed about a
    current connection before asking to enter new command line arguments
    and not the other way round.
    
    * lisp/progmodes/eglot.el (eglot): Rework.
---
 lisp/progmodes/eglot.el | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 0082a17130..445d6ee9b5 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1113,16 +1113,16 @@ LANGUAGE-ID is the language ID string to send to the 
server for
 MANAGED-MAJOR-MODE, which matters to a minority of servers.
 
 INTERACTIVE is t if called interactively."
-  (interactive (append (eglot--guess-contact t) '(t)))
-  (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)
-      (when live-p (ignore-errors (eglot-shutdown current-server)))
-      (eglot--connect managed-major-mode project class contact language-id))))
+  (interactive
+   (let ((current-server (eglot-current-server)))
+     (unless (or (null current-server)
+                 (y-or-n-p "\
+[eglot] Shut down current connection before attempting new one?"))
+       (user-error "[eglot] Connection attempt aborted by user."))
+     (prog1 (append (eglot--guess-contact t) '(t))
+       (when current-server (ignore-errors (eglot-shutdown current-server))))))
+  (eglot--connect (eglot--ensure-list managed-major-mode) 
+                  project class contact language-id))
 
 (defun eglot-reconnect (server &optional interactive)
   "Reconnect to SERVER.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]