aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorMichael Albinus2024-10-13 18:05:39 +0200
committerMichael Albinus2024-10-13 18:05:39 +0200
commit6864ac2bc3bee1add508872b756693a6fbe0c2e7 (patch)
tree57423497b361f2062fdeca8bd44363e14a3eba43 /doc/misc
parent19f929aaa33a3bd8cc02a7fdfa0d8dc4c2fa8fc3 (diff)
downloademacs-6864ac2bc3bee1add508872b756693a6fbe0c2e7.tar.gz
emacs-6864ac2bc3bee1add508872b756693a6fbe0c2e7.zip
Describe how to add an ELPA package to Tramp
* doc/misc/tramp.texi: Use @dots{} where appropriate. (External packages): Rename subsection "Timers, process filters, process sentinels, redisplay". (Extension packages): New node. (Top, Files directories and localnames): Add it to @menu.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/tramp.texi137
1 files changed, 133 insertions, 4 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 19a2668e76c..1b40ce6fa62 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -167,6 +167,7 @@ How file names, directories and localnames are mangled and managed
167* Temporary directory:: Where temporary files are kept. 167* Temporary directory:: Where temporary files are kept.
168* Localname deconstruction:: Breaking a localname into its components. 168* Localname deconstruction:: Breaking a localname into its components.
169* External packages:: Integration with external Lisp packages. 169* External packages:: Integration with external Lisp packages.
170* Extension packages:: Adding new methods to @value{tramp}.
170 171
171@end detailmenu 172@end detailmenu
172@end menu 173@end menu
@@ -2665,7 +2666,7 @@ will help:
2665@example 2666@example
2666@group 2667@group
2667if test "$TERM" = "dumb"; then 2668if test "$TERM" = "dumb"; then
2668 ... 2669 @dots{}
2669fi 2670fi
2670@end group 2671@end group
2671@end example 2672@end example
@@ -5047,8 +5048,8 @@ An archive file name could be a remote file name, as in
5047Since all file operations are mapped internally to @acronym{GVFS} 5048Since all file operations are mapped internally to @acronym{GVFS}
5048operations, remote file names supported by @code{tramp-gvfs} perform 5049operations, remote file names supported by @code{tramp-gvfs} perform
5049better, because no local copy of the file archive must be downloaded 5050better, because no local copy of the file archive must be downloaded
5050first. For example, @samp{/sftp:user@@host:...} performs better than 5051first. For example, @samp{/sftp:user@@host:@dots{}} performs better
5051the similar @samp{/scp:user@@host:...}. See the constant 5052than the similar @samp{/scp:user@@host:@dots{}}. See the constant
5052@code{tramp-archive-all-gvfs-methods} for a complete list of 5053@code{tramp-archive-all-gvfs-methods} for a complete list of
5053@code{tramp-gvfs} supported method names. 5054@code{tramp-gvfs} supported method names.
5054 5055
@@ -6260,6 +6261,7 @@ programs.
6260* Temporary directory:: Where temporary files are kept. 6261* Temporary directory:: Where temporary files are kept.
6261* Localname deconstruction:: Splitting a localname into its component parts. 6262* Localname deconstruction:: Splitting a localname into its component parts.
6262* External packages:: Integrating with external Lisp packages. 6263* External packages:: Integrating with external Lisp packages.
6264* Extension packages:: Adding new methods to @value{tramp}.
6263@end menu 6265@end menu
6264 6266
6265 6267
@@ -6377,7 +6379,7 @@ root directory, it is most likely sufficient to make the
6377@code{default-directory} of the process buffer as the root directory. 6379@code{default-directory} of the process buffer as the root directory.
6378 6380
6379 6381
6380@subsection Timers 6382@subsection Timers, process filters, process sentinels, redisplay
6381 6383
6382@vindex remote-file-error 6384@vindex remote-file-error
6383Timers run asynchronously at any time when Emacs is waiting for 6385Timers run asynchronously at any time when Emacs is waiting for
@@ -6396,6 +6398,133 @@ wrapping the timer function body as follows:
6396@end group 6398@end group
6397@end lisp 6399@end lisp
6398 6400
6401A similar problem could happen with process filters, process
6402sentinels, and redisplay (updating the mode line).
6403
6404
6405@node Extension packages
6406@section Adding new methods to @value{tramp}
6407
6408There are two ways to add new methods to @value{tramp}: writing a new
6409backend including an own file name handler, or adding the new method,
6410using the existing @code{tramp-sh-file-name-handler}. The former
6411shall happen inside the @value{tramp} repository, and it isn't
6412discussed here. The latter means usually a new ELPA package.
6413@pxref{Customizing Methods} for some examples.
6414
6415
6416@subsection Writing an own ELPA package
6417
6418An external ELPA package @file{foo-tramp.el}, which intends to
6419provide a new @value{tramp} method, say @option{foo}, must add this
6420new method to the variable @code{tramp-methods}. This variable is an
6421alist with elements @code{(@var{name} @var{param1} @var{param2}
6422@dots{})}.
6423
6424@var{name} is the method name, @t{"foo"} in this case.
6425@var{param}@t{x} is a pair of the form @code{(@var{key} @var{value})}.
6426See the docstring of variable @code{tramp-methods} for possible
6427@var{key}s and @var{value}s. An example would be
6428
6429@lisp
6430@group
6431(add-to-list
6432 'tramp-methods
6433 `("foo"
6434 (tramp-login-program ,foo-tramp-executable)
6435 (tramp-login-args (("exec") ("%h") ("--") ("su - %u")))
6436 (tramp-remote-shell "/bin/sh")
6437 (tramp-remote-shell-args ("-i" "-c"))))
6438@end group
6439@end lisp
6440
6441@code{foo-tramp-executable} in this example would be a Lisp constant,
6442which is the program name of @command{foo}.
6443
6444Another initialization could tell @value{tramp} which are the default
6445user and host name for method @option{foo}. This is done by calling
6446@code{tramp-set-completion-function}:
6447
6448@lisp
6449@group
6450(tramp-set-completion-function
6451 "foo"
6452 '((tramp-foo--completion-function @var{arg})))
6453@end group
6454@end lisp
6455
6456@code{tramp-foo--completion-function} is a function, which returns
6457completion candidates. @var{arg}, a string, is the argument for the
6458completion function, for example a file name to read from.
6459@pxref{Customizing Completion} for details.
6460
6461Finally, it might also be helpful to define default user or host names
6462for method @option{foo}, in case a remote file name leaves them empty.
6463This can be performed by calling
6464
6465@lisp
6466@group
6467(add-to-list 'tramp-default-user-alist '("foo" nil "root"))
6468(add-to-list 'tramp-default-host-alist '("foo" nil "localhost"))
6469@end group
6470@end lisp
6471
6472@pxref{Default User} and @ref{Default Host} explaining the user options
6473@code{tramp-default-user-alist} and @code{tramp-default-host-alist}.
6474
6475
6476@subsection Making a customized method optional
6477
6478The settings of the previous subsection are global in the package
6479@file{foo-tramp.el}, meaning they are activated when loading
6480@code{foo-tramp}. Sometimes, it is desired to make these settings
6481available without loading the whole package @code{foo-tramp}, but
6482declaring the new method @option{foo} as optional method only. In
6483this case, declare a function @code{tramp-enable-foo-method} which
6484collects the initialization. This function must be auto loaded.
6485
6486@lisp
6487@group
6488;;;###autoload
6489(defun tramp-enable-foo-method ()
6490 (add-to-list 'tramp-methods '("foo" @dots{}))
6491 (tramp-set-completion-function "foo" @dots{})
6492 (add-to-list 'tramp-default-user-alist '("foo" @dots{}))
6493 (add-to-list 'tramp-default-host-alist '("foo" @dots{})))
6494@end group
6495@end lisp
6496
6497Then, you can activate method @option{foo} by calling @kbd{M-x
6498tramp-enable-method @key{RET} foo @key{RET}}. @pxref{Optional methods}.
6499
6500
6501@subsection Activating a customized method without loading the package
6502
6503If you want to make method @option{foo} known after loading
6504@value{tramp}, without loading the package @file{foo-tramp.el}, you
6505must autoload the implementation of function
6506@code{tramp-enable-foo-method}. Add the following code in
6507@file{foo-tramp.el}:
6508
6509@lisp
6510@group
6511;;;###autoload
6512(progn
6513 (defun tramp-enable-foo-method ()
6514 (add-to-list 'tramp-methods '("foo" @dots{}))
6515 (tramp-set-completion-function "foo" @dots{})
6516 (add-to-list 'tramp-default-user-alist '("foo" @dots{}))
6517 (add-to-list 'tramp-default-host-alist '("foo" @dots{}))))
6518
6519;;;###autoload
6520(with-eval-after-load 'tramp (tramp-enable-method "foo"))
6521@end group
6522@end lisp
6523
6524The trick is to wrap the function definition of
6525@code{tramp-enable-foo-method} with @code{progn} for the
6526@code{;;;###autoload} cookie.
6527
6399 6528
6400@node Traces and Profiles 6529@node Traces and Profiles
6401@chapter How to Customize Traces 6530@chapter How to Customize Traces