Subject: Re: bug#62816: 30.0.50; ElDoc blinks echo area when eldoc-documentation-compose is used

From: Dmitry Gutov <[email-masked]>
Date: Fri, 14 Apr 2023 02:37:39 +0300

On 14/04/2023 02:23, João Távora wrote:
> Dmitry Gutov <[email-masked]> writes:
> 
>> I still see the problem with window jumping and blinking when typing
>> with company-mode enabled, though. You say: "I do use company and
>> multi-line echo areas liberally". Do you have some extra configuration
>> for company-frontends?
> 
> Not that I know of.  I just use a TTY frame.  I don't see it.  The echo
> area is frequently empty for me when selecting Eglot completions (in
> clangd, the server I most use nowadays).
> 
>> Here's a screencast that demonstrates the problem:
>> https://a.uguu.se/csTMrzxc.webm
> 
> Ugh, that indeed looks awful.  We must fix it.
> 
>> One way to fix that is
>>    (push 'company-echo-metadata-frontend company-frontends)

Sorry, that was supposed to be (delete ...). The one above restores the 
configuration -- I needed it for a repeat comparison.

>> but I wonder whether some better solution exists.
> 
> I hope so.
> 
>> OTOH, Eglot implements the attribute which this frontend plugs into
>> via :company-docsig, and it seems like both with LSP servers that I
>> just tried it returns nil. If the feature is generally unused, I could
>> understand if Eglot users all disable this frontend anyway.
> 
> I don't think that's the best solution.  Though you're right that only
> one server, pyright, uses this (it's some user's hack in eglot.el I let
> through: I don't even know what it does, i think it tells)

Maybe other servers have different bits of info that could be used for this?

> But, perhaps to ask the obvious, why can't Company just detect when nil
> is passed to it via :company-docsig and not do any echoing in that
> situation?  Isn't it Company doing the clearing we want to avoid?

I think it does need to clear the echo area when it was previously 
echoed to by the same backend (showing meta from a different 
completion). E.g. after the user just presses C-n with completion popup 
already visible. So the idea to "just not do any echoes" would require 
some bookkeeping about where the current message came from, compare the 
current message contents, and possibly still fail sometimes where the 
exact same message came from a different source. The last one is 
unlikely, though.

> Another option is just to temporarily disable eldoc during the duration
> of the Company completion session.

Right.

And yet another solution would be to detect that Eldoc will be used, and 
try to plug into its documentation functions to display the meta thingy 
alongside the other info.

That's at least 3 potential solutions now.

> I think Company could/should do both of these things, but I haven't
> studied the problem so I might be missing something.

I've looked into that issue in the past, but haven't picked one yet.

Related:
https://github.com/company-mode/company-mode/issues/797
https://github.com/company-mode/company-mode/issues/588
https://github.com/company-mode/company-mode/issues/796