diff options
| -rw-r--r-- | lisp/subr.el | 8 |
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. |
| 1848 | The returned file name (created by appending some random characters at the end | 1848 | The returned file name (created by appending some random characters at the end |
| 1849 | of PREFIX, and expanding against `temporary-file-directory' if necessary, | 1849 | of PREFIX, and expanding against `temporary-file-directory' if necessary, |
| 1850 | is guaranteed to point to a newly created empty file. | 1850 | is guaranteed to point to a newly created empty file. |
| 1851 | You can then use `write-region' to write new data into the file. | 1851 | You can then use `write-region' to write new data into the file. |
| 1852 | 1852 | ||
| 1853 | If DIR-FLAG is non-nil, create a new empty directory instead of a file." | 1853 | If DIR-FLAG is non-nil, create a new empty directory instead of a file. |
| 1854 | |||
| 1855 | If 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)) |