changeset 26039:fb6b9c37cdc4

Use make-temp-file.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 15 Oct 1999 16:03:59 +0000
parents 2f34f175497c
children 8500b0f62b8e
files lisp/ChangeLog lisp/ange-ftp.el lisp/browse-url.el lisp/ediff-util.el lisp/ediff-vers.el lisp/emerge.el lisp/gnus/ChangeLog lisp/gnus/gnus-start.el lisp/gnus/gnus-uu.el lisp/gnus/nnmail.el lisp/jka-compr.el lisp/mail/mailpost.el lisp/mail/metamail.el lisp/progmodes/cmacexp.el lisp/textmodes/makeinfo.el lisp/vc.el
diffstat 16 files changed, 60 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/ChangeLog	Fri Oct 15 16:03:59 1999 +0000
@@ -1,3 +1,18 @@
+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
--- a/lisp/ange-ftp.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/ange-ftp.el	Fri Oct 15 16:03:59 1999 +0000
@@ -1691,43 +1691,13 @@
 ;;; 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))
-
-(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)))
+		     ange-ftp-tmp-name-template)))
+
+(defalias 'ange-ftp-del-tmp-name 'delete-file)
 
 ;;;; ------------------------------------------------------------
 ;;;; Interactive gateway program support.
--- a/lisp/browse-url.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/browse-url.el	Fri Oct 15 16:03:59 1999 +0000
@@ -469,8 +469,6 @@
 (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 @@
 	    (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 ()
--- a/lisp/ediff-util.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/ediff-util.el	Fri Oct 15 16:03:59 1999 +0000
@@ -2922,14 +2922,14 @@
 		   ;; 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
--- a/lisp/ediff-vers.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/ediff-vers.el	Fri Oct 15 16:03:59 1999 +0000
@@ -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)
--- a/lisp/emerge.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/emerge.el	Fri Oct 15 16:03:59 1999 +0000
@@ -2907,9 +2907,7 @@
 ;; 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))
 
--- a/lisp/gnus/ChangeLog	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/gnus/ChangeLog	Fri Oct 15 16:03:59 1999 +0000
@@ -1,3 +1,12 @@
+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.
--- a/lisp/gnus/gnus-start.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/gnus/gnus-start.el	Fri Oct 15 16:03:59 1999 +0000
@@ -2404,12 +2404,12 @@
   (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
--- a/lisp/gnus/gnus-uu.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/gnus/gnus-uu.el	Fri Oct 15 16:03:59 1999 +0000
@@ -219,7 +219,7 @@
 
 (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 @@
 			  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 @@
 	 (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 @@
   "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 @@
 		 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)
--- a/lisp/gnus/nnmail.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/gnus/nnmail.el	Fri Oct 15 16:03:59 1999 +0000
@@ -1238,13 +1238,6 @@
 
 ;;; 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 @@
 	     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 @@
 			 (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.
--- a/lisp/jka-compr.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/jka-compr.el	Fri Oct 15 16:03:59 1999 +0000
@@ -356,49 +356,11 @@
   :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))
+  (make-temp-file jka-compr-temp-name-template))
 
-	  (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)
-
-  (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)
--- a/lisp/mail/mailpost.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/mail/mailpost.el	Fri Oct 15 16:03:59 1999 +0000
@@ -28,7 +28,7 @@
   (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 @@
 		(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
--- a/lisp/mail/metamail.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/mail/metamail.el	Fri Oct 15 16:03:59 1999 +0000
@@ -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 @@
   (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)))))
--- a/lisp/progmodes/cmacexp.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/progmodes/cmacexp.el	Fri Oct 15 16:03:59 1999 +0000
@@ -265,7 +265,7 @@
 	(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)))))
--- a/lisp/textmodes/makeinfo.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/textmodes/makeinfo.el	Fri Oct 15 16:03:59 1999 +0000
@@ -97,7 +97,7 @@
 
     (setq makeinfo-temp-file
           (concat
-           (make-temp-name
+           (make-temp-file
             (substring (buffer-file-name)
                        0 
                        (or (string-match "\\.tex" (buffer-file-name)) 
--- a/lisp/vc.el	Fri Oct 15 15:48:53 1999 +0000
+++ b/lisp/vc.el	Fri Oct 15 16:03:59 1999 +0000
@@ -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 @@
          (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 @@
   (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))))