aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/files.texi46
1 files changed, 46 insertions, 0 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index ea9d53b0ea6..0aea1dfd9a3 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2440,6 +2440,50 @@ condition, between the @code{make-temp-name} call and the creation of
2440the file, which in some cases may cause a security hole. 2440the file, which in some cases may cause a security hole.
2441@end defun 2441@end defun
2442 2442
2443Sometimes, it is necessary to create a temporary file on a remote host
2444or a mounted directory. The following two functions support this.
2445
2446@defun make-nearby-temp-file prefix &optional dir-flag suffix
2447This function is similar to @code{make-temp-file}, but it creates a
2448temporary file as close as possible to @code{default-directory}. If
2449@var{prefix} is a relative file name, and @code{default-directory} is
2450a remote file name or located on a mounted file systems, the temporary
2451file is created in the directory returned by the function
2452@code{temporary-file-directory}. Otherwise, the function
2453@code{make-temp-file} is used. @var{prefix}, @var{dir-flag} and
2454@var{suffix} have the same meaning as in @code{make-temp-file}.
2455
2456@example
2457@group
2458(let ((default-directory "/ssh:remotehost:"))
2459 (make-nearby-temp-file "foo"))
2460 @result{} "/ssh:remotehost:/tmp/foo232J6v"
2461@end group
2462@end example
2463@end defun
2464
2465@defun temporary-file-directory
2466The directory for writing temporary files via
2467@code{make-nearby-temp-file}. In case of a remote
2468@code{default-directory}, this is a directory for temporary files on
2469that remote host. If such a directory does not exist, or
2470@code{default-directory} ought to be located on a mounted file system
2471(see @code{mounted-file-systems}), the function returns
2472@code{default-directory}. For a non-remote and non-mounted
2473@code{default-directory}, the value of the variable
2474@code{temporary-file-directory} is returned.
2475@end defun
2476
2477In order to extract the local part of the path name from a temporary
2478file, the following code could be used:
2479
2480@example
2481@group
2482(let ((tmpfile (make-nearby-temp-file "foo")))
2483 (or (file-remote-p tmpfile 'localname) tmpfile))
2484@end group
2485@end example
2486
2443@node File Name Completion 2487@node File Name Completion
2444@subsection File Name Completion 2488@subsection File Name Completion
2445@cindex file name completion subroutines 2489@cindex file name completion subroutines
@@ -2903,6 +2947,7 @@ first, before handlers for jobs such as remote file access.
2903@code{make-auto-save-file-name}, 2947@code{make-auto-save-file-name},
2904@code{make-directory}, 2948@code{make-directory},
2905@code{make-directory-internal}, 2949@code{make-directory-internal},
2950@code{make-nearby-temp-file},
2906@code{make-symbolic-link},@* 2951@code{make-symbolic-link},@*
2907@code{process-file}, 2952@code{process-file},
2908@code{rename-file}, @code{set-file-acl}, @code{set-file-modes}, 2953@code{rename-file}, @code{set-file-acl}, @code{set-file-modes},
@@ -2910,6 +2955,7 @@ first, before handlers for jobs such as remote file access.
2910@code{set-visited-file-modtime}, @code{shell-command}, 2955@code{set-visited-file-modtime}, @code{shell-command},
2911@code{start-file-process}, 2956@code{start-file-process},
2912@code{substitute-in-file-name},@* 2957@code{substitute-in-file-name},@*
2958@code{temporary-file-directory},
2913@code{unhandled-file-name-directory}, 2959@code{unhandled-file-name-directory},
2914@code{vc-registered}, 2960@code{vc-registered},
2915@code{verify-visited-file-modtime},@* 2961@code{verify-visited-file-modtime},@*