Subject: bug#67682: 30.0.50; M-u M-x eglot localhost:4567 doesn't connect

From: João Távora <[email-masked]>
Date: Fri, 8 Dec 2023 11:19:48 +0000

On Thu, Dec 7, 2023 at 9:28 AM Helmut Eller <[email-masked]> wrote:
>
> When I try:
>
>   M-u M-x eglot localhost:4567
>
> then I get:
>
>   No such file or directory, localhost:4567
>
> ISTR, that this worked in the past.

Confirm.  Broken in

commit 523547321e4caca6fc966bd71ecd7b60a6e98f73
Author: João Távora <[email-masked]>
Date:   Sat Sep 17 21:40:34 2022 +0100

    Allow :initializationoptions in eglot-server-programs

...for more than one year, probably means very few people
are using this.  May I ask what your LS is? .  Please try
the untested patch after my sig.

João

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index d410367f902..248199641e3 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1280,14 +1280,21 @@ eglot--guess-contact
                          (concat "`%s' not found in PATH, but can't form"
                                  " an interactive prompt for to fix %s!")
                          program guess))))))
+         (user-input (and prompt
+                          (read-shell-command
+                           prompt
+                           full-program-invocation
+                           'eglot-command-history)))
          (contact
-          (or (and prompt
-                   (split-string-and-unquote
-                    (read-shell-command
-                     prompt
-                     full-program-invocation
-                     'eglot-command-history)))
-              guess)))
+          (cond ((and user-input
+                      (string-match
"^[\s\t]*\\(.*\\):\\([[:digit:]]+\\)[\s\t]*$"
+                                    user-input))
+                 (list (match-string 1 user-input)
+                       (string-to-number (match-string 2 user-input))))
+                (user-input
+                 (split-string-and-unquote user-input))
+                (t
+                 guess))))
     (list managed-modes (eglot--current-project) class contact language-ids)))

 (defvar eglot-lsp-context)