unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66093: Eglot over tramp sshfs/sftp
@ 2023-09-18 17:52 Ko Nishi
  2023-09-19  7:46 ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Ko Nishi @ 2023-09-18 17:52 UTC (permalink / raw)
  To: 66093; +Cc: michael.albinus, joaotavora

[-- Attachment #1: Type: text/html, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-18 17:52 bug#66093: Eglot over tramp sshfs/sftp Ko Nishi
@ 2023-09-19  7:46 ` Michael Albinus
  2023-09-19 18:59   ` Ko Nishi
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2023-09-19  7:46 UTC (permalink / raw)
  To: Ko Nishi; +Cc: 66093, joaotavora

Ko Nishi <kohnish@gmx.com> writes:

> Hi,

Hi Ko,

> I was suggested to contact here from a github discussion
> https://github.com/joaotavora/eglot/discussions/1294.
> But in short, at the moment, eglot fails to spawn a functioning
> language server process over tramp when sshfs or sftp is used.
> For sshfs, I see clangd process without stty command on remote, while
> with sftp eglot doesn't find the path.

Tramp's sftp integration doesn't support remote processes. So there's no
chance to make it working.

sshfs, as general concept, doesn't allow remote processes either. Tramp
has added this functionality by opening a parallel ssh connection, see
tramp-sshfs.el for its configuration (the lines, where
tramp-sshfs-method is added to tramp-methods). However, it calls remote
commands directly via ssh, like this (according to Tramp traces):

--8<---------------cut here---------------start------------->8---
ssh -q -e none -t -t gandalf cd /home/albinus/src/emacs/ && ( env INSIDE_EMACS\=30.0.50\,tramp\:2.7.0-pre ENV\=\'\' TMOUT\=0 LC_CTYPE\=\'\' CDPATH\= HISTORY\= MAIL\= MAILCHECK\= MAILPATH\= PAGER\=cat autocorrect\= correct\= /bin/sh -c stty\ raw\ \>\ /dev/null\;\ /usr/bin/clangd )
--8<---------------cut here---------------end--------------->8---

I'm not sure, but likely the snippet "stty\ raw\ \>\ /dev/null\;\ /usr/bin/clangd"
might need another quoting.

> Best regards,
> Ko

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-19  7:46 ` Michael Albinus
@ 2023-09-19 18:59   ` Ko Nishi
  2023-09-20  9:14     ` Michael Albinus
  2023-09-22 18:02     ` Michael Albinus
  0 siblings, 2 replies; 8+ messages in thread
From: Ko Nishi @ 2023-09-19 18:59 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 66093, joaotavora

[-- Attachment #1: Type: text/html, Size: 4006 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-19 18:59   ` Ko Nishi
@ 2023-09-20  9:14     ` Michael Albinus
  2023-09-22 18:02     ` Michael Albinus
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Albinus @ 2023-09-20  9:14 UTC (permalink / raw)
  To: Ko Nishi; +Cc: 66093, joaotavora

Ko Nishi <kohnish@gmx.com> 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.
> Eglot is noticeably faster than using just ssh or sshx on a server
> 80ms ping away.

Remote processes with sshfs are configured to use the direct async
connection by default (see the Tramp manual, section "Improving
performance of asynchronous remote processes"). You can achieve the same
with ssh connections by setting the "direct-async-process" connection
property, like

--8<---------------cut here---------------start------------->8---
     (add-to-list 'tramp-connection-properties
                  (list (regexp-quote "/ssh:user@host:")
                        "direct-async-process" t))
--8<---------------cut here---------------end--------------->8---

> Best,
> Ko

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-19 18:59   ` Ko Nishi
  2023-09-20  9:14     ` Michael Albinus
@ 2023-09-22 18:02     ` Michael Albinus
  2023-09-22 18:11       ` Michael Albinus
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2023-09-22 18:02 UTC (permalink / raw)
  To: Ko Nishi; +Cc: 66093, joaotavora

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

Ko Nishi <kohnish@gmx.com> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1313 bytes --]

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)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-22 18:02     ` Michael Albinus
@ 2023-09-22 18:11       ` Michael Albinus
  2023-09-26  9:03         ` Ko Nishi
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Albinus @ 2023-09-22 18:11 UTC (permalink / raw)
  To: Ko Nishi; +Cc: 66093, joaotavora

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Ko,

> 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.

Oops, the other part is missing. Pls apply also the appended patch here.

>> Best,
>> Ko

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 873 bytes --]

diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index c638d32ec35..0e58e8d7ee5 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -60,7 +60,7 @@ tramp-default-remote-shell
 		;; These are for remote processes.
                 (tramp-login-program        "ssh")
                 (tramp-login-args           (("-q") ("-l" "%u") ("-p" "%p")
-				             ("-e" "none") ("-t" "-t")
+				             ("-e" "none") ("-t" "%a")
 					     ("%h") ("%l")))
                 (tramp-direct-async         t)
                 (tramp-remote-shell         ,tramp-default-remote-shell)
@@ -323,6 +323,7 @@ tramp-sshfs-handle-process-file
 	    ?h (or (tramp-file-name-host v) "")
 	    ?u (or (tramp-file-name-user v) "")
 	    ?p (or (tramp-file-name-port v) "")
+            ?a ""
 	    ?l command))

 	;; Synchronize stderr.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-22 18:11       ` Michael Albinus
@ 2023-09-26  9:03         ` Ko Nishi
  2023-09-26 16:59           ` Michael Albinus
  0 siblings, 1 reply; 8+ messages in thread
From: Ko Nishi @ 2023-09-26  9:03 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 66093, joaotavora

[-- Attachment #1: Type: text/html, Size: 1887 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#66093: Eglot over tramp sshfs/sftp
  2023-09-26  9:03         ` Ko Nishi
@ 2023-09-26 16:59           ` Michael Albinus
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Albinus @ 2023-09-26 16:59 UTC (permalink / raw)
  To: Ko Nishi; +Cc: 66093-done, joaotavora

Version: 29.2

Ko Nishi <kohnish@gmx.com> writes:

> Hi Micheal,

Hi Ko,

> It works pretty good on emac29.1! Thank you.

Thanks for the feedback. I've pushed the patch to the repositories,
slightly modified. It will appear with Emacs 29.2 as well as on GNU ELPA
later this week, as Tramp 2.6.1.3.

> The only thing it doesn't work is vc-root-dir on a current file.  Like
> within sshfs eshell, it returns properly, but according the
> interactive functions in my init.el that does work based on current
> file, it returns nil.

Yes. tramp-sshfs.el does not offer an implementation for
`vc-registered'. To be precise, it offers the function

--8<---------------cut here---------------start------------->8---
    (vc-registered . ignore)
--8<---------------cut here---------------end--------------->8---

Therefore, all files are not under VC control. This won't change.

> Btw, indeed, you might be right about async option, but sshfs "might"
> performce nicely for go to definition for eglot sometimes, but it's
> just an impression, I could be totally wrong if I actually measure it.

Pls tell me if you see more optimization knobs to be implemented. ATM, I
believe we have done what's possible with this bug, so I'm closing it.

> Best regards,
> Ko

Best regards, Michael.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-26 16:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-18 17:52 bug#66093: Eglot over tramp sshfs/sftp Ko Nishi
2023-09-19  7:46 ` Michael Albinus
2023-09-19 18:59   ` Ko Nishi
2023-09-20  9:14     ` Michael Albinus
2023-09-22 18:02     ` Michael Albinus
2023-09-22 18:11       ` Michael Albinus
2023-09-26  9:03         ` Ko Nishi
2023-09-26 16:59           ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).