Subject: Re: bug#54401: 28.0.91; Buffer visited file replaced with lockfile location

From: Kenny Ballou <[email-masked]>
Date: Thu, 17 Mar 2022 09:15:33 -0600

On 2022-03-17, 12:20 +0100, Lars Ingebrigtsen wrote:

> Kenny Ballou <[email-masked]> writes:
>> ```
>> (setq auto-save-visited-file-name t)
>> (setq auto-save-default t)
>> (setq auto-save-timeout 20)
>> (setq auto-save-interval 20)
>
> You only need the first, apparently.

I included the other values to ensure the bug is triggered.  But yes,
`auto-save-visited-file-name` seems to be "real, honest" trigger of the behavior.

> And there's more bugginess going on than described.
>
> /tmp/foo1 no longer exists!  But /tmp/foo2 does.

For some reason, I thought this was expected behavior.  But now that I've
switched off `auto-save-visited-file-name`, I have seen `write-file` act more
like a "copy" operation, not a "rename" operation.  Certainly, more is wrong
here.

>
> <type something>
> `M-x do-auto-save RET'
>
> /tmp/#foo2# now exists!  And `buffer-file-name' in the "foo2" buffer is
> now "/tmp/#foo2#'

Frustratingly, the content of `/tmp/#foo2#` contains the result of "<type
something>", and `/tmp/foo2` is at the content before "<type something>".  I've
lost a fair amount of work to this before I figured out what was happening (and
a work around) before reporting.
>
> So this is kinda totally broken.  Now, `auto-save-visited-file-name' was
> made obsolete in Emacs 26.1, but perhaps these things should be fixed
> anyway.

This "rename" behavior does not happen when using the minor mode.  Therefore,
the "fix" should probably be adding warnings against using the variable
directly or accelerating its deprecation (not sure how that would work since
the variable is probably used internally by the minor mode, no?).

I'm new here, I'm not sure how this proceeds.