[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
server-local variables
From: |
Michael Albinus |
Subject: |
server-local variables |
Date: |
Sun, 30 Oct 2016 19:39:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
Hi,
a long standing wishlist for Tramp are server-local (sometimes called
connection-local) variables. It was expressed for the first time in
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3736#35>, but there are
more discussions about in bug reports and discussions on emacs-devel and
tramp-devel.
I'm playing with a small patch for files.el, which provides a mechanism
similar to directory-local variables. Most important are the following
functions:
--8<---------------cut here---------------start------------->8---
server-locals-set-class is a compiled Lisp function in
‘../../../src/emacs/lisp/files.el’.
(server-locals-set-class REGEXP CLASS)
Add CLASS for remote servers.
REGEXP is a regular expression identifying remote servers, a string.
CLASS is the name of a project class, a symbol.
When a connection to a remote server is opened, the
server-specific variables from CLASS are applied to the
corresponding process buffer. The variables for a class are
defined using ‘server-locals-set-class-variables’.
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
server-locals-set-class-variables is a compiled Lisp function in
‘../../../src/emacs/lisp/files.el’.
(server-locals-set-class-variables CLASS VARIABLES)
Map the symbol CLASS to a list of variable settings.
VARIABLES is a list that declares server-local variables for the
class. An element in VARIABLES is an alist whose elements are of
the form (VARIABLE . VALUE).
When a connection to a remote server is opened, the server’s
classes are found. A server may be assigned a class using
‘server-locals-set-directory-class’. Then variables are set in
the server’s process buffer according to the VARIABLES list of
the class. The list is processed in order.
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
hack-server-local-variables-apply is a compiled Lisp function in
‘../../../src/emacs/lisp/files.el’.
(hack-server-local-variables-apply)
Apply server-local variables for the server identified by ‘default-directory’.
Other local variables, like file-local and dir-local variables,
will not be touched.
--8<---------------cut here---------------end--------------->8---
With these functions, one could write the following code snippet,
pushing a server-local variable `some-useful-setting' for all remote
connections using the "sudo" method:
--8<---------------cut here---------------start------------->8---
(server-locals-set-class-variables
'remote '((some-useful-setting . some-useful-value)))
(server-locals-set-class "^/sudo:" 'remote)
;; This must be applied in a buffer with remote `default-directory'.
(hack-server-local-variables-apply)
--8<---------------cut here---------------end--------------->8---
Comments?
Best regards, Michael.
- server-local variables,
Michael Albinus <=
- Re: server-local variables, Eli Zaretskii, 2016/10/30
- Re: server-local variables, Michael Albinus, 2016/10/30
- Re: server-local variables, Eli Zaretskii, 2016/10/30
- Re: server-local variables, Michael Albinus, 2016/10/31
- Re: server-local variables, Phil Sainty, 2016/10/31
- Re: server-local variables, Óscar Fuentes, 2016/10/31
- Re: server-local variables, Michael Albinus, 2016/10/31
- Re: server-local variables, Phil Sainty, 2016/10/31
- Re: server-local variables, Stefan Monnier, 2016/10/31
- Re: server-local variables, Michael Albinus, 2016/10/31