Subject: Re: bug#27427: 26.0.50; Native line numbers lead to display error in company-mode popup

From: martin rudalics <[email-masked]>
Date: Tue, 27 Jun 2017 09:06:06 +0200

> If we let Emacs escape into the main loop, we cannot control when
 > redisplay kicks in and what effect does it have.  For example, some
 > timer could display a message that could be longer than a single
 > screen line, so Emacs will resize the echo area and as result
 > redisplay the windows above the mode line.  Since the text of the
 > popup comes from a source about which the display engine knows
 > absolutely nothing, redisplay will do its job assuming that the screen
 > shows the contents before we overwrote it, and thus will completely
 > mess up the display.  Even if the code which displayed the popup gets
 > control right away (which isn't guaranteed in general, since
 > company-mode wants to be able to run arbitrary Lisp given user
 > interaction with the popup), the user will see a momentary flash of
 > messed-up display.

I assume that the buffer position of the popup would have been specified
by company-mode before.  Hence, if on a terminal the character at that
position would get displayed, the display engine would try to display
the overlay for the popup there instead.  On the right and below of that
position if it fits, "anywhere there" otherwise, possibly truncating it
to keep the echo area free as you did for menus.  And that overlay would
stick at that buffer position until company-mode removes it.

So resizing the echo area would, in the worst case, not display the
popup because its buffer position would be temporarily off screen.  But
I can't imagine any mess up here.

 > I don't see how the echo area can fit the job, since the space there
 > is very small and there's no way to let the user select an alternative
 > using menu-like interaction.

The echo area can be resized and can emulate any menu-like interaction.

martin