Subject: Re: bug#40529: 26.3; global-display-line-numbers-mode and flymake-show-diagnostics-buffer error

From: João Távora <[email-masked]>
Date: Sun, 12 Apr 2020 17:58:16 +0100

On Sun, Apr 12, 2020 at 3:42 PM Eli Zaretskii <[email-masked]> wrote:

> AFAIR, the :align-to display spec needs to be recalculated when line
> numbers are turned on or off.

I don't know what that is, but if it involves propertizing
the rows themselves, there's possiblya bug when you gain
or lose a character when scrolling. As evidenced by the fact
that the hooks I showed you also only recalculate the header.

> The code was introduced to solve real problems in some users of
> tabulated-list-mode (and we have quite a few of them in core alone).

Do you have reason to believe these would resurface if you
did my change? What are these "real problems"?  Can
references to them be found in the git log?

> Maybe so, but that code endured many months on the master branch and
> then in the pretest, so we have some reason to believe it is correct.

I don't think it's correct to ask the buffer's row-providing
backend to produce rows just you turned on the mode.
Certainly I can't think how it can be correct to do that depending
on whether or not a totally unrelated customization related to
presentation is enabled or not.

If you disagree, I would at least indicate this possibility in
the manual before releasing.

The manual says, in
https://www.gnu.org/software/emacs/manual/html_node/elisp/Tabulated-List-Mode.html

   The listing command should create or switch to a
   buffer, turn on the derived mode, specify the tabulated data,
   and finally call tabulated-list-print to populate the buffer.

Maybe you should add something explaining that sometimes
populating happens automatically, sometimes not.  If gathering
the data is expensive, the client code can be doing it twice,
a bad thing IMO.

But even conceptually and intuitively, changing the line numbers
to the left of a buffer shouldn't need recalculating the buffer's
contents. Even the effect on the header line smells a little, to
be honest. Shouldn't line numbers care to handle also push
the header line forward as they do the remainder of the buffer?
I don't know and I don't use line numbers, just wondering.

> I'm sure a simple solution for Flymake can be found.  E.g., what about
> skipping the entire body of flymake--diagnostics-buffer-entries if
> flymake--diagnostics-buffer-source is nil

Maybe that works, yes. Feel free to try it and commit it
to Emacs 27, I have little time and I'm booted into a machine
with no Emacs.

Thanks,
João