Subject: Re: bug#61350: Eglot over Tramp freezes with large project

From: João Távora <[email-masked]>
Date: Tue, 28 Feb 2023 19:37:51 +0000

Michael Albinus <[email-masked]> writes:

> João Távora <[email-masked]> writes:
>
> Hi João,
>
>> Looking at the Tramp code, I think Thomas's idea of using
>>
>>   -o "ControlMaster=no" -o "ControlPath=none"
>>
>> would probably be quite effective.  It would work with previous
>> Tramp versions that Eglot users might be using.
>
> Yes, that I have also in mind.
>
>> Thomas, can you try this patch?
>>
>> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
>> index e20d209332d..83462633dd9 100644
>> --- a/lisp/progmodes/eglot.el
>> +++ b/lisp/progmodes/eglot.el
>> @@ -130,6 +130,8 @@
>>  (defvar markdown-fontify-code-blocks-natively)
>>  (defvar company-backends)
>>  (defvar company-tooltip-align-annotations)
>> +(defvar tramp-ssh-controlmaster-options)
>> +(defvar tramp-use-ssh-controlmaster-options)
>>
>>
>>
>> @@ -1247,7 +1249,15 @@ eglot--connect
>>                          (contact (cl-subseq contact 0 probe)))
>>                     `(:process
>>                       ,(lambda ()
>> -                        (let ((default-directory default-directory))
>> +                        (let ((default-directory default-directory)
>> +                              ;; bug#61350: Tramp turns a feature on
>> +                              ;; by default that can't (yet) handle
>> +                              ;; very much data so we turn it off
>> +                              ;; unconditionally -- just for our
>> +                              ;; process.
>> +                              (tramp-use-ssh-controlmaster-options t)
>> +                              (tramp-ssh-controlmaster-options
>> +                               "-o ControlMaster=no -o ControlPath=none"))
>>                            (make-process
>>                             :name readable-name
>>                             :command (setq server-info (eglot--cmd contact))
>
> Even better than my proposal :-)
>
> There is the small risk that a user runs a local ssh client which is
> not aware of the ControlMaster option. For such a user, Eglot on a
> remote host might fail.
>
> Tramp is busy to check, whether ControlMaster could be applied.
>
> OTOH, I don't know if such ssh clients are still used in the wild, at
> least by Eglot users.

There is this risk indeed.  But considering the two demographics:

1. People who use ControlMaster in ~/.ssh/config
2. People who have very old ssh clients

I think that 2 is probably smaller than 1, especially if ControlMaster
is such a momentous thing.  So i think the risk is worth taking.
Especially because an error for people in 2. is easier to recognize,
understand and report than an inexplicable Emacs hang.  And Eglot is a
:core ELPA package, so bugfixes can be expedited.

João