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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#79252: closed (Option 'file-precious-flag' creates
 unrelatable/untrackable temporary filenames)
Date: Sat, 23 Aug 2025 12:12:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 23 Aug 2025 15:11:22 +0300
with message-id <86bjo6b5lh.fsf <at> gnu.org>
and subject line Re: bug#79252: Option 'file-precious-flag' creates unrelatable/untrackable temporary filenames
has caused the debbugs.gnu.org bug report #79252,
regarding Option 'file-precious-flag' creates unrelatable/untrackable temporary filenames
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
79252: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79252
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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



[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: "R. Diez" <rdiez-2006 <at> rd10.de>
Cc: 79252-done <at> debbugs.gnu.org, michael.albinus <at> gmx.de
Subject: Re: bug#79252: Option 'file-precious-flag' creates
 unrelatable/untrackable temporary filenames
Date: Sat, 23 Aug 2025 15:11:22 +0300
> X-Spam-Status: No, score=-2.898 required=6.31 tests=[ALL_TRUSTED=-1,
> 	BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001,
> 	URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001]
> 	autolearn=ham autolearn_force=no
> Date: Sun, 17 Aug 2025 20:58:38 +0200
> Cc: 79252 <at> debbugs.gnu.org
> From: "R. Diez" <rdiez-2006 <at> rd10.de>
> 
> 
> > I think the patch below should do what you are asking for.
> 
> I don't really know much Emacs or Lisp, but the patch looks fine to me too.

Thanks, so now installed on the master branch, and closing the bug.


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.