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

From: Frank Fischer <[email-masked]>
Date: Thu, 22 Aug 2013 09:04:12 +0200

Am 08/22/2013 03:33 AM, schrieb Stefan Monnier:

> I have the vague impression of having already seen such a bug-report,
> except the other way around (where the user complained that the
> wrap-prefix was displayed in the font that happened to be active where
> the line got truncated), so we "fixed" it for Emacs-24.

Ah, I see (just add some additional !!! before the first line in
*scratch* and see that the exclamation marks in the wrapped lines have
comment face (but they should be black) in Emacs 23).

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?).

Many thanks for your comments, they already helped me a lot :)

Frank