summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2016-08-07 13:57:23 +0200
committerMichael Albinus <michael.albinus@gmx.de>2016-08-07 13:57:23 +0200
commit2c0506173d92dd9d6de409a045668c6b5cf1fcef (patch)
tree2ea1931603ecabe4b544600029b52215cc75f7f7 /doc
parenta798547727081de5b99e1036783084fcb9afec75 (diff)
Add `make-nearby-temp-file' and `temporary-file-directory'
* doc/lispref/files.texi (Unique File Names): Introduce `make-nearby-temp-file' and `temporary-file-directory'. (Magic File Names): Mention `make-nearby-temp-file' and `temporary-file-directory'. * etc/NEWS (provided): Mention `make-nearby-temp-file' and `temporary-file-directory'. * lisp/files.el (mounted-file-systems): New defcustom. (temporary-file-directory, make-nearby-temp-file): New defuns. (normal-backup-enable-predicate): Fix docstring. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): <make-nearby-temp-file, temporary-file-directory>: Add handler. * lisp/net/tramp.el (tramp-file-name-for-operation): Add `make-nearby-temp-file' and `temporary-file-directory'. (tramp-get-remote-tmpdir): Remove compatibility code. (tramp-handle-temporary-file-directory) (tramp-handle-make-nearby-temp-file): New defuns. * lisp/org/ob-core.el (org-babel-local-file-name): * lisp/progmodes/gud.el (gud-common-init): * lisp/vc/vc-hooks.el (vc-user-login-name): Use `file-remote-p'. * lisp/vc/vc-git.el (vc-git-checkin): Handle remote log message. * test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name): Check `tramp--test-enabled'. (tramp-test18-file-attributes): Add tests for `file-ownership-preserved-p'. (tramp-test27-start-file-process, tramp-test28-shell-command): Reduce timeouts in `accept-process-output'. (tramp-test--shell-command-to-string-asynchronously): Add timeout. (tramp-test29-environment-variables): Remove additional sleep calls. (tramp-test32-make-nearby-temp-file): New test. (tramp--test-special-characters, tramp--test-utf8): Adapt docstring. (tramp-test33-special-characters) (tramp-test33-special-characters-with-stat) (tramp-test33-special-characters-with-perl) (tramp-test33-special-characters-with-ls, tramp-test34-utf8) (tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl) (tramp-test34-utf8-with-ls) (tramp-test35-asynchronous-requests) (tramp-test36-recursive-load, tramp-test37-unload): Rename. (tramp--test-ftp-p): Simplify check. (tramp--test-sh-p): New defun. (tramp-test20-file-modes, tramp-test22-file-times) (tramp-test26-process-file, tramp-test27-start-file-process) (tramp-test28-shell-command) (tramp-test29-environment-variables) (tramp-test30-vc-registered) (tramp-test33-special-characters-with-stat) (tramp-test33-special-characters-with-perl) (tramp-test33-special-characters-with-ls) (tramp-test34-utf8-with-stat, tramp-test34-utf8-with-perl) (tramp-test34-utf8-with-ls) (tramp-test35-asynchronous-requests): Use it.
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 ea9d53b0ea..0aea1dfd9a 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
the file, which in some cases may cause a security hole.
@end defun
+Sometimes, it is necessary to create a temporary file on a remote host
+or a mounted directory. The following two functions support this.
+
+@defun make-nearby-temp-file prefix &optional dir-flag suffix
+This function is similar to @code{make-temp-file}, but it creates a
+temporary file as close as possible to @code{default-directory}. If
+@var{prefix} is a relative file name, and @code{default-directory} is
+a remote file name or located on a mounted file systems, the temporary
+file is created in the directory returned by the function
+@code{temporary-file-directory}. Otherwise, the function
+@code{make-temp-file} is used. @var{prefix}, @var{dir-flag} and
+@var{suffix} have the same meaning as in @code{make-temp-file}.
+
+@example
+@group
+(let ((default-directory "/ssh:remotehost:"))
+ (make-nearby-temp-file "foo"))
+ @result{} "/ssh:remotehost:/tmp/foo232J6v"
+@end group
+@end example
+@end defun
+
+@defun temporary-file-directory
+The directory for writing temporary files via
+@code{make-nearby-temp-file}. In case of a remote
+@code{default-directory}, this is a directory for temporary files on
+that remote host. If such a directory does not exist, or
+@code{default-directory} ought to be located on a mounted file system
+(see @code{mounted-file-systems}), the function returns
+@code{default-directory}. For a non-remote and non-mounted
+@code{default-directory}, the value of the variable
+@code{temporary-file-directory} is returned.
+@end defun
+
+In order to extract the local part of the path name from a temporary
+file, the following code could be used:
+
+@example
+@group
+(let ((tmpfile (make-nearby-temp-file "foo")))
+ (or (file-remote-p tmpfile 'localname) tmpfile))
+@end group
+@end example
+
@node File Name Completion
@subsection File Name Completion
@cindex file name completion subroutines
@@ -2903,6 +2947,7 @@ first, before handlers for jobs such as remote file access.
@code{make-auto-save-file-name},
@code{make-directory},
@code{make-directory-internal},
+@code{make-nearby-temp-file},
@code{make-symbolic-link},@*
@code{process-file},
@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.
@code{set-visited-file-modtime}, @code{shell-command},
@code{start-file-process},
@code{substitute-in-file-name},@*
+@code{temporary-file-directory},
@code{unhandled-file-name-directory},
@code{vc-registered},
@code{verify-visited-file-modtime},@*