Subject: Re: bug#15155: 24.3; wrap-prefix in adaptive-wrap-prefix-mode with variable-pitch has wrong face

From: Eli Zaretskii <[email-masked]>
Date: Thu, 22 Aug 2013 17:54:23 +0300

> Date: Thu, 22 Aug 2013 09:04:12 +0200
> From: Frank Fischer <[email-masked]>
> Cc: [email-masked]
> 
> Taking your hint, I have tried the following `adaptive-fill-function`
> 
> (setq adaptive-fill-function
>   (lambda ()
>     (and adaptive-fill-prefix
>          (looking-at adaptive-fill-prefix)
>          (match-string 0))))
> 
> This is exactly what `fill-adaptive-match-prefix' does except the latter
> uses `match-string-no-properties`.
> 
> This seems to work fine for the color of the prefix but not for its font
> (when using variable-pitch-mode). So a second try was
> 
> 
> (setq adaptive-fill-function
>   (lambda ()
>     (and adaptive-fill-prefix
>          (looking-at adaptive-fill-prefix)
>          (propertize (match-string-no-properties 0) 'face 'default))))
> 
> Now the wrap-prefix has the correct font but the wrong color (but this
> variant seems to work reasonably well for LaTeX and variable-pitch).
> 
> I think, the wrap-prefix should at least have the default face (which
> may be modified by variable-pitch-mode) in any case. I'm not sure about
> the other properties like color, but may adaptive-wrap-mode should
> (optionally?) use something like the adaptive-fill-function above to
> assign the wrap-prefix the same face as the original prefix (in contrast
> to the one that happened to be active where the line got truncated).
> 
> Though, I have no idea what to about the color vs. font problem (how to
> get both?).

How about using the face returned by face-at-point, instead of
'default'?