aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorMichael Albinus2025-08-05 12:00:21 +0200
committerMichael Albinus2025-08-05 12:00:21 +0200
commit5ff8a9039583b0e9e05b59986126905542fd78a1 (patch)
tree67dce4aeaa9f287add8d19cfda080004f11a5667 /doc/misc
parent2d2755c3d7b69a11372e8fb8eba3c342cc5f61e8 (diff)
downloademacs-5ff8a9039583b0e9e05b59986126905542fd78a1.tar.gz
emacs-5ff8a9039583b0e9e05b59986126905542fd78a1.zip
Tramp allows now external implementations for functions
* doc/misc/tramp.texi (Frequently Asked Questions): Mention tramp-hlo. (New operations): New node. (Top, Files directories and localnames): Add it to @menu. * etc/NEWS: Mention Tramp's feature to add function implementations. Presentational fixes and improvements. * lisp/net/tramp.el (tramp-file-name-for-operation-external): New defvar. (tramp-file-name-for-operation): Use `memq'. Handle external operations. Raise `remote-file-error' error in case of. (tramp-add-external-operation, tramp-remove-external-operation): New defuns. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test50-auto-load) (tramp-archive-test50-delay-load) (tramp-archive-test51-without-remote-files): Rename. * test/lisp/net/tramp-tests.el (tramp--test-operation) (tramp--handler-for-test-operation): New defuns. (tramp-test49-external-backend-function): New test. (tramp-test50-auto-load, tramp-test50-delay-load) (tramp-test50-recursive-load, tramp-test50-remote-load-path) (tramp-test51-without-remote-files, tramp-test52-unload): Rename.
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/tramp.texi104
1 files changed, 104 insertions, 0 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 21f12a38e0b..7fbd4f898f5 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -169,6 +169,7 @@ How file names, directories and localnames are mangled and managed
169* Localname deconstruction:: Breaking a localname into its components. 169* Localname deconstruction:: Breaking a localname into its components.
170* External packages:: Integration with external Lisp packages. 170* External packages:: Integration with external Lisp packages.
171* Extension packages:: Adding new methods to @value{tramp}. 171* Extension packages:: Adding new methods to @value{tramp}.
172* New operations:: Handling further operations in @value{tramp}.
172 173
173@end detailmenu 174@end detailmenu
174@end menu 175@end menu
@@ -5472,6 +5473,13 @@ Suppress reading the remote history file in @code{shell}. Set
5472Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, 5473Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
5473default being 3. Increase trace levels temporarily when hunting for 5474default being 3. Increase trace levels temporarily when hunting for
5474bugs. 5475bugs.
5476
5477@item
5478Use a package with @value{tramp} specific implementation of high-level
5479operations. For example, the GNU ELPA package @file{tramp-hlo}
5480implements specialized versions of @code{dir-locals--all-files},
5481@code{locate-dominating-file} and @code{dir-locals-find-file} for
5482@value{tramp}'s @code{tramp-sh} backend (@pxref{New operations}).
5475@end itemize 5483@end itemize
5476 5484
5477 5485
@@ -6457,6 +6465,7 @@ programs.
6457* Localname deconstruction:: Splitting a localname into its component parts. 6465* Localname deconstruction:: Splitting a localname into its component parts.
6458* External packages:: Integrating with external Lisp packages. 6466* External packages:: Integrating with external Lisp packages.
6459* Extension packages:: Adding new methods to @value{tramp}. 6467* Extension packages:: Adding new methods to @value{tramp}.
6468* New operations:: Handling further operations in @value{tramp}.
6460@end menu 6469@end menu
6461 6470
6462 6471
@@ -6721,6 +6730,101 @@ The trick is to wrap the function definition of
6721@code{;;;###autoload} cookie. 6730@code{;;;###autoload} cookie.
6722 6731
6723 6732
6733@node New operations
6734@section Handling further operations in @value{tramp}
6735
6736By default, @value{tramp} handles the basic operations listed in
6737@ref{Magic File Names, , Magic File Name Operations, elisp}.
6738Sometimes, it is desired to support more complex operations directly,
6739mainly for performance reasons.
6740
6741An external package package could add an own implementation of an
6742operation to @value{tramp}, which avoids the performance overhead
6743caused by using the basic operations which are aware of remote files.
6744For example, it could implement this by using an own shell script
6745which collects the information on the remote host for this very
6746special purpose with one round-trip per-call.
6747
6748@defun tramp-add-external-operation operation function backend
6749This adds an implementation of @var{operation} to @value{tramp}'s
6750backend @var{backend}. @var{function} is the new implementation.
6751
6752Both @var{operation} and @var{function} shall be function symbols.
6753They must have the same argument list. The first argument is used to
6754determine, whether @value{tramp} is invoked (check for remote file
6755name syntax). It must be a string or nil, in the latter case
6756@code{default-directory} is used for the check.
6757
6758@var{backend}, also a symbol, is the feature name of a @value{tramp}
6759backend (except @code{tramp-ftp}). The new implementation will be
6760applied only for this backend. Example:
6761
6762@lisp
6763@group
6764(defun test-operation (file)
6765 (message "Original implementation for %s" file))
6766@end group
6767
6768@group
6769(defun handle-test-operation (file)
6770 (message "Handler implementation for %s" file))
6771@end group
6772
6773@group
6774(tramp-add-external-operation
6775 #'test-operation #'handle-test-operation 'tramp-sh)
6776@end group
6777@end lisp
6778
6779Then we have the different use cases:
6780
6781@lisp
6782@group
6783;; Local file name.
6784(test-operation "/a/b")
6785@result{} "Original implementation for /a/b"
6786@end group
6787
6788@group
6789;; Remote file name, handled by `tramp-sh'.
6790(test-operation "/ssh::/a/b")
6791@result{} "Handler implementation for /ssh::/a/b"
6792@end group
6793
6794@group
6795;; Remote file name, handled by `tramp-gvfs'.
6796(test-operation "/sftp::/a/b")
6797@result{} "Original implementation for /sftp::/a/b"
6798@end group
6799@end lisp
6800
6801@var{function} is implemented like an ordinary @value{tramp} backend
6802handler, see the examples in @code{tramp-<backend>-handle-*} and
6803@code{tramp-handle-*}. It can expect, that the first argument (or
6804@code{default-directory}, if that is @code{nil}) has remote file name
6805syntax. It shall use @value{tramp} internal macros and functions like
6806@code{with-parsed-tramp-file-name} and the different cache functions.
6807
6808If the same @var{function} shall be used for different @value{tramp}
6809backends, @code{tramp-add-external-operation} must be called for every
6810backend, respectively.
6811@end defun
6812
6813@defun tramp-remove-external-operation operation backend
6814The handler for @var{operation}, added by
6815@code{tramp-add-external-operation}, is removed from @var{backend}.
6816If there are handlers of @var{operation} for other @var{backend}s,
6817they are kept. Example:
6818
6819@lisp
6820@group
6821(tramp-remove-external-operation
6822 #'test-operation 'tramp-sh)
6823@end group
6824@end lisp
6825@end defun
6826
6827
6724@node Traces and Profiles 6828@node Traces and Profiles
6725@chapter How to Customize Traces 6829@chapter How to Customize Traces
6726@vindex tramp-verbose 6830@vindex tramp-verbose