aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMichael Albinus2019-11-20 13:45:30 +0100
committerMichael Albinus2019-11-20 13:45:30 +0100
commit035931777bd89b939436fd1d8a2b8d5a80ede095 (patch)
treeb0ce714884bc106eaa95415754e807cb40c761e6 /doc
parent5c5c1b559313d06aab6516ff1b1acf1da3a01c7d (diff)
downloademacs-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.texi140
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
158How file names, directories and localnames are mangled and managed 159How file names, directories and localnames are mangled and managed
@@ -1409,7 +1410,7 @@ use the @samp{john} as the default user for the domain
1409A Caution: @value{tramp} will override any default user specified in 1410A Caution: @value{tramp} will override any default user specified in
1410the configuration files outside Emacs, such as @file{~/.ssh/config}. 1411the configuration files outside Emacs, such as @file{~/.ssh/config}.
1411To stop @value{tramp} from applying the default value, set the 1412To stop @value{tramp} from applying the default value, set the
1412corresponding alist entry to nil: 1413corresponding 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
3375This command flushes all connection related objects. @option{vec} is 3377This command flushes all connection related objects. @var{vec} is the
3376the internal representation of a remote connection. When called 3378internal representation of a remote connection. When called
3377interactively, this command lists active remote connections in the 3379interactively, this command lists active remote connections in the
3378minibuffer. Each connection is of the format 3380minibuffer. 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
3384Conveniences, , , emacs}). It also deletes session timers 3386Conveniences, , , emacs}). It also deletes session timers
3385(@pxref{Predefined connection information}) and connection buffers. 3387(@pxref{Predefined connection information}) and connection buffers.
3388
3389If @var{keep-debug} is non-@code{nil}, the debug buffer is kept. A
3390non-@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
3389Flushes only the current buffer's remote connection objects, the same 3394Flushes the current buffer's remote connection objects, the same as in
3390as 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
3416Sometimes, it is desirable to safe file contents of buffers visiting a
3417given remote host. This could happen for example, if the local host
3418changes its network integration, and the remote host is not reachable
3419anymore.
3420
3421@deffn Command tramp-rename-files source target
3422Replace in all buffers the visiting file name from @var{source} to
3423@var{target}. @var{source} is a remote directory name, which could
3424contain also a localname part. @var{target} is the directory name
3425@var{source} is replaced with. Often, @var{target} is a remote
3426directory name on another host, but it can also be a local directory
3427name. If @var{target} has no local part, the local part from
3428@var{source} is used.
3429
3430If @var{target} is @code{nil}, it is selected according to the first
3431match in @code{tramp-default-rename-alist}. If called interactively,
3432this match is offered as initial value for selection.
3433
3434On 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
3438prompted for modification in the minibuffer. The buffers are marked
3439modified, and must be saved explicitly.
3440
3441If user option @code{tramp-confirm-rename-file-names} is nil, changing
3442the file name happens without confirmation. This requires a
3443matching entry in @code{tramp-default-rename-alist}.
3444
3445Remote buffers related to the remote connection identified by
3446@var{source}, which are not visiting files, or which are visiting
3447files not matching @var{source}, are not modified.
3448
3449Interactively, @var{target} is selected from
3450@code{tramp-default-rename-alist} without confirmation if the prefix
3451argument is non-@code{nil}.
3452
3453The 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
3458Replace visiting file names to @var{target}. The current buffer must
3459be related to a remote connection. In all buffers, which are visiting
3460a file with the same directory name, the buffer file name is changed.
3461
3462Interactively, @var{target} is selected from
3463@code{tramp-default-rename-alist} without confirmation if the prefix
3464argument is non-@code{nil}.
3465@end deffn
3466
3467@defopt tramp-default-rename-alist
3468The default target for renaming remote buffer file names. This is an
3469alist of cons cells @code{(source . target)}. The first matching item
3470specifies the target to be applied for renaming buffer file names from
3471source via @code{tramp-rename-files}. @code{source} is a regular
3472expressions, which matches a remote file name. @code{target} must be
3473a directory name, which could be remote (including remote directories
3474Tramp 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
3478name of @code{source} when calling @code{tramp-rename-files}.
3479
3480@code{source} could also be a Lisp form, which will be evaluated. The
3481result must be a string or nil, which is interpreted as a regular
3482expression which always matches.
3483
3484Example 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
3493would 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
3500routes all connections to a host in @samp{company.org} via
3501@samp{@trampfn{ssh,multi.hop,}}, which might be useful when using
3502Emacs outside the company network.
3503
3504@lisp
3505(nil . "~/saved-files/%m:%u@@%h/")
3506@end lisp
3507
3508saves all remote files locally, with a directory name including method
3509name, user name and host name of the remote connection.
3510@end defopt
3511
3512@defopt tramp-confirm-rename-file-names
3513Whether 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
3415archives. This is possible only on machines which have installed 3526archives. 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
3417methods}. Internally, file archives are mounted via the 3528methods}. 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
4554How to save files when a remote host isn't reachable anymore?
4555
4556If the local machine Emacs is running on changes its network
4557integration, remote hosts could become unreachable. This happens for
4558example, if the local machine is moved between your office and your
4559home without restarting Emacs.
4560
4561In such cases, the command @code{tramp-rename-files} can be used to
4562alter remote buffers’ method, host, and/or directory names. This
4563permits saving their contents in the same location via another network
4564path, or somewhere else entirely (including locally). @pxref{Renaming
4565remote files}.
4566
4567
4568@item
4443How to disable other packages from calling @value{tramp}? 4569How to disable other packages from calling @value{tramp}?
4444 4570
4445There are packages that call @value{tramp} without the user ever 4571There are packages that call @value{tramp} without the user ever