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

From: João Távora <[email-masked]>
Date: Wed, 02 Nov 2022 14:00:50 +0000

Philip Kaludercic <[email-masked]> writes:

> João Távora <[email-masked]> writes:
>
>> Philip Kaludercic <[email-masked]> writes:
>>
>>>> Not sure.  This started has a report of hidden buffer being incorrectly
>>>> killed by project.el.  
>>>
>>> The issue that was reported was that Eglot/jsonrpc raised an error that
>>> broke `project-kill-buffer'.  This could have also all been solved by
>>> wrapping a `with-demoted-errors' around `kill-buffer'.
>>
>> No.  It couldn't.  The error is there to show you among other things
>> that the LSP connection isn't being shut down correctly, which is not
>> something to paper over.  And even if you did paper over the error, you
>> would break eglot-autoshutdown.  I've explained that at least 3 times
>> already in the beginning of this discussion.
>
> That was not my concern, my concern was that project-kill-buffer
> broke.  I continue to not see a reason why project.el should be
> considered broken because of this, and not jsonrpc/eglot.

It was always broken since the way it was created.  Eglot's precedes it,
I've also explained this.  You can't kill a internal hidden buffer just
because you can see it anymore than you unintern some "--" symbol in
obarray simply because you can see it and don't like its inelegant name,
or you think it's taking too much RAM.  I can't really explain this any
other way.

> This is probably best solved by reading code.  Can you point me to a few
> functions/section/etc. that would help me clarify the situation.
> I haven't made up my mind, I am just trying to understand all
> perspectives, and get a better overview over the issue.

OK, one last time.  First, the above principle of encapsulation has
nothing to do with LSP or Eglot or Jsonrpc.

Specifically in Eglot, as I already explained, eglot.el and jsonrpc.el
colaborate so that jsonrpc.el holds a network process to communicate
with the LSP server.  It uses a buffer for more convenient and efficient
parsing of messages.  That buffer is out of bounds for Eglot (and anyone
else).  Eglot doesn't know or care that a buffer is being used, it only
actuate on the handle using operations of jsonrpc.el's API.  According
to user options, Eglot provides controlled shutdown and reconnection
using these operations.

All of this has worked for a long time and predates project.el's buffer
collection/killing/switching logic.

If you or some Lisp package finds and destroys the hidden implementation
detail, all the above is broken.  Therefore packages like project.el
that do it are buggy in that regard.