Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
cdd9f643
Commit
cdd9f643
authored
Sep 11, 1999
by
Richard M. Stallman
Browse files
(make-temp-file): New function.
parent
e596094d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
lisp/subr.el
lisp/subr.el
+24
-0
No files found.
lisp/subr.el
View file @
cdd9f643
...
...
@@ -1302,4 +1302,28 @@ Return the modified alist."
(
setq
tail
(
cdr
tail
)))
alist
))
(
defun
make-temp-file
(
prefix
&optional
dir-flag
)
"Create a temporary file.
The returned file name (created by appending some random characters at the end
of PREFIX, and expanding against `temporary-file-directory' if necessary,
is guaranteed to point to a newly created empty file.
You can then use `write-region' to write new data into the file.
If DIR-FLAG is non-nil, create a new empty directory instead of a file."
(
let
(
file
)
(
while
(
condition-case
()
(
progn
(
setq
file
(
make-temp-name
(
expand-file-name
prefix
temporary-file-directory
)))
(
if
dir-flag
(
make-directory
file
)
(
write-region
""
nil
file
nil
'silent
nil
'excl
))
nil
)
(
file-already-exists
t
))
;; the file was somehow created by someone else between
;; `make-temp-name' and `write-region', let's try again.
nil
)
file
))
;;; subr.el ends here
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment