Subject: bug#75306: 31.0.50; Make `small-temporary-file-directory` variable obsolete

From: Stefan Kangas <[email-masked]>
Date: Thu, 2 Jan 2025 21:23:12 -0600

Severity: wishlist

The variable `small-temporary-file-directory` was created in 2000 for
MS-DOS systems and systems with widely different specs than what we run
now.  Putting temporary files on a RAM disk should be done by the system
administrator (usually the user themselves), for example by simply using
tmpfs for _all_ temporary files (not just "small" ones, whatever that
means).

I think the variable doesn't make much sense these days, and should be
made obsolete.  Note that it is barely used in Emacs and third-party
packages.

However, Tramp recently started using the variable as a place to create
OpenSSH Unix domain sockets.  May I suggest that Tramp uses some other
variable for this purpose, perhaps a Tramp specific one?

I've attached a diff that makes the variable obsolete and removes all
uses, for reference.
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 620d16ddf11..b8314bbac37 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -599,11 +599,9 @@ Backup
 
 @vindex backup-enable-predicate
 @vindex temporary-file-directory
-@vindex small-temporary-file-directory
   The default value of the @code{backup-enable-predicate} variable
 prevents backup files being written for files in the directories used
-for temporary files, specified by @code{temporary-file-directory} or
-@code{small-temporary-file-directory}.
+for temporary files, specified by @code{temporary-file-directory}.
 
   You can explicitly tell Emacs to make another backup file from a
 buffer, even though that buffer has been saved before.  If you save
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 1064f347a12..645827de85e 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2803,21 +2803,6 @@ Unique File Names
 non-@code{nil}.
 @end defopt
 
-@defopt small-temporary-file-directory
-This variable specifies the directory name for
-creating certain temporary files, which are likely to be small.
-
-If you want to write a temporary file which is likely to be small, you
-should compute the directory like this:
-
-@example
-(make-temp-file
-  (expand-file-name @var{prefix}
-                    (or small-temporary-file-directory
-                        temporary-file-directory)))
-@end example
-@end defopt
-
 @defun make-temp-name base-name
 This function generates a string that might be a unique file
 name.  The name starts with @var{base-name}, and has several random
diff --git a/lisp/files.el b/lisp/files.el
index 72128ea4af2..98e66aac1ea 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -229,6 +229,8 @@ small-temporary-file-directory
   :group 'files
   :initialize #'custom-initialize-delay
   :type '(choice (const nil) directory))
+(make-obsolete-variable 'small-temporary-file-directory
+                        'temporary-file-directory "31.1")
 
 ;; The system null device. (Should reference NULL_DEVICE from C.)
 (defvar null-device (purecopy "/dev/null") "The system null device.")
@@ -5592,8 +5594,7 @@ backup-directory-alist
 
 (defun normal-backup-enable-predicate (name)
   "Default `backup-enable-predicate' function.
-Checks for files in `temporary-file-directory',
-`small-temporary-file-directory', and \"/tmp\"."
+Checks for files in `temporary-file-directory' and \"/tmp\"."
   (let ((temporary-file-directory temporary-file-directory)
 	caseless)
     ;; On MS-Windows, file-truename will convert short 8+3 aliases to
@@ -5611,14 +5612,7 @@ normal-backup-enable-predicate
 					  name 0 nil)))
 	       ;; Directory is under /tmp.
 	       (and (not (eq comp t))
-		    (< comp (- (length "/tmp")))))
-	     (if small-temporary-file-directory
-		 (let ((comp (compare-strings small-temporary-file-directory
-					      0 nil
-					      name 0 nil caseless)))
-		   ;; Directory is under small-temporary-file-directory.
-		   (and (not (eq comp t))
-			(< comp (- (length small-temporary-file-directory))))))))))
+		    (< comp (- (length "/tmp")))))))))
 
 (defun make-backup-file-name (file)
   "Create the non-numeric backup file name for FILE.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 823ff81cb56..8252169783c 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4940,8 +4940,7 @@ tramp-ssh-controlmaster-options
 	     (expand-file-name
 	      (if (tramp-ssh-option-exists-p vec "ControlPath=tramp.%C")
 		  "tramp.%%C" "tramp.%%r@%%h:%%p")
-	      (or small-temporary-file-directory
-		  tramp-compat-temporary-file-directory))))
+	      tramp-compat-temporary-file-directory)))
 
          ;; ControlPersist option is introduced in OpenSSH 5.6.
 	 (when (and (not (eq tramp-use-connection-share 'suppress))
diff --git a/lisp/progmodes/cmacexp.el b/lisp/progmodes/cmacexp.el
index 35ebf506dfb..eaee29b8649 100644
--- a/lisp/progmodes/cmacexp.el
+++ b/lisp/progmodes/cmacexp.el
@@ -275,8 +275,7 @@ c-macro-expansion
 	(exit-status 0)
 	(tempname (make-temp-file
 		   (expand-file-name "cmacexp"
-				     (or small-temporary-file-directory
-					 temporary-file-directory)))))
+				     temporary-file-directory))))
     (unwind-protect
 	(save-excursion
 	  (save-restriction
diff --git a/lisp/simple.el b/lisp/simple.el
index b0490bb36d4..741229c9d60 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4646,8 +4646,7 @@ shell-command
                  (and error-buffer
                       (make-temp-file
                        (expand-file-name "scor"
-                                         (or small-temporary-file-directory
-                                             temporary-file-directory))))))
+                                         temporary-file-directory)))))
 	    (barf-if-buffer-read-only)
 	    (push-mark nil t)
             (shell-command-save-pos-or-erase 'output-to-current-buffer)
@@ -4968,8 +4967,7 @@ shell-command-on-region
 	 (if error-buffer
 	     (make-temp-file
 	      (expand-file-name "scor"
-				(or small-temporary-file-directory
-				    temporary-file-directory)))
+				temporary-file-directory))
 	   nil))
 	exit-status)
     ;; Unless a single contiguous chunk is selected, operate on multiple chunks.
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 07c7f37cbe5..cdeced20db9 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -886,8 +886,7 @@ vc-rcs-update-changelog
 	;; Presumably not portable to non-Unixy systems, along with rcs2log:
 	(tempfile (make-temp-file
 		   (expand-file-name "vc"
-				     (or small-temporary-file-directory
-					 temporary-file-directory))))
+				     temporary-file-directory)))
         (login-name (or user-login-name
                         (format "uid%d" (number-to-string (user-uid)))))
 	(full-name (or add-log-full-name