diff options
| author | Michael Albinus | 2016-08-07 13:57:23 +0200 |
|---|---|---|
| committer | Michael Albinus | 2016-08-07 13:57:23 +0200 |
| commit | 2c0506173d92dd9d6de409a045668c6b5cf1fcef (patch) | |
| tree | 2ea1931603ecabe4b544600029b52215cc75f7f7 /doc | |
| parent | a798547727081de5b99e1036783084fcb9afec75 (diff) | |
| download | emacs-2c0506173d92dd9d6de409a045668c6b5cf1fcef.tar.gz emacs-2c0506173d92dd9d6de409a045668c6b5cf1fcef.zip | |
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.texi | 46 |
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 | |||
| 2440 | the file, which in some cases may cause a security hole. | 2440 | the file, which in some cases may cause a security hole. |
| 2441 | @end defun | 2441 | @end defun |
| 2442 | 2442 | ||
| 2443 | Sometimes, it is necessary to create a temporary file on a remote host | ||
| 2444 | or a mounted directory. The following two functions support this. | ||
| 2445 | |||
| 2446 | @defun make-nearby-temp-file prefix &optional dir-flag suffix | ||
| 2447 | This function is similar to @code{make-temp-file}, but it creates a | ||
| 2448 | temporary file as close as possible to @code{default-directory}. If | ||
| 2449 | @var{prefix} is a relative file name, and @code{default-directory} is | ||
| 2450 | a remote file name or located on a mounted file systems, the temporary | ||
| 2451 | file 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 | ||
| 2466 | The 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 | ||
| 2469 | that 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 | |||
| 2477 | In order to extract the local part of the path name from a temporary | ||
| 2478 | file, 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},@* |