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

From: Juri Linkov <[email-masked]>
Date: Tue, 09 Apr 2024 19:40:03 +0300

>> The problem is that 'image-next-file' calls 'find-alternate-file'
>> that does such buffer renaming:
>>
>>      (if (get-buffer " **lose**")
>> 	(kill-buffer " **lose**"))
>>      (rename-buffer " **lose**")
>>
>> and 'rename-buffer' changes the buffer's last name to **lose**.
>
> Isn't the problem that it leaves the last name nil?  Does the attached
> diff fix it?
>
> diff --git a/src/buffer.c b/src/buffer.c
> index 291c7d3f911..5e2386c94fa 100644
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -1686,7 +1686,11 @@ DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
>  	 with the original name.  It makes UNIQUE equivalent to
>  	 (rename-buffer (generate-new-buffer-name NEWNAME)).  */
>        if (NILP (unique) && XBUFFER (tem) == current_buffer)
> -	return BVAR (current_buffer, name);
> +	{
> +	  bset_last_name (current_buffer, oldname);
> +
> +	  return BVAR (current_buffer, name);
> +	}
>        if (!NILP (unique))
>  	newname = Fgenerate_new_buffer_name (newname, oldname);
>        else

Alas, this doesn't help.  Because 'find-alternate-file' renames
the buffer with (rename-buffer " **lose**") before killing it.
So 'kill-buffer' remembers the last buffer name " **lose**".