aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-04-28 22:29:38 +0000
committerRichard M. Stallman2002-04-28 22:29:38 +0000
commit10cf1ba83a1cbbb8642d552fe2bca14513992ea3 (patch)
tree7ed1a4350a2873668dfee4d46e9b6558b2ffe3e9
parent5c2a80ad5c8133b8712d3b606bd7987945b99f63 (diff)
downloademacs-10cf1ba83a1cbbb8642d552fe2bca14513992ea3.tar.gz
emacs-10cf1ba83a1cbbb8642d552fe2bca14513992ea3.zip
(make-temp-file): New arg SUFFIX.
-rw-r--r--lisp/subr.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 6b9820f3e42..12c8272782c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1843,20 +1843,24 @@ Return the modified alist."
1843 (setq tail (cdr tail))) 1843 (setq tail (cdr tail)))
1844 alist)) 1844 alist))
1845 1845
1846(defun make-temp-file (prefix &optional dir-flag) 1846(defun make-temp-file (prefix &optional dir-flag suffix)
1847 "Create a temporary file. 1847 "Create a temporary file.
1848The returned file name (created by appending some random characters at the end 1848The returned file name (created by appending some random characters at the end
1849of PREFIX, and expanding against `temporary-file-directory' if necessary, 1849of PREFIX, and expanding against `temporary-file-directory' if necessary,
1850is guaranteed to point to a newly created empty file. 1850is guaranteed to point to a newly created empty file.
1851You can then use `write-region' to write new data into the file. 1851You can then use `write-region' to write new data into the file.
1852 1852
1853If DIR-FLAG is non-nil, create a new empty directory instead of a file." 1853If DIR-FLAG is non-nil, create a new empty directory instead of a file.
1854
1855If SUFFIX is non-nil, add that at the end of the file name."
1854 (let (file) 1856 (let (file)
1855 (while (condition-case () 1857 (while (condition-case ()
1856 (progn 1858 (progn
1857 (setq file 1859 (setq file
1858 (make-temp-name 1860 (make-temp-name
1859 (expand-file-name prefix temporary-file-directory))) 1861 (expand-file-name prefix temporary-file-directory)))
1862 (if suffix
1863 (setq file (concat file suffix)))
1860 (if dir-flag 1864 (if dir-flag
1861 (make-directory file) 1865 (make-directory file)
1862 (write-region "" nil file nil 'silent nil 'excl)) 1866 (write-region "" nil file nil 'silent nil 'excl))