Subject: Re: bug#42552: 28.0.50; Overlay 'face' property doesn't set the "underlying face" for 'after-string'

From: Eli Zaretskii <[email-masked]>
Date: Thu, 30 Jul 2020 17:04:12 +0300

> Cc: [email-masked]
> From: Dmitry Gutov <[email-masked]>
> Date: Sun, 26 Jul 2020 23:00:57 +0300
> 
> On 26.07.2020 22:02, Eli Zaretskii wrote:
> > I'd like a recipe for reproducing the problem and the description of
> > what exactly constitutes the problem, if possible.
> 
> The recipe is similar to 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38563#11.
> 
> The only difference is one needs to initiate completion 10 lines above 
> the lines which `whitespace-mode` highlights with red.

Thanks.

> 1. Apply the patch to company.el.
> 2. Launch 'emacs -Q -L path/to/company -l company'.
> 3. Turn on company-mode and whitespace-mode.
> 4. In the scratch:
> C-u 11 M-x newline
> space space space
> C-u 11 M-x previous-line
> Type 'c', then M-x company-complete-common

I installed a fix on master.  The fix is simple enough, but it is in
code that is used in all cases where faces are used in overlay
strings, and so I don't want to install this on emacs-27, since the
Emacs 27.1 release is imminent, and I don't want to delay it any
longer.  We could discuss later whether to backport to Emacs 27.2.

> The solution I hoped would fix this, which we discussed in 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38563#60, does not work 
> when the popup is rendered with 'after-string' instead of 'display' 
> overlay property (and a similar problem exists for 'before-string' as 
> well). Hence the title of this bug report.

Setting the 'face' property of an overlay with the intent of affecting
the display of an overlay string never worked in Emacs, and the
comments to the code even mention it (note the last sentence):

  /* Return the face ID at buffer position POS for displaying ASCII
     characters associated with overlay strings for overlay OVERLAY.

     Like face_at_buffer_position except for OVERLAY.  Currently it
     simply disregards the `face' properties of all overlays.  */

  int
  face_for_overlay_string (struct window *w, ptrdiff_t pos,