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

From: Stefan Monnier <[email-masked]>
Date: Fri, 23 Aug 2013 11:38:05 -0400

> (setq adaptive-fill-function
>   (lambda ()
>     (and adaptive-fill-regexp
>          (looking-at adaptive-fill-regexp)
>          (match-string 0))))

W.r.t the above change, I installed the patch below which should make
it unnecessary:

--- lisp/textmodes/fill.el	2013-01-02 16:13:04 +0000
+++ lisp/textmodes/fill.el	2013-08-23 15:25:50 +0000
@@ -220,7 +220,7 @@
   (let ((str (or
               (and adaptive-fill-function (funcall adaptive-fill-function))
               (and adaptive-fill-regexp (looking-at adaptive-fill-regexp)
-                   (match-string-no-properties 0)))))
+                   (match-string 0)))))
     (if (>= (+ (current-left-margin) (length str)) (current-fill-column))
         ;; Death to insanely long prefixes.
         nil

> hoping that (match-string 0) returns the whole prefix with the correct
> fontification. However, there are situations where this does not work:
> for example if one has a (very long) wrapped line without comment and
> then inserts a semicolon (only one) at the beginning of that line to
> comment it out, then the wrap-prefix does not get comment face (to be
> precise, it has the correct font, thus your patch works, but not the
> correct color). But if one inserts a second semicolon then the
> wrap-prefix gets the correct color. I assume this happens because the
> wrap-prefix is set before font-lock changed the face of inserted
> semicolon.

Indeed.  It probably depends on whether adaptive-mode-mode was enabled
before or after font-lock.  Can you try the patch below to see if it
fixes this problem for you?

        Stefan