GNU bug report logs - #79252
Option 'file-precious-flag' creates unrelatable/untrackable temporary filenames

Previous Next

Package: emacs;

Reported by: "R. Diez" <rdiez-2006 <at> rd10.de>

Date: Sat, 16 Aug 2025 07:38:03 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "R. Diez" <rdiez-2006 <at> rd10.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Option 'file-precious-flag' creates unrelatable/untrackable temporary
 filenames
Date: Fri, 15 Aug 2025 21:14:17 +0200
Hi all:

Some time ago, I enabled option 'file-precious-flag' after getting file corruption when editing remote files over unstable links.

The trouble is, 'file-precious-flag' generates cryptic temporary filenames like "tmp1eghjG". If there is a network problem while saving, such files are left scattered behind, and when you (or some other sysadmin) realise about those orphaned files next month (or even later), such filenames make it hard to know exactly was caused the problem and what file it was related to.

In the past months, I have increasingly suffered this orphaned file problem due to a Tramp issue described here:

Please change the naming template for temporary files
https://lists.gnu.org/archive/html/tramp-devel/2025-08/msg00007.html

After some struggling (I am no Emacs guru), I finally tracked down the related code in my Emacs 29. Function basic-save-buffer-2 in files.el builds the temporary filename like this:

(setq tempname
  (make-temp-file
   (expand-file-name "tmp" dir)))

That is where those tmpXXXX filenames are coming from.

In contrast, function make-auto-save-file-name in the same file (files.el) uses the buffer's filename to construct the temporary filename:

(make-temp-file
 (let ((fname
    (expand-file-name
     (format "#%s#" buffer-name)

Could you modify the first make-temp-file call, so that it is clear what file the temporary file relates to? It would also be best if the word "Emacs" were part or the temporary filename, like Tramp does, so that you know what piece of software caused the littering.

Thanks in advance,
  rdiez





This bug report was last modified 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.