Subject: Re: bug#61748: 27.2; Eglot should use shell-file-name when launching the language server for a remote file

From: João Távora <[email-masked]>
Date: Tue, 28 Feb 2023 15:23:24 +0000

On Tue, Feb 28, 2023 at 3:15 PM Michael Albinus <[email-masked]> wrote:

> > Indeed, as the adage goes, cache invalidation is a hard problem of
> > computer science, we deal with it every day.  But it's a bit unfair to expect
> > the user to solve it.
>
> I don't expect a user to solve it. And a user shouldn't expect that
> changing a variable is sufficient.

I respectfully but diametrically disagree here.

Here's an untested patch that could solve this.  It can probably
be made smarter by only invalidating the cache when a change
to the variable is detected.

João

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index ec8437176db..eae00923395 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -5578,11 +5578,7 @@ tramp-get-remote-path
     ;; Expand connection-local variables.
     (tramp-set-connection-local-variables vec)
     (with-tramp-connection-property
- ;; When `tramp-own-remote-path' is in `tramp-remote-path', we
- ;; cache the result for the session only.  Otherwise, the
- ;; result is cached persistently.
- (if (memq 'tramp-own-remote-path tramp-remote-path)
-     (tramp-get-process vec) vec)
+ (tramp-get-process vec)
  "remote-path"
       (let* ((remote-path (copy-tree tramp-remote-path))
       (elt1 (memq 'tramp-default-remote-path remote-path))