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 01:58:19 +0300

On 13/04/2023 17:47, João Távora wrote:
> Hello,
> 
> Originally reported by Dmitry Gutov <[email-masked]> over
> at bug#62029:
> 
>> It's trivially reproduced even with 'emacs -Q': just add somewhere
>> inside an Elisp buffer:
> 
>>    (remove-hook asd)
> 
>> when flymake-mode is enabled and eldoc-documentation-strategy is
>> 'eldoc-documentation-compose, and eldoc-echo-area-use-multiline-p is
>> not 1, and move around 'asd' with C-f and C-b.
> 
> I've confirmed this in a graphical Emacs frame.  In a TTY frame, it's
> harder or impossible to spot.
> 
> Traced the problem down to a misimplementation of the
> 'eldoc-documentation-compose' strategy, which leads to potentially one
> eldoc-message call to be issued for each member of
> 'eldoc-documentation-functions'.  In fact, with this particular
> strategy, the intention at most one such call should occur (after all
> the documentation items of different backends have been collected).
> 
> It's reasonably easy to fix, and I've been running the patch after my
> sig all day with no problems either in Elisp or other modes.  The
> "blinking" observed before is gone.
> 
> I'll push it to master soon, but leave this issue open for comments
> and/or feedback a little longer.

Thank you, it does seems to fix the issue with C-f/C-b in elisp-mode, in 
the described situation.

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?

Here's a screencast that demonstrates the problem:

https://a.uguu.se/csTMrzxc.webm

One way to fix that is

   (delq 'company-echo-metadata-frontend company-frontends)

but I wonder whether some better solution exists.

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.

It is handy to have in emacs-lisp-mode, though. At least when there is 
no documentation popup floating nearby.