Function: make-nearby-temp-file
make-nearby-temp-file is a byte-compiled function defined in
files.el.gz.
Signature
(make-nearby-temp-file PREFIX &optional DIR-FLAG SUFFIX)
Documentation
Create a temporary file as close as possible to default-directory.
Return the absolute file name of the created file.
If PREFIX is a relative file name, and 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 temporary-file-directory(var)/temporary-file-directory(fun). Otherwise, the function
make-temp-file is used. PREFIX, DIR-FLAG and SUFFIX have the
same meaning as in make-temp-file.
Other relevant functions are documented in the file group.
Probably introduced at or before Emacs version 26.1.
Shortdoc
;; file
(make-nearby-temp-file "/tmp/foo-")
e.g. => "/tmp/foo-xe8iON"
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun make-nearby-temp-file (prefix &optional dir-flag suffix)
"Create a temporary file as close as possible to `default-directory'.
Return the absolute file name of the created file.
If PREFIX is a relative file name, and `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 `temporary-file-directory'. Otherwise, the function
`make-temp-file' is used. PREFIX, DIR-FLAG and SUFFIX have the
same meaning as in `make-temp-file'."
(let ((handler (find-file-name-handler
default-directory 'make-nearby-temp-file)))
(if (and handler (not (file-name-absolute-p default-directory)))
(funcall handler 'make-nearby-temp-file prefix dir-flag suffix)
(let ((temporary-file-directory (temporary-file-directory)))
(make-temp-file prefix dir-flag suffix)))))