Subject: Re: bug#66093: Eglot over tramp sshfs/sftp

From: Michael Albinus <[email-masked]>
Date: Fri, 22 Sep 2023 20:02:21 +0200

Ko Nishi <[email-masked]> writes:

> Hi Michael,

Hi Ko,

> Without really understanding the code, If I copy the list from the ssh
> section of tramp-sh.el:245 and remove ("%c"), it started work after
> manually telling eglot to start clangd manually on propmt.

Well, after all it was a perfect shot! The "-t -t" ssh arguments have
prevented the pipe process, eglot is using, to work properly.

Could you pls test the appended patch? It is on top of the emacs-29
branch of the Emacs git repository, but it should apply also on the
Emacs 29.1 sources.

> Other than that many other things aren't working like vc-root-dir,
> finding PATH and etc.
> I'll try to understand the code and play around later.

Yep, that's still open. Perhaps my patch improves the situation, because
it suppresses the "-t -t" arguments only for pipe processes.

> Best,
> Ko

Best regards, Michael.

diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 8ace0165ed9..7e6fce16d56 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -283,6 +283,8 @@ tramp-methods
     - \"%z\" is replaced by the `tramp-scp-direct-remote-copying'
       argument if it is supported.
     - \"%d\" is replaced by the device detected by `tramp-adb-get-device'.
+    - \"%a\" adds the tty allocation argument \"-t\" in
+      asynchronous processes, if the connection type is not `pipe'.

     The existence of `tramp-login-args', combined with the
     absence of `tramp-copy-args', is an indication that the
@@ -5033,6 +5035,7 @@ tramp-handle-make-process
 		  (when adb-file-name-handler-p
 		    (tramp-compat-funcall
 		     'tramp-adb-get-device v)))
+                 (tty-allocation (unless (eq connection-type 'pipe) "-t"))
 		 login-args p)

 	    ;; Replace `login-args' place holders.  Split
@@ -5049,7 +5052,7 @@ tramp-handle-make-process
 		 v 'tramp-login-args
 		 ?h (or host "") ?u (or user "") ?p (or port "")
 		 ?c (format-spec (or options "") (format-spec-make ?t tmpfile))
-		 ?d (or device "") ?l ""))))
+		 ?d (or device "") ?a (or tty-allocation "") ?l ""))))
 	     p (make-process
 		:name name :buffer buffer
 		:command (append `(,login-program) login-args command)