aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMichael Albinus2017-02-19 17:14:35 +0100
committerMichael Albinus2017-02-19 17:14:35 +0100
commit143bc75c414434badcb324db056ad37c15893bd9 (patch)
treeedb4c926bd940e39ec9a88ea13324d55f925223c /doc
parentb6a1a74522120979fe1a63b2d5517a490ee572b0 (diff)
downloademacs-143bc75c414434badcb324db056ad37c15893bd9.tar.gz
emacs-143bc75c414434badcb324db056ad37c15893bd9.zip
Rework connection local variables
For connection local variables interface, `class' is renamed to `profile'. All arguments `criteria' are a plist now. * doc/lispref/variables.texi (Connection Local Variables): Rewrite. * lisp/files-x.el (connection-local-profile-alist): Rename from `connection-local-class-alist'. Adapt docstring. (connection-local-criteria-alist): Adapt docstring. (connection-local-normalize-criteria): New defun. (connection-local-get-profiles): Rename from `connection-local-get-classes'. Rewrite. (connection-local-set-profiles): Rename from `connection-local-set-classes'. Rewrite. (connection-local-get-profile-variables): Rename from `connection-local-get-class-variables'. Rewrite. (connection-local-set-profile-variables): Rename from `connection-local-set-class-variables'. Rewrite. (hack-connection-local-variables) (hack-connection-local-variables-apply)): Rewrite. (with-connection-local-profiles): Rename from `ith-connection-local-classes'. Rewrite. * lisp/net/tramp.el (tramp-set-connection-local-variables): Compute criteria. * lisp/net/tramp-cmds.el (tramp-bug): Use `connection-local-profile-alist'. * test/lisp/files-x-tests.el (files-x-test--variables1) (files-x-test--variables2, files-x-test--variables3) (files-x-test--variables4, files-x-test--criteria1) (files-x-test--criteria2): Make them a defconst. (files-x-test--application) (files-x-test--another-application, files-x-test--protocol) (files-x-test--user, files-x-test--machine): New defconst. (files-x-test--criteria): New defvar. (files-x-test--criteria3): Remove. (files-x-test-connection-local-set-profile-variables): Rename from `files-x-test-connection-local-set-class-variables'. Rewrite. (files-x-test-connection-local-set-profiles): Rename from `files-x-test-connection-local-set-classes'. Rewrite. (files-x-test-hack-connection-local-variables-apply) Rewrite. (files-x-test-with-connection-local-profiles): Rename from `files-x-test-with-connection-local-classes'. Rewrite.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/variables.texi152
1 files changed, 75 insertions, 77 deletions
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 8a61018a612..2818ea067d2 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1979,24 +1979,21 @@ still respecting file-local variables (@pxref{File Local Variables}).
1979@section Connection Local Variables 1979@section Connection Local Variables
1980@cindex connection local variables 1980@cindex connection local variables
1981 1981
1982 Connection-local variables provide a general mechanism for 1982 Connection-local variables provide a general mechanism for different
1983different variable settings in buffers with a remote default 1983variable settings in buffers with a remote connection. They are bound
1984directory. They are bound and set depending on the remote connection 1984and set depending on the remote connection a buffer is dedicated to.
1985a buffer is dedicated to. Per default, they are set in all process 1985
1986buffers for a remote connection, but they could be applied also in 1986@defun connection-local-set-profile-variables profile variables
1987other buffers with a remote directory. 1987This function defines a set of variable settings for the connection
1988 1988@var{profile}, which is a symbol. You can later assign the connection
1989@defun connection-local-set-class-variables class variables 1989profile to one or more remote connections, and Emacs will apply those
1990This function defines a set of variable settings for the named 1990variable settings to all process buffers for those connections. The
1991@var{class}, which is a symbol. You can later assign the class to one 1991list in @var{variables} is an alist of the form
1992or more remote connections, and Emacs will apply those variable 1992@code{(@var{name}@tie{}.@tie{}@var{value})}. Example:
1993settings to all process buffers for those connections. The list in
1994@var{variables} is an alist of the form @code{(@var{name}
1995. @var{value})}. Example:
1996 1993
1997@example 1994@example
1998@group 1995@group
1999(connection-local-set-class-variables 1996(connection-local-set-profile-variables
2000 'remote-bash 1997 'remote-bash
2001 '((shell-file-name . "/bin/bash") 1998 '((shell-file-name . "/bin/bash")
2002 (shell-command-switch . "-c") 1999 (shell-command-switch . "-c")
@@ -2005,7 +2002,7 @@ settings to all process buffers for those connections. The list in
2005@end group 2002@end group
2006 2003
2007@group 2004@group
2008(connection-local-set-class-variables 2005(connection-local-set-profile-variables
2009 'remote-ksh 2006 'remote-ksh
2010 '((shell-file-name . "/bin/ksh") 2007 '((shell-file-name . "/bin/ksh")
2011 (shell-command-switch . "-c") 2008 (shell-command-switch . "-c")
@@ -2014,38 +2011,41 @@ settings to all process buffers for those connections. The list in
2014@end group 2011@end group
2015 2012
2016@group 2013@group
2017(connection-local-set-class-variables 2014(connection-local-set-profile-variables
2018 'remote-null-device 2015 'remote-null-device
2019 '((null-device . "/dev/null"))) 2016 '((null-device . "/dev/null")))
2020@end group 2017@end group
2021@end example 2018@end example
2022@end defun 2019@end defun
2023 2020
2024@defvar connection-local-class-alist 2021@defvar connection-local-profile-alist
2025This alist holds the class symbols and the associated variable 2022This alist holds the connection profile symbols and the associated
2026settings. It is updated by @code{connection-local-set-class-variables}. 2023variable settings. It is updated by
2024@code{connection-local-set-profile-variables}.
2027@end defvar 2025@end defvar
2028 2026
2029@defun connection-local-set-classes criteria &rest classes 2027@defun connection-local-set-profiles criteria &rest profiles
2030This function assigns @var{classes}, which are symbols, to all remote 2028This function assigns @var{profiles}, which are symbols, to all remote
2031connections identified by @var{criteria}. @var{criteria} is either a 2029connections identified by @var{criteria}. @var{criteria} is a plist
2032regular expression identifying a remote server, or a function with one 2030identifying a connection and the application using this connection.
2033argument @var{identification}, which must return non-nil when a remote 2031Property names might be @code{:application}, @code{:protocol},
2034server shall apply @var{classes} variables, or @code{nil}. 2032@code{:user} and @code{:machine}. The property value of
2035 2033@code{:application} is a symbol, all other property values are
2036If @var{criteria} is a regexp, is must match the result of 2034strings. All properties are optional; if @var{criteria} is nil, it
2037@code{(file-remote-p default-directory)} of a buffer in order to apply 2035always applies. Example:
2038the variables setting. Example:
2039 2036
2040@example 2037@example
2041@group 2038@group
2042(connection-local-set-classes 2039(connection-local-set-profiles
2043 "^/ssh:" 'remote-bash 'remote-null-device) 2040 '(:application 'tramp :protocol "ssh" :machine "localhost")
2041 'remote-bash 'remote-null-device)
2044@end group 2042@end group
2045 2043
2046@group 2044@group
2047(connection-local-set-classes 2045(connection-local-set-profiles
2048 "^/sudo:" 'remote-ksh 'remote-null-device) 2046 '(:application 'tramp :protocol "sudo"
2047 :user "root" :machine "localhost")
2048 'remote-ksh 'remote-null-device)
2049@end group 2049@end group
2050@end example 2050@end example
2051 2051
@@ -2053,82 +2053,80 @@ the variables setting. Example:
2053Therefore, the example above would be equivalent to 2053Therefore, the example above would be equivalent to
2054 2054
2055@example 2055@example
2056(connection-local-set-classes "^/ssh:" 'remote-bash)
2057(connection-local-set-classes "^/sudo:" 'remote-ksh)
2058(connection-local-set-classes nil 'remote-null-device)
2059@end example
2060
2061 If @var{criteria} is a lambda function it must accept one parameter,
2062the identification. The example above could be rewritten as
2063
2064@example
2065@group 2056@group
2066(connection-local-set-classes 2057(connection-local-set-profiles
2067 (lambda (identification) 2058 '(:application 'tramp :protocol "ssh" :machine "localhost")
2068 (string-equal (file-remote-p identification 'method) "ssh"))
2069 'remote-bash) 2059 'remote-bash)
2070@end group 2060@end group
2071 2061
2072@group 2062@group
2073(connection-local-set-classes 2063(connection-local-set-profiles
2074 (lambda (identification) 2064 '(:application 'tramp :protocol "sudo"
2075 (string-equal (file-remote-p identification 'method) "sudo")) 2065 :user "root" :machine "localhost")
2076 'remote-ksh) 2066 'remote-ksh)
2077@end group 2067@end group
2078 2068
2079@group 2069@group
2080(connection-local-set-classes 2070(connection-local-set-profiles
2081 (lambda (identification) t) 2071 nil 'remote-null-device)
2082 'remote-null-device)
2083@end group 2072@end group
2084@end example 2073@end example
2085 2074
2086 Thereafter, all the variable settings specified for @var{classes} 2075 Any connection profile of @var{profiles} must have been already
2087will be applied to any buffer with a matching remote directory, when 2076defined by @code{connection-local-set-profile-variables}.
2088activated by @code{hack-connection-local-variables-apply}. Any class
2089of @var{classes} must have been already defined by
2090@code{connection-local-set-class-variables}.
2091@end defun 2077@end defun
2092 2078
2093@defvar connection-local-criteria-alist 2079@defvar connection-local-criteria-alist
2094This alist contains remote server identifications and their assigned 2080This alist contains connection criteria and their assigned profile
2095class names. The function @code{connection-local-set-classes} updates 2081names. The function @code{connection-local-set-profiles} updates this
2096this list. 2082list.
2097@end defvar 2083@end defvar
2098 2084
2099@defun hack-connection-local-variables 2085@defun hack-connection-local-variables criteria
2100This function collects applicable connection-local variables in 2086This function collects applicable connection-local variables
2101@code{connection-local-variables-alist} that is local to the buffer, 2087associated with @var{criteria} in
2102without applying them. Whether a connection-local variable is 2088@code{connection-local-variables-alist}, without applying them.
2103applicable is specified by the remote identifier of a buffer, 2089Example:
2104evaluated by @code{(file-remote-p default-directory)}. 2090
2091@example
2092@group
2093(hack-connection-local-variables
2094 '(:application 'tramp :protocol "ssh" :machine "localhost"))
2095@end group
2096
2097@group
2098connection-local-variables-alist
2099 @result{} ((null-device . "/dev/null")
2100 (shell-login-switch . "-l")
2101 (shell-interactive-switch . "-i")
2102 (shell-command-switch . "-c")
2103 (shell-file-name . "/bin/bash"))
2104@end group
2105@end example
2105@end defun 2106@end defun
2106 2107
2107@defun hack-connection-local-variables-apply 2108@defun hack-connection-local-variables-apply criteria
2108This function looks for connection-local variables, and immediately 2109This function looks for connection-local variables according to
2109applies them in the current buffer. It is called per default for 2110@var{criteria}, and immediately applies them in the current buffer.
2110every process-buffer related to a remote connection. For other remote
2111buffers, it could be called by any mode.
2112@end defun 2111@end defun
2113 2112
2114@defmac with-connection-local-classes classes &rest body 2113@defmac with-connection-local-profiles profiles &rest body
2115All connection-local variables, which are specified by a class in 2114All connection-local variables, which are specified by a connection
2116@var{classes}, are applied. An implicit binding of the classes to the 2115profile in @var{profiles}, are applied.
2117remote connection is enabled.
2118 2116
2119After that, @var{body} is executed, and the connection-local variables 2117After that, @var{body} is executed, and the connection-local variables
2120are unwound. Example: 2118are unwound. Example:
2121 2119
2122@example 2120@example
2123@group 2121@group
2124(connection-local-set-class-variables 2122(connection-local-set-profile-variables
2125 'remote-perl 2123 'remote-perl
2126 '((perl-command-name . "/usr/local/bin/perl") 2124 '((perl-command-name . "/usr/local/bin/perl")
2127 (perl-command-switch . "-e %s"))) 2125 (perl-command-switch . "-e %s")))
2128@end group 2126@end group
2129 2127
2130@group 2128@group
2131(with-connection-local-classes '(remote-perl) 2129(with-connection-local-profiles '(remote-perl)
2132 do something useful) 2130 do something useful)
2133@end group 2131@end group
2134@end example 2132@end example