Subject: bug#78530: 31.0.50; [PATCH] eglot-code-action-suggestion doesn't call the callback function in the original buffer

From: Yuan Fu <[email-masked]>
Date: Mon, 9 Jun 2025 18:30:15 -0700

> On Jun 8, 2025, at 4:19 PM, João Távora <[email-masked]> wrote:
> 
> On Sat, Jun 7, 2025 at 9:08 AM Eli Zaretskii <[email-masked]> wrote:
>> 
>> Ping!  João, any comments or suggestions?
> 
> I think the patch is definitely in the right direction, but it would make
> even more sense if it checked if the "original buffer" is still live by
> the time the lambda is called.  If it's not, probably the callback
> lambda shouldn't get called.  This is why Eglot uses its own macro
> eglot--when-buffer-live.

Ohh yeah, good call.

> 
> And this new "rule" should be encoded in the documentation (docstring
> and/or manual).  No need for lots of text, just a note.

Will do.

> 
> And we should think a little bit if we're breaking backward
> compatibility.  Though I don't think we are: not many ElDoc clients are
> relying on the fact that the buffer the callbacks are run in is somewhat
> arbitrary.

Plus usually the callback _is_ ran in the original buffer, unless the provider of the documentation function does something weird. (In our case, eglot runs the callback in a temp buffer.)

> Finally the patch could come with some changes to Eglot as well, because
> this allows for eglot.el to be simplified.  But be careful: the way to
> do this is to do the eldoc.el change bumping its :core package version,
> and then make the eglot.el change bumping its Package-requires: eldoc
> version.  That way we guarantee that older Emacsen pulling in new eglot.el
> also pull in the new suitable eldoc.el.

Cool. Let me check if we really don’t need the eglot--when-buffer-window wrapper in the documentation functions. Or you’re certain that we don’t?

Yuan