]> git.eshelyaron.com Git - emacs.git/commitdiff
Make ediff-m-empty-t-f obsolete in favor of make-temp-file
authorStefan Kangas <stefankangas@gmail.com>
Sat, 2 Sep 2023 13:07:09 +0000 (15:07 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sat, 2 Sep 2023 13:14:34 +0000 (15:14 +0200)
* lisp/vc/ediff-util.el (ediff-make-empty-tmp-file): Make obsolete
in favor of 'make-temp-file'.  Update callers.

lisp/vc/ediff-util.el

index c4ebe20d7e47ad4f2915e02144424cc5071a23ce..00200f1d1dac5e7f47af7f3505eb53439b57342a 100644 (file)
@@ -3138,16 +3138,15 @@ Hit \\[ediff-recenter] to reset the windows afterward."
                   ;; e.g., if file name ends with .Z or .gz
                    ;; This is needed so that patches produced by ediff will
                   ;; have more meaningful names
-                  (ediff-make-empty-tmp-file short-f))
+                   (make-temp-file short-f))
                  (prefix
                   ;; 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.
-                  (ediff-make-empty-tmp-file f 'keep-name))
+                   ;; variant.
+                   (make-temp-file f))
                  (t
                   ;; If don't care about name, add some random stuff
                   ;; to proposed file name.
-                  (ediff-make-empty-tmp-file short-f))))
+                   (make-temp-file short-f))))
 
     ;; create the file
     (ediff-with-current-buffer buff
@@ -3159,28 +3158,6 @@ Hit \\[ediff-recenter] to reset the windows afterward."
       (set-file-modes f ediff-temp-file-mode)
       (expand-file-name f))))
 
-;; Create a temporary file.
-;; The returned file name (created by appending some random characters at the
-;; end of PROPOSED-NAME is guaranteed to point to a newly created empty file.
-;; This is a replacement for make-temp-name, which eliminates a security hole.
-;; If KEEP-PROPOSED-NAME isn't nil, try to keep PROPOSED-NAME, unless such file
-;; already exists.
-;; It is a modified version of make-temp-file in emacs 20.5
-(defun ediff-make-empty-tmp-file (proposed-name &optional keep-proposed-name)
-  (let ((file proposed-name))
-    (while (condition-case ()
-               (progn
-                (if (or (file-exists-p file) (not keep-proposed-name))
-                    (setq file (make-temp-name proposed-name)))
-                 (write-region "" nil file nil 'silent nil 'excl)
-                 nil)
-            (file-already-exists t))
-      ;; the file was somehow created by someone else between
-      ;; `make-temp-name' and `write-region', let's try again.
-      nil)
-    file))
-
-
 ;; Make sure the current buffer (for a file) has the same contents as the
 ;; file on disk, and attempt to remedy the situation if not.
 ;; Signal an error if we can't make them the same, or the user doesn't want
@@ -4144,6 +4121,10 @@ Mail anyway? (y or n) ")
 (define-obsolete-function-alias 'ediff-intersection #'seq-intersection "28.1")
 (define-obsolete-function-alias 'ediff-set-difference #'seq-difference "28.1")
 
+(defun ediff-make-empty-tmp-file (prefix &optional _ignored)
+  (declare (obsolete make-temp-file "30.1"))
+  (make-temp-file prefix))
+
 (run-hooks 'ediff-load-hook)
 
 ;;; ediff-util.el ends here