diff options
| author | Michael Albinus | 2019-11-20 13:45:30 +0100 |
|---|---|---|
| committer | Michael Albinus | 2019-11-20 13:45:30 +0100 |
| commit | 035931777bd89b939436fd1d8a2b8d5a80ede095 (patch) | |
| tree | b0ce714884bc106eaa95415754e807cb40c761e6 /doc | |
| parent | 5c5c1b559313d06aab6516ff1b1acf1da3a01c7d (diff) | |
| download | emacs-035931777bd89b939436fd1d8a2b8d5a80ede095.tar.gz emacs-035931777bd89b939436fd1d8a2b8d5a80ede095.zip | |
Add renaming of remote buffer file names to Tramp
* doc/misc/tramp.texi (Default User): Fix typo.
(Cleanup remote connections): Adapt arguments of
`tramp-cleanup-connection'.
(Renaming remote files): New node.
(Frequently Asked Questions): New item "How to save files when a
remote host isn't reachable anymore?".
* etc/NEWS: Add `tramp-rename-files' and `tramp-rename-these-files'.
* lisp/net/tramp-cmds.el (tramp-default-rename-alist)
(tramp-confirm-rename-file-names): New defcustoms.
(tramp-rename-read-file-name-dir)
(tramp-rename-read-file-name-init): New defsubsts.
(tramp-default-rename-file, tramp-rename-files)
(tramp-rename-these-files): New defuns.
* lisp/net/tramp-integration.el (ido, ivy): Integrate with them.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/tramp.texi | 140 |
1 files changed, 133 insertions, 7 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 67472a87a32..dd1378a8da7 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -153,6 +153,7 @@ Using @value{tramp} | |||
| 153 | * Ad-hoc multi-hops:: Declaring multiple hops in the file name. | 153 | * Ad-hoc multi-hops:: Declaring multiple hops in the file name. |
| 154 | * Remote processes:: Integration with other Emacs packages. | 154 | * Remote processes:: Integration with other Emacs packages. |
| 155 | * Cleanup remote connections:: Cleanup remote connections. | 155 | * Cleanup remote connections:: Cleanup remote connections. |
| 156 | * Renaming remote files:: Renaming remote files. | ||
| 156 | * Archive file names:: Access to files in file archives. | 157 | * Archive file names:: Access to files in file archives. |
| 157 | 158 | ||
| 158 | How file names, directories and localnames are mangled and managed | 159 | How file names, directories and localnames are mangled and managed |
| @@ -1409,7 +1410,7 @@ use the @samp{john} as the default user for the domain | |||
| 1409 | A Caution: @value{tramp} will override any default user specified in | 1410 | A Caution: @value{tramp} will override any default user specified in |
| 1410 | the configuration files outside Emacs, such as @file{~/.ssh/config}. | 1411 | the configuration files outside Emacs, such as @file{~/.ssh/config}. |
| 1411 | To stop @value{tramp} from applying the default value, set the | 1412 | To stop @value{tramp} from applying the default value, set the |
| 1412 | corresponding alist entry to nil: | 1413 | corresponding alist entry to @code{nil}: |
| 1413 | 1414 | ||
| 1414 | @lisp | 1415 | @lisp |
| 1415 | @group | 1416 | @group |
| @@ -2710,6 +2711,7 @@ is a feature of Emacs that may cause missed prompts when using | |||
| 2710 | * Ad-hoc multi-hops:: Declaring multiple hops in the file name. | 2711 | * Ad-hoc multi-hops:: Declaring multiple hops in the file name. |
| 2711 | * Remote processes:: Integration with other Emacs packages. | 2712 | * Remote processes:: Integration with other Emacs packages. |
| 2712 | * Cleanup remote connections:: Cleanup remote connections. | 2713 | * Cleanup remote connections:: Cleanup remote connections. |
| 2714 | * Renaming remote files:: Renaming remote files. | ||
| 2713 | * Archive file names:: Access to files in file archives. | 2715 | * Archive file names:: Access to files in file archives. |
| 2714 | @end menu | 2716 | @end menu |
| 2715 | 2717 | ||
| @@ -3371,9 +3373,9 @@ To open @command{powershell} as a remote shell, use this: | |||
| 3371 | 3373 | ||
| 3372 | @value{tramp} provides several ways to flush remote connections. | 3374 | @value{tramp} provides several ways to flush remote connections. |
| 3373 | 3375 | ||
| 3374 | @deffn Command tramp-cleanup-connection vec | 3376 | @deffn Command tramp-cleanup-connection vec &optional keep-debug keep-password |
| 3375 | This command flushes all connection related objects. @option{vec} is | 3377 | This command flushes all connection related objects. @var{vec} is the |
| 3376 | the internal representation of a remote connection. When called | 3378 | internal representation of a remote connection. When called |
| 3377 | interactively, this command lists active remote connections in the | 3379 | interactively, this command lists active remote connections in the |
| 3378 | minibuffer. Each connection is of the format | 3380 | minibuffer. Each connection is of the format |
| 3379 | @file{@trampfn{method,user@@host,}}. | 3381 | @file{@trampfn{method,user@@host,}}. |
| @@ -3383,11 +3385,14 @@ Flushing remote connections also cleans the password cache | |||
| 3383 | (@pxref{Connection caching}), and recentf cache (@pxref{File | 3385 | (@pxref{Connection caching}), and recentf cache (@pxref{File |
| 3384 | Conveniences, , , emacs}). It also deletes session timers | 3386 | Conveniences, , , emacs}). It also deletes session timers |
| 3385 | (@pxref{Predefined connection information}) and connection buffers. | 3387 | (@pxref{Predefined connection information}) and connection buffers. |
| 3388 | |||
| 3389 | If @var{keep-debug} is non-@code{nil}, the debug buffer is kept. A | ||
| 3390 | non-@code{nil} @var{keep-password} preserves the password cache. | ||
| 3386 | @end deffn | 3391 | @end deffn |
| 3387 | 3392 | ||
| 3388 | @deffn Command tramp-cleanup-this-connection | 3393 | @deffn Command tramp-cleanup-this-connection |
| 3389 | Flushes only the current buffer's remote connection objects, the same | 3394 | Flushes the current buffer's remote connection objects, the same as in |
| 3390 | as in @code{tramp-cleanup-connection}. | 3395 | @code{tramp-cleanup-connection}. |
| 3391 | @end deffn | 3396 | @end deffn |
| 3392 | 3397 | ||
| 3393 | @deffn Command tramp-cleanup-all-connections | 3398 | @deffn Command tramp-cleanup-all-connections |
| @@ -3404,6 +3409,112 @@ killing all buffers related to remote connections. | |||
| 3404 | @end deffn | 3409 | @end deffn |
| 3405 | 3410 | ||
| 3406 | 3411 | ||
| 3412 | @node Renaming remote files | ||
| 3413 | @section Renaming remote files | ||
| 3414 | @cindex save remote files | ||
| 3415 | |||
| 3416 | Sometimes, it is desirable to safe file contents of buffers visiting a | ||
| 3417 | given remote host. This could happen for example, if the local host | ||
| 3418 | changes its network integration, and the remote host is not reachable | ||
| 3419 | anymore. | ||
| 3420 | |||
| 3421 | @deffn Command tramp-rename-files source target | ||
| 3422 | Replace in all buffers the visiting file name from @var{source} to | ||
| 3423 | @var{target}. @var{source} is a remote directory name, which could | ||
| 3424 | contain also a localname part. @var{target} is the directory name | ||
| 3425 | @var{source} is replaced with. Often, @var{target} is a remote | ||
| 3426 | directory name on another host, but it can also be a local directory | ||
| 3427 | name. If @var{target} has no local part, the local part from | ||
| 3428 | @var{source} is used. | ||
| 3429 | |||
| 3430 | If @var{target} is @code{nil}, it is selected according to the first | ||
| 3431 | match in @code{tramp-default-rename-alist}. If called interactively, | ||
| 3432 | this match is offered as initial value for selection. | ||
| 3433 | |||
| 3434 | On all buffers, which have a @code{buffer-file-name} matching | ||
| 3435 | @var{source}, this name is modified by replacing @var{source} with | ||
| 3436 | @var{target}. This is applied by calling | ||
| 3437 | @code{set-visited-file-name}. The new @code{buffer-file-name} is | ||
| 3438 | prompted for modification in the minibuffer. The buffers are marked | ||
| 3439 | modified, and must be saved explicitly. | ||
| 3440 | |||
| 3441 | If user option @code{tramp-confirm-rename-file-names} is nil, changing | ||
| 3442 | the file name happens without confirmation. This requires a | ||
| 3443 | matching entry in @code{tramp-default-rename-alist}. | ||
| 3444 | |||
| 3445 | Remote buffers related to the remote connection identified by | ||
| 3446 | @var{source}, which are not visiting files, or which are visiting | ||
| 3447 | files not matching @var{source}, are not modified. | ||
| 3448 | |||
| 3449 | Interactively, @var{target} is selected from | ||
| 3450 | @code{tramp-default-rename-alist} without confirmation if the prefix | ||
| 3451 | argument is non-@code{nil}. | ||
| 3452 | |||
| 3453 | The remote connection identified by @var{source} is flushed by | ||
| 3454 | @code{tramp-cleanup-connection}. | ||
| 3455 | @end deffn | ||
| 3456 | |||
| 3457 | @deffn Command tramp-rename-these-files target | ||
| 3458 | Replace visiting file names to @var{target}. The current buffer must | ||
| 3459 | be related to a remote connection. In all buffers, which are visiting | ||
| 3460 | a file with the same directory name, the buffer file name is changed. | ||
| 3461 | |||
| 3462 | Interactively, @var{target} is selected from | ||
| 3463 | @code{tramp-default-rename-alist} without confirmation if the prefix | ||
| 3464 | argument is non-@code{nil}. | ||
| 3465 | @end deffn | ||
| 3466 | |||
| 3467 | @defopt tramp-default-rename-alist | ||
| 3468 | The default target for renaming remote buffer file names. This is an | ||
| 3469 | alist of cons cells @code{(source . target)}. The first matching item | ||
| 3470 | specifies the target to be applied for renaming buffer file names from | ||
| 3471 | source via @code{tramp-rename-files}. @code{source} is a regular | ||
| 3472 | expressions, which matches a remote file name. @code{target} must be | ||
| 3473 | a directory name, which could be remote (including remote directories | ||
| 3474 | Tramp infers by default, such as @samp{@trampfn{method,user@@host,}}). | ||
| 3475 | |||
| 3476 | @code{target} can contain the patterns @code{%m}, @code{%u} or | ||
| 3477 | @code{%h}, which are replaced by the method name, user name or host | ||
| 3478 | name of @code{source} when calling @code{tramp-rename-files}. | ||
| 3479 | |||
| 3480 | @code{source} could also be a Lisp form, which will be evaluated. The | ||
| 3481 | result must be a string or nil, which is interpreted as a regular | ||
| 3482 | expression which always matches. | ||
| 3483 | |||
| 3484 | Example entries: | ||
| 3485 | |||
| 3486 | @lisp | ||
| 3487 | @group | ||
| 3488 | ("@trampfn{ssh,badhost,/path/to/dir/}" | ||
| 3489 | . "@trampfn{ssh,goodhost,/path/to/another/dir/}") | ||
| 3490 | @end group | ||
| 3491 | @end lisp | ||
| 3492 | |||
| 3493 | would trigger renaming of buffer file names on @samp{badhost} to | ||
| 3494 | @samp{goodhost}, including changing the directory name. | ||
| 3495 | |||
| 3496 | @lisp | ||
| 3497 | ("@trampfn{ssh,.+\\\\.company\\\\.org,}" . "@value{prefix}ssh@value{postfixhop}multi.hop|ssh@value{postfixhop}%h@value{postfix}") | ||
| 3498 | @end lisp | ||
| 3499 | |||
| 3500 | routes all connections to a host in @samp{company.org} via | ||
| 3501 | @samp{@trampfn{ssh,multi.hop,}}, which might be useful when using | ||
| 3502 | Emacs outside the company network. | ||
| 3503 | |||
| 3504 | @lisp | ||
| 3505 | (nil . "~/saved-files/%m:%u@@%h/") | ||
| 3506 | @end lisp | ||
| 3507 | |||
| 3508 | saves all remote files locally, with a directory name including method | ||
| 3509 | name, user name and host name of the remote connection. | ||
| 3510 | @end defopt | ||
| 3511 | |||
| 3512 | @defopt tramp-confirm-rename-file-names | ||
| 3513 | Whether renaming a buffer file name by @code{tramp-rename-files} or | ||
| 3514 | @code{tramp-rename-these-files} must be confirmed. | ||
| 3515 | @end defopt | ||
| 3516 | |||
| 3517 | |||
| 3407 | @node Archive file names | 3518 | @node Archive file names |
| 3408 | @section Archive file names | 3519 | @section Archive file names |
| 3409 | @cindex file archives | 3520 | @cindex file archives |
| @@ -3412,7 +3523,7 @@ killing all buffers related to remote connections. | |||
| 3412 | @cindex archive method | 3523 | @cindex archive method |
| 3413 | 3524 | ||
| 3414 | @value{tramp} offers also transparent access to files inside file | 3525 | @value{tramp} offers also transparent access to files inside file |
| 3415 | archives. This is possible only on machines which have installed | 3526 | archives. This is possible only on hosts which have installed |
| 3416 | @acronym{GVFS, the GNOME Virtual File System}, @ref{GVFS-based | 3527 | @acronym{GVFS, the GNOME Virtual File System}, @ref{GVFS-based |
| 3417 | methods}. Internally, file archives are mounted via the | 3528 | methods}. Internally, file archives are mounted via the |
| 3418 | @acronym{GVFS} @option{archive} method. | 3529 | @acronym{GVFS} @option{archive} method. |
| @@ -4440,6 +4551,21 @@ the buffer is remote. See the optional arguments of | |||
| 4440 | 4551 | ||
| 4441 | 4552 | ||
| 4442 | @item | 4553 | @item |
| 4554 | How to save files when a remote host isn't reachable anymore? | ||
| 4555 | |||
| 4556 | If the local machine Emacs is running on changes its network | ||
| 4557 | integration, remote hosts could become unreachable. This happens for | ||
| 4558 | example, if the local machine is moved between your office and your | ||
| 4559 | home without restarting Emacs. | ||
| 4560 | |||
| 4561 | In such cases, the command @code{tramp-rename-files} can be used to | ||
| 4562 | alter remote buffers’ method, host, and/or directory names. This | ||
| 4563 | permits saving their contents in the same location via another network | ||
| 4564 | path, or somewhere else entirely (including locally). @pxref{Renaming | ||
| 4565 | remote files}. | ||
| 4566 | |||
| 4567 | |||
| 4568 | @item | ||
| 4443 | How to disable other packages from calling @value{tramp}? | 4569 | How to disable other packages from calling @value{tramp}? |
| 4444 | 4570 | ||
| 4445 | There are packages that call @value{tramp} without the user ever | 4571 | There are packages that call @value{tramp} without the user ever |