Most of the variables reflect the situation on the local machine.
Often, they must use a different value when you operate in buffers
with a remote default directory. Think about the behavior when
shell – on your local machine, you might use
/bin/bash and rely on termcap, but on a remote machine, it may
be /bin/ksh and terminfo.
This can be accomplished with connection-local variables. Directory and file local variables override connection-local variables. Unsafe connection-local variables are handled in the same way as unsafe file-local variables (see Safety of File Variables).
Connection-local variables are declared as a group of
variables/value pairs in a profile, using the
connection-local-set-profile-variables function. The function
connection-local-set-profiles activates profiles for a given
criteria, identifying a remote machine:
(connection-local-set-profile-variables 'remote-terminfo '((system-uses-terminfo . t) (comint-terminfo-terminal . "dumb-emacs-ansi"))) (connection-local-set-profile-variables 'remote-ksh '((shell-file-name . "/bin/ksh") (shell-command-switch . "-c"))) (connection-local-set-profile-variables 'remote-bash '((shell-file-name . "/bin/bash") (shell-command-switch . "-c"))) (connection-local-set-profiles '(:application tramp :machine "remotemachine") 'remote-terminfo 'remote-ksh)
This code declares three different profiles,
remote-bash. The profiles
remote-ksh are applied to all
buffers which have a remote default directory matching the regexp
"remotemachine" as host name. Such a criteria can also
discriminate for the properties
:protocol (this is the Tramp
:user (a remote user name). The
matches all buffers with a remote default directory.