Subject: Re: bug#76969: kill-buffer fails silently when a thread exists where it's current

From: Spencer Baugh <[email-masked]>
Date: Thu, 13 Mar 2025 16:16:46 -0400

Dmitry Gutov <[email-masked]> writes:
> On 13/03/2025 16:58, Eli Zaretskii wrote:
>>> And/or if the killing does not happen, showing a warning or an error
>>> would be an improvement.
>> We could signal an error, yes.  But it sounds too drastic to me.
>
> Or a warning, or an entry in *Messages*, at least. Anything's better
> than silent noop. And you can't examine the thread's current buffer in
> Lisp, to find the conflicting thread another way from Lisp (e.g. for
> print-debugging).

Note that if you try kill a buffer which is the process-buffer of some
process:

- process-kill-buffer-query-function will query the user whether they
  want to proceed.

- If the user decides to proceed, then the process in that buffer will
  simply be killed with SIGHUP.

Perhaps we should do a similar thing for threads?

- Add a new kill-buffer-query-functions which checks if the buffer being
  killed is the current-buffer of any threads, and if so, queries the
  user if they want to proceed.

- If the user decides to proceed, then do something like killing the
  thread with SIGHUP.  Probably call thread-signal on the thread.  We'll
  still need to switch the thread's current-buffer to a new buffer,
  since the thread could choose to handle the signal and continue
  executing.