Ahh, good. But pls show the backtrace here. Tramp is involved in
the file-precious-flag machinery.
My Emacs debugging skills are not great, but I believe I found the related code.
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 uses the
buffer's filename to construct the temporary filename:
(make-temp-file
(let ((fname
(expand-file-name
(format "#%s#" buffer-name)