GNU Emacs Lisp Reference Manual
Some programs need to write temporary files. Here is the usual way to construct a name for such a file:
(make-temp-name (concat "/tmp/" name-of-application))
Here we use the directory `/tmp/' because that is the standard place on Unix for temporary files. The job of make-temp-name is to prevent two different users or two different jobs from trying to use the same name.
(make-temp-name "/tmp/foo")
=> "/tmp/foo021304"
To prevent conflicts among different libraries running in the same Emacs, each Lisp program that uses make-temp-name should have its own string. The number added to the end of the name distinguishes between the same application running in different Emacs jobs.