Subject: Re: bug#57556: 28.1; Eshell not finding executables in PATH when tramp-integration loaded

From: Michael Albinus <[email-masked]>
Date: Sun, 09 Oct 2022 20:01:10 +0200

Jim Porter <[email-masked]> writes:

Hi Jim,

> Thanks, this makes connection-local variables a lot clearer to
> me. Since this seems pretty tricky to get right for people who don't
> know much about connection-local variables, maybe it would make sense
> to add some helper functions for anyone who wants to do something
> similar?
>
> I attached an updated version of my connection-local.el that tries to
> pull out the additions you made into some helpers. What do you think?

I gave it a short reading, and in general it looks OK (comments
below). Do you want to provide a patch for files-x.el with this?

This patch shall also extent the "Connection Local Variables" section of
the Elisp manual. This section is already quite
long (~150 lines), and speaks almost about static setting of
connection-local variables. You bring dynamic settings here, maybe a
subsection would help to structure. And feel free to restructure the
other, long text if you believe it would help.

Add an example.

Btw, do you have write access to the Emacs git repo? If not I recommend
to ask the maintainers (Eli or Lars) for this.

> (defun connection-local-profile-name ()
>   "Get a connection-local profile name.
>
> This allows `connection-local-setq' to use this profile name when
> setting variables connection-locally. In theory, a user of these
> functions could locally override this function if they wanted to
> change the naming scheme."

The profile name is derived from default-directory, I would make this
more obvious in the function name and the docstring.

>   (when connection-local-criteria
>     (intern (concat
>              "auto-connection-local-profile/"
>              (symbol-name (plist-get connection-local-criteria :application))
>              "/" (or (file-remote-p default-directory) "local")))))

It is not guaranteed that the :application property exists. See the
docstring of connection-local-criteria-alist: "All properties are
optional ...".

> (defun with-connection-local-application-variables-1 (application body-fun)
>   "Apply connection-local variables for APPLICATION in `default-directory'.
> Call BODY-FUN with no args, and then unwind connection-local variables."

Please say that APPLICATION must be a symbol, and shouldn't be nil (if
this is what you want).

Best regards, Michael.