Subject: bug#77480: 31.0.50; Flymake: impossible to show multiline diagnostics in echo area

From: João Távora <[email-masked]>
Date: Thu, 03 Apr 2025 09:29:02 +0100

Nicolás Ojeda Bär <[email-masked]> writes:

> Dear Flymake maintainers (Cc: João Távora),
>
> While using Eglot and its default Flymake integration, it seems
> impossible to make Flymake display multi-line diagnostics in the echo
> area: diagnostic messages are systematically truncated and only their
> first line is shown.

Certainly not impossible.  First, Flymake has two ways of showing
diagnostic in the echo area:

1 flymake-mode insinuates itself onto ElDoc
   eldoc-documentation-functions, which you have correctly identified,
   so you get at-point echo area updates as you navigate code.

2. interactive, on-demand Flymake commands such as
   flymake-goto-next-error 

In approach number 1, Flymake is usually sharing a hotly contested
ElDoc-managed resource with many other outlets (since you use Eglot you
know what I'm talking about).  I chose the "one line per backend"
default rule from years of dealing with many user reports about this
topic, as a means of keeping the maximum amount of users content.

In approach number 2, as far as I can see, you do suffer this
limitation, and the line is truncated.  But this behaviour has been
around since the inception of modern flymake as I rewrote it circa 2017.

Changing approach number 2 to honour the
`eldoc-echo-area-use-multiline-p` is very problematic for two reasons
(a): it's odd to use a variable not really connected to the mechanism it
uses to access that space, since it calls `message`directly. (b) it
would break a lot of workflows everywhere.  Perhaps I don't have to tell
you that C++ diagnostics can usually span many hundred lines.

So let's get to approach number 1, which is what I suppose you're using
anyway.  I call attention to the facts:

* that C-h . always popups the *eldoc* buffer in a separate window,
  where you can usually see all diagnostics in full in a separate
  window.  There are even extensions that keep this window around in
  some "child-frame" (search for "eldoc-box")

* that you can customize approach number 1.  See examples in the most
  up-to-date Eglot manual (linked in the Eglot home page).
  
  https://joaotavora.github.io/eglot/#More-Customization-1

  Basically, pay attention to the docstrings of eldoc-display-functions
  and eldoc-documentation-functions, then craft your own function to
  work just the way you want it.

  There are a good number of issues in the Eglot tracker showing how to
  do this and how everyone has a slightly different view on the topic.

So there is, in my view, no need for changes to ElDoc or Flymake in this
regard.

> Looking at the Git history, this behaviour seems to have changed or
> introduced recently, in commit 560950468588117b264a9f916fb578e0eb2a124a.

By the way, this was 2 years ago, hardly "recently".

João