Subject: bug#46177: 27.1; Display problem with minibuffer overlay when using display property

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Jan 2021 10:26:47 +0200

> Cc: [email-masked]
> From: Clemens <[email-masked]>
> Date: Fri, 29 Jan 2021 21:26:26 +0100
> 
> > That's a feature: Emacs treats display strings and overlay strings
> > differently for the purposes of face merging.
> 
> Okay, thanks. I have a problem with this when displaying completion 
> candidates in the minibuffer. The candidates are displayed via 
> `after-string` overlay. The candidates are provided by the caller and 
> can contain the `display` property. Right now I "inline" any parts of 
> the string that use `display` to avoid this:
> 
> 
> (defun selectrum--display-string (str)
>    "Return display string of STR."
>    (let ((len (length str))
>          (display "")
>          (start 0)
>          (end 0))
>      (while (not (eq len end))
>        (setq end (next-single-property-change start 'display str len))
>        (let ((val  (get-text-property start 'display str)))
>          (if (and val (stringp val))
>              (setq display (concat display val))
>            (setq display (concat display (substring str start end)))))
>        (setq start end))
>      display))
> 
> 
> Is there a better way?

Better in what sense?

If you mean a way that prevents the background of the prompt from
being applied to the text you display via the overlay, I think the
best/only way is for the overlay string or display string to specify
the background color.