diff options
| author | Michael Albinus | 2025-08-05 12:00:21 +0200 |
|---|---|---|
| committer | Michael Albinus | 2025-08-05 12:00:21 +0200 |
| commit | 5ff8a9039583b0e9e05b59986126905542fd78a1 (patch) | |
| tree | 67dce4aeaa9f287add8d19cfda080004f11a5667 /doc/misc | |
| parent | 2d2755c3d7b69a11372e8fb8eba3c342cc5f61e8 (diff) | |
| download | emacs-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.texi | 104 |
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 | |||
| 5472 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, | 5473 | Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, |
| 5473 | default being 3. Increase trace levels temporarily when hunting for | 5474 | default being 3. Increase trace levels temporarily when hunting for |
| 5474 | bugs. | 5475 | bugs. |
| 5476 | |||
| 5477 | @item | ||
| 5478 | Use a package with @value{tramp} specific implementation of high-level | ||
| 5479 | operations. For example, the GNU ELPA package @file{tramp-hlo} | ||
| 5480 | implements 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 | |||
| 6736 | By default, @value{tramp} handles the basic operations listed in | ||
| 6737 | @ref{Magic File Names, , Magic File Name Operations, elisp}. | ||
| 6738 | Sometimes, it is desired to support more complex operations directly, | ||
| 6739 | mainly for performance reasons. | ||
| 6740 | |||
| 6741 | An external package package could add an own implementation of an | ||
| 6742 | operation to @value{tramp}, which avoids the performance overhead | ||
| 6743 | caused by using the basic operations which are aware of remote files. | ||
| 6744 | For example, it could implement this by using an own shell script | ||
| 6745 | which collects the information on the remote host for this very | ||
| 6746 | special purpose with one round-trip per-call. | ||
| 6747 | |||
| 6748 | @defun tramp-add-external-operation operation function backend | ||
| 6749 | This adds an implementation of @var{operation} to @value{tramp}'s | ||
| 6750 | backend @var{backend}. @var{function} is the new implementation. | ||
| 6751 | |||
| 6752 | Both @var{operation} and @var{function} shall be function symbols. | ||
| 6753 | They must have the same argument list. The first argument is used to | ||
| 6754 | determine, whether @value{tramp} is invoked (check for remote file | ||
| 6755 | name 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} | ||
| 6759 | backend (except @code{tramp-ftp}). The new implementation will be | ||
| 6760 | applied 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 | |||
| 6779 | Then 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 | ||
| 6802 | handler, 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 | ||
| 6805 | syntax. It shall use @value{tramp} internal macros and functions like | ||
| 6806 | @code{with-parsed-tramp-file-name} and the different cache functions. | ||
| 6807 | |||
| 6808 | If the same @var{function} shall be used for different @value{tramp} | ||
| 6809 | backends, @code{tramp-add-external-operation} must be called for every | ||
| 6810 | backend, respectively. | ||
| 6811 | @end defun | ||
| 6812 | |||
| 6813 | @defun tramp-remove-external-operation operation backend | ||
| 6814 | The handler for @var{operation}, added by | ||
| 6815 | @code{tramp-add-external-operation}, is removed from @var{backend}. | ||
| 6816 | If there are handlers of @var{operation} for other @var{backend}s, | ||
| 6817 | they 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 |