Commit 767d12f2 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

Use make-temp-file.

parent 93c8d183
1999-10-14 Stefan Monnier <monnier@cs.yale.edu>
* ange-ftp.el (ange-ftp-make-tmp-name, ange-ftp-del-tmp-name):
* browse-url.el (browse-url-of-buffer, browse-url-delete-temp-file),
(browse-url-temp-file-list, browse-url-delete-temp-file-list):
* ediff-util.el (ediff-make-temp-file):
* ediff-vers.el (ediff-pcl-cvs-view-revision):
* emerge.el (emerge-make-temp-file):
* jka-compr.el (jka-compr-make-temp-name, jka-compr-delete-temp-file):
* vc.el (vc-update-change-log):
* mail/mailpost.el (post-mail-send-it):
* mail/metamail.el (metamail-region):
* progmodes/cmacexp.el (c-macro-expansion):
* textmodes/makeinfo.el (makeinfo-region): Use make-temp-file.
1999-10-15 Gerd Moellmann <gerd@gnu.org>
* smtpmail.el (smtpmail-via-smtp): Add support for
......
......@@ -1691,43 +1691,13 @@ good, skip, fatal, or unknown."
;;; Temporary file location and deletion...
;;; ------------------------------------------------------------
(defvar ange-ftp-tmp-name-files ())
(defvar ange-ftp-tmp-name-hashtable (ange-ftp-make-hashtable 10))
(defvar ange-ftp-pid nil)
(defun ange-ftp-get-pid ()
"Half-hearted attempt to get the current process's id."
(setq ange-ftp-pid (substring (make-temp-name "") 1)))
(defun ange-ftp-make-tmp-name (host)
"This routine will return the name of a new file."
(let* ((template (if (ange-ftp-use-gateway-p host)
(make-temp-file (if (ange-ftp-use-gateway-p host)
ange-ftp-gateway-tmp-name-template
ange-ftp-tmp-name-template))
(pid (or ange-ftp-pid (ange-ftp-get-pid)))
(start ?a)
file entry)
(while
(progn
(setq file (format "%s%c%s" template start pid))
(setq entry (intern file ange-ftp-tmp-name-hashtable))
(or (memq entry ange-ftp-tmp-name-files)
(ange-ftp-real-file-exists-p file)))
(if (> (setq start (1+ start)) ?z)
(progn
(setq template (concat template "X"))
(setq start ?a))))
(setq ange-ftp-tmp-name-files
(cons entry ange-ftp-tmp-name-files))
file))
ange-ftp-tmp-name-template)))
(defun ange-ftp-del-tmp-name (temp)
(setq ange-ftp-tmp-name-files
(delq (intern temp ange-ftp-tmp-name-hashtable)
ange-ftp-tmp-name-files))
(condition-case ()
(ange-ftp-real-delete-file temp)
(error nil)))
(defalias 'ange-ftp-del-tmp-name 'delete-file)
;;;; ------------------------------------------------------------
;;;; Interactive gateway program support.
......
......@@ -469,8 +469,6 @@ down (this *won't* always work)."
(defcustom browse-url-lynx-input-delay 0.2
"How many seconds to wait for lynx between moves down from an input field.")
(defvar browse-url-temp-file-list '())
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL input
......@@ -559,35 +557,20 @@ narrowed."
(or browse-url-temp-file-name
(setq browse-url-temp-file-name
(convert-standard-filename
(make-temp-name
(make-temp-file
(expand-file-name "burl" browse-url-temp-dir)))))
(setq file-name browse-url-temp-file-name)
(write-region (point-min) (point-max) file-name nil 'no-message)))
(browse-url-of-file file-name))))
(defun browse-url-delete-temp-file (&optional temp-file-name)
;; Delete browse-url-temp-file-name from the file system and from
;; browse-url-temp-file-list. If optional arg TEMP-FILE-NAME is
;; non-nil, delete it instead, but only from the file system --
;; browse-url-temp-file-list is not affected.
;; Delete browse-url-temp-file-name from the file system
;; If optional arg TEMP-FILE-NAME is non-nil, delete it instead
(let ((file-name (or temp-file-name browse-url-temp-file-name)))
(if (and file-name (file-exists-p file-name))
(progn
(delete-file file-name)
(if (null temp-file-name)
(setq browse-url-temp-file-list
(delete browse-url-temp-file-name
browse-url-temp-file-list)))))))
(defun browse-url-delete-temp-file-list ()
;; Delete all elements of browse-url-temp-file-list.
(while browse-url-temp-file-list
(browse-url-delete-temp-file (car browse-url-temp-file-list))
(setq browse-url-temp-file-list
(cdr browse-url-temp-file-list))))
(delete-file file-name))))
(add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
(add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
;;;###autoload
(defun browse-url-of-dired-file ()
......
......@@ -2922,14 +2922,14 @@ Hit \\[ediff-recenter] to reset the windows afterward."
;; name ends with .Z or .gz
;; This is needed so that patches produced by ediff will
;; have more meaningful names
(make-temp-name short-f))
(make-temp-file short-f))
;; Prefix is most often the same as the file name for the
;; variant. Here we are trying to use the original file name
;; but in the temp directory.
((and prefix (not (file-exists-p f))) f)
;; If a file with the orig name exists, add some random stuff
;; to it.
(t (make-temp-name short-f))))
(t (make-temp-file short-f))))
;; create the file
(ediff-with-current-buffer buff
......
......@@ -306,7 +306,7 @@
(defun ediff-pcl-cvs-view-revision (file rev)
;; if rev = "", get the latest revision
(let ((temp-name (make-temp-name
(let ((temp-name (make-temp-file
(concat ediff-temp-file-prefix
"ediff_" rev))))
(cvs-kill-buffer-visiting temp-name)
......
......@@ -2907,9 +2907,7 @@ keymap. Leaves merge in fast mode."
;; Make a temporary file that only we have access to.
;; PREFIX is appended to emerge-temp-file-prefix to make the filename prefix.
(defun emerge-make-temp-file (prefix)
(let ((f (make-temp-name (concat emerge-temp-file-prefix prefix))))
;; create the file
(write-region (point-min) (point-min) f nil 'no-message)
(let ((f (make-temp-file (concat emerge-temp-file-prefix prefix))))
(set-file-modes f emerge-temp-file-mode)
f))
......
1999-10-15 Stefan Monnier <monnier@cs.yale.edu>
* gnus-start.el (gnus-slave-save-newsrc):
* gnus-uu.el (gnus-uu-tmp-dir, gnus-uu-decode-binhex)
(gnus-uu-decode-binhex-view, gnus-uu-digest-mail-forward)
(gnus-uu-initialize):
* nnmail.el (nnmail-make-complex-temp-name, nnmail-get-new-mail):
Use make-temp-file.
1999-09-07 Eli Zaretskii <eliz@gnu.org>
* nnsoup.el (nnsoup-tmp-directory): Use temporary-file-directory.
......
......@@ -2404,12 +2404,12 @@ If FORCE is non-nil, the .newsrc file is read."
(save-excursion
(set-buffer gnus-dribble-buffer)
(let ((slave-name
(make-temp-name (concat gnus-current-startup-file "-slave-")))
(make-temp-file (concat gnus-current-startup-file "-slave-")))
(modes (ignore-errors
(file-modes (concat gnus-current-startup-file ".eld")))))
(gnus-write-buffer slave-name)
(when modes
(set-file-modes slave-name modes)))))
(set-file-modes slave-name modes))
(gnus-write-buffer slave-name))))
(defun gnus-master-read-slave-newsrc ()
(let ((slave-files
......
......@@ -219,7 +219,7 @@ Note that this variable can be used in conjunction with the
(defcustom gnus-uu-tmp-dir temporary-file-directory
"*Variable saying where gnus-uu is to do its work.
Default is \"/tmp/\"."
Defaults to `temporary-file-directory'."
:group 'gnus-extract
:type 'directory)
......@@ -450,7 +450,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
gnus-uu-default-dir
gnus-uu-default-dir))))
(setq gnus-uu-binhex-article-name
(make-temp-name (concat gnus-uu-work-dir "binhex")))
(make-temp-file (concat gnus-uu-work-dir "binhex")))
(gnus-uu-decode-with-method 'gnus-uu-binhex-article n dir))
(defun gnus-uu-decode-uu-view (&optional n)
......@@ -503,7 +503,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
(read-file-name "Unbinhex, view and save in dir: "
gnus-uu-default-dir gnus-uu-default-dir)))
(setq gnus-uu-binhex-article-name
(make-temp-name (concat gnus-uu-work-dir "binhex")))
(make-temp-file (concat gnus-uu-work-dir "binhex")))
(let ((gnus-view-pseudos (or gnus-view-pseudos 'automatic)))
(gnus-uu-decode-binhex n file)))
......@@ -514,7 +514,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
"Digests and forwards all articles in this series."
(interactive "P")
(let ((gnus-uu-save-in-digest t)
(file (make-temp-name (nnheader-concat gnus-uu-tmp-dir "forward")))
(file (make-temp-file (nnheader-concat gnus-uu-tmp-dir "forward")))
buf subject from)
(gnus-setup-message 'forward
(setq gnus-uu-digest-from-subject nil)
......@@ -1678,8 +1678,7 @@ didn't work, and overwrite existing files. Otherwise, ask each time."
gnus-uu-tmp-dir)))
(setq gnus-uu-work-dir
(make-temp-name (concat gnus-uu-tmp-dir "gnus")))
(gnus-make-directory gnus-uu-work-dir)
(make-temp-file (concat gnus-uu-tmp-dir "gnus") t))
(set-file-modes gnus-uu-work-dir 448)
(setq gnus-uu-work-dir (file-name-as-directory gnus-uu-work-dir))
(push (cons gnus-newsgroup-name gnus-uu-work-dir)
......
......@@ -1238,13 +1238,6 @@ Return the number of characters in the body."
;;; Utility functions
(defun nnmail-make-complex-temp-name (prefix)
(let ((newname (make-temp-name prefix))
(newprefix prefix))
(while (file-exists-p newname)
(setq newprefix (concat newprefix "x"))
(setq newname (make-temp-name newprefix)))
newname))
;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
......@@ -1623,8 +1616,7 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
nnmail-crash-box (intern (format "%s-save-mail" method))
spool-func group (intern (format "%s-active-number" method)))
;; Check whether the inbox is to be moved to the special tmp dir.
(setq incoming
(nnmail-make-complex-temp-name
(let ((prefix
(expand-file-name
(if nnmail-tmp-directory
(concat
......@@ -1632,8 +1624,9 @@ See the documentation for the variable `nnmail-split-fancy' for documentation."
(file-name-nondirectory
(concat (file-name-as-directory temp) "Incoming")))
(concat (file-name-as-directory temp) "Incoming")))))
(unless (file-exists-p (file-name-directory incoming))
(make-directory (file-name-directory incoming) t))
(unless (file-exists-p (file-name-directory prefix))
(make-directory (file-name-directory prefix) t))
(setq incoming (make-temp-file prefix)))
(rename-file nnmail-crash-box incoming t)
(push incoming incomings))))
;; If we did indeed read any incoming spools, we save all info.
......
......@@ -356,49 +356,11 @@ There should be no more than seven characters after the final `/'."
:type 'string
:group 'jka-compr)
(defvar jka-compr-temp-name-table (make-vector 31 nil))
(defun jka-compr-make-temp-name (&optional local-copy)
"This routine will return the name of a new file."
(let* ((lastchar ?a)
(prevchar ?a)
(template (concat jka-compr-temp-name-template "aa"))
(lastpos (1- (length template)))
(not-done t)
file
entry)
(while not-done
(aset template lastpos lastchar)
(setq file (concat (make-temp-name template) "#"))
(setq entry (intern file jka-compr-temp-name-table))
(if (or (get entry 'active)
(file-exists-p file))
(progn
(setq lastchar (1+ lastchar))
(if (> lastchar ?z)
(progn
(setq prevchar (1+ prevchar))
(setq lastchar ?a)
(if (> prevchar ?z)
(error "Can't allocate temp file.")
(aset template (1- lastpos) prevchar)))))
(put entry 'active (not local-copy))
(setq not-done nil)))
file))
(defun jka-compr-delete-temp-file (temp)
(put (intern temp jka-compr-temp-name-table)
'active nil)
(make-temp-file jka-compr-temp-name-template))
(condition-case ()
(delete-file temp)
(error nil)))
(defalias 'jka-compr-delete-temp-file 'delete-file)
(defun jka-compr-write-region (start end file &optional append visit)
......
......@@ -28,7 +28,7 @@ site-init."
(let ((errbuf (if mail-interactive
(generate-new-buffer " post-mail errors")
0))
(temfile (expand-file-name ",rpost" temporary-file-directory))
(temfile (make-temp-file ",rpost"))
(tembuf (generate-new-buffer " post-mail temp"))
(case-fold-search nil)
delimline
......@@ -74,8 +74,8 @@ site-init."
(save-excursion
(set-buffer errbuf)
(erase-buffer))))
(write-file (setq temfile (make-temp-name temfile)))
(set-file-modes temfile 384)
(write-file temfile)
(apply 'call-process
(append (list (if (boundp 'post-mail-program)
post-mail-program
......
......@@ -3,7 +3,7 @@
;; Copyright (C) 1993, 1996 Free Software Foundation, Inc.
;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
;; Version: $Id: metamail.el,v 1.11 1999/01/11 12:36:15 fx Exp rms $
;; Version: $Id: metamail.el,v 1.12 1999/08/28 18:25:16 rms Exp $
;; Keywords: mail, news, mime, multimedia
;; This file is part of GNU Emacs.
......@@ -165,7 +165,7 @@ redisplayed as output is inserted."
(interactive "r\np")
(let ((curbuf (current-buffer))
(buffer-read-only nil)
(metafile (make-temp-name (expand-file-name "metamail" temporary-file-directory)))
(metafile (make-temp-file "metamail"))
(option-environment
(list (format "EMACS_VIEW_MODE=%d"
(if (numberp viewmode) viewmode 1)))))
......
......@@ -265,7 +265,7 @@ Optional arg DISPLAY non-nil means show messages in the echo area."
(startstat ())
(startmarker "")
(exit-status 0)
(tempname (make-temp-name
(tempname (make-temp-file
(expand-file-name "cmacexp"
(or small-temporary-file-directory
temporary-file-directory)))))
......
......@@ -97,7 +97,7 @@ command to gain use of `next-error'."
(setq makeinfo-temp-file
(concat
(make-temp-name
(make-temp-file
(substring (buffer-file-name)
0
(or (string-match "\\.tex" (buffer-file-name))
......
......@@ -5,7 +5,7 @@
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
;; $Id: vc.el,v 1.255 1999/09/22 12:58:49 spiegel Exp $
;; $Id: vc.el,v 1.256 1999/10/02 10:53:18 spiegel Exp $
;; This file is part of GNU Emacs.
......@@ -755,6 +755,8 @@ before the filename."
(let ((new-mark (vc-find-position-by-context mark-context)))
(if new-mark (set-mark new-mark))))))
;; Maybe this "smart mark preservation" could be added directly
;; to revert-buffer since it can be generally useful. -sm
(defun vc-revert-buffer1 (&optional arg no-confirm)
;; Revert buffer, try to keep point and mark where user expects them in spite
;; of changes because of expanded version-control key words.
......@@ -2261,7 +2263,7 @@ default directory."
(let ((odefault default-directory)
(changelog (find-change-log))
;; Presumably not portable to non-Unixy systems, along with rcs2log:
(tempfile (make-temp-name
(tempfile (make-temp-file
(expand-file-name "vc"
(or small-temporary-file-directory
temporary-file-directory))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment