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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 17 Aug 2025 11:07:06 +0300

> From: Michael Albinus <[email-masked]>
> Cc: "R. Diez" <[email-masked]>,  [email-masked]
> Date: Sun, 17 Aug 2025 09:56:02 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> Hi Eli,
> 
> > Michael, could you please review the patch and tell if you see any
> > issues with it?
> >
> > diff --git a/lisp/files.el b/lisp/files.el
> > index 84e9254..3e85244 100644
> > --- a/lisp/files.el
> > +++ b/lisp/files.el
> > @@ -6245,7 +6245,13 @@ basic-save-buffer-2
> >  		  ;; for saving the buffer.
> >  		  (setq tempname
> >  			(make-temp-file
> > -			 (expand-file-name "tmp" dir)))
> > +                         ;; The MSDOS 8+3 restricted namespace cannot be
> > +                         ;; relied upon to produce a different file name
> > +                         ;; if we append ".tmp".
> > +	                 (if (and (eq system-type 'ms-dos)
> > +		                  (not (msdos-long-file-names)))
> > +                             (expand-file-name "tmp" dir)
> > +                           (concat buffer-file-name ".tmp"))))
> >  		  ;; Pass in nil&nil rather than point-min&max
> >  		  ;; cause we're saving the whole buffer.
> >  		  ;; write-region-annotate-functions may use it.
> 
> On a first glance, it looks OK. I don't know whether we need special care
> for symlinks, i.e., use buffer-file-truename instead of buffer-file-name.

Thanks for the review.

What could be the issues with symlinks?  The directory of
buffer-file-name is writable, so using the name of the symlink should
be okay, since we create a normal file.  Or what am I missing?