Subject: bug#59001: Eglot activated in Xref internal buffers

From: Juri Linkov <[email-masked]>
Date: Fri, 04 Nov 2022 09:29:49 +0200

>> This issue is very hard to reproduce.  It occurs only when
>> *xref-temp* first sets one mode not eglot-managed, then
>> afterwards enables another mode that is eglot-managed
>> in the same internal buffer.  Maybe Dmitry could explain
>> what is going wrong.
>
> Sounds like Eglot, by means of some hooks, sets up some information about
> the buffer. And then it somehow doesn't get cleaned up when the major mode
> changes. Permanent locals? That's a question for Joao.
>
> It is a temporary buffer, and we enable different major modes in it
> (through set-auto-mode), to be able to regexp-search in the inserted
> contents using syntax-sensitive specials (most often - \_< and \_>).
>
> The reason we don't use delay-mode-hooks is in the linked bug report in the
> comments. Hopefully we will later, maybe after Emacs 29.

Thanks for reminding that it's the same as bug#39190
and https://github.com/joaotavora/eglot/pull/233

Though I still don't completely understand full details of bug#23272
why xref--collect-matches couldn't use delay-mode-hooks.