Subject: Re: bug#68235: 29.1.90; Switching tabs stops following process output in selected window

From: Juri Linkov <[email-masked]>
Date: Mon, 22 Apr 2024 09:46:00 +0300

>> I noticed that now 'find-alternate-file' has such a problem
>> that it updates the modification timestamp of the directory.
>>
>> This is because 'find-alternate-file' calls 'rename-buffer'
>> before setting back the value of 'buffer-file-name'.
>> So this code in 'rename-buffer' is fired and changes
>> the directory modification timestamp:
>>
>>    if (NILP (BVAR (current_buffer, filename))
>>        && !NILP (BVAR (current_buffer, auto_save_file_name)))
>>      call0 (intern ("rename-auto-save-file"));
>
> Why does an auto-save file exist at all in this situation?  If the
> original buffer was modified, 'find-alternate-file' should have saved it
> into its file and deleted the auto-save file.  Does your code rely on
> fine tuned directory timestamps?

Nothing special is done.  The problem is reproducible in 'emacs -Q'
with the original test case.

This is because image-mode modifies the timestamp unless a special handling
is used such as in 'image-toggle-display-image':

    (let ((create-lockfiles nil)) ; avoid changing dir mtime by lock_file
      (add-text-properties (point-min) (point-max) props)
      (restore-buffer-modified-p modified))

But 'rename-buffer' can't do the same.

>> A possible fix would be to swap the order of
>> setting of 'buffer-file-name' and 'rename-buffer':
>
> I see no problems doing that so please install.

Thanks, so now installed.