Subject: bug#58839: [Patch] Re: bug#58839: 29.0.50; project-kill-buffer fails when Eglot is running

From: Dmitry Gutov <[email-masked]>
Date: Fri, 28 Oct 2022 21:40:58 +0300

On 28.10.2022 21:20, Philip Kaludercic wrote:
> Dmitry Gutov<[email-masked]>  writes:
> 
>> On 28.10.2022 20:28, Philip Kaludercic wrote:
>>> I still don't agree that this is the right interpretation of the issue
>>> or solution, but wouldn't it be better to add this to
>>> `project-kill-buffer-conditions'?
>> I don't mind a new variable specifically, but
>> kill-buffer-query-functions seems to serve this purpose just fine.
>>
>> And no extra "coupling between two packages" will be added.
> How would you imagine it being used in this case?

(defun eglot-before-kill-special ()
   (eglot-shutdown)
   t)

;; somewhere inside that special buffer's setup:
(add-hook 'kill-buffer-query-functions #'eglot-before-kill-special nil t)

Or use kill-buffer-hook, no need to watch the return value then.

In either case, it will also cover the scenario of the user killing the 
background buffer some other way.