Subject: Re: bug#79252: Option 'file-precious-flag' creates unrelatable/untrackable temporary filenames

From: "R. Diez" <[email-masked]>
Date: Sun, 17 Aug 2025 20:58:38 +0200

> 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.

At first, I thought that Tramp was the one creating the temporary file, so I suggested this change to Tramp:

> For a file like:
>
> myfile.txt
>
> I suggest a temporary filename like:
>
> myfile.txt.EmacsTrampTmp1eghjG

Michael Albinus' reply was:

> That wouldn't be possible. An extension, like ".txt", must be kept.

See the full text here: https://lists.gnu.org/archive/html/tramp-devel/2025-08/msg00008.html

Your patch does change the file extension, but I do not know whether that is actually a problem. The original temporary filename had no extension anyway.

> I don't see an issue. It is just the idea, that the temp file is more
> related to the canonical file instead of the link source.

While checking 'file-precious-flag' because of this issue, I saw related option 'file-preserve-symlinks-on-save'.

The documentation does not recommend enabling it, or leaving it disabled, but since enabling it seems to mirror the symlink behaviour when 'file-precious-flag' is disabled, I decided to enable 'file-preserve-symlinks-on-save' on my system. So far without trouble.

I am mentioning it mainly because I would imagine the Lisp code that queries 'file-preserve-symlinks-on-save' could offer some insight into the necessary symlink handling. However, if anything comes out of that, I would do it in a separate patch.