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

From: Frank Fischer <[email-masked]>
Date: Fri, 23 Aug 2013 17:17:59 +0200

Am Fri, 23 Aug 2013 17:29:37 +0300
schrieb Eli Zaretskii <[email-masked]>:

> > That patch seems to work, thank you.
> 
> Thanks, committed as trunk revision 113979.

Cool!

> I think your analysis is correct.  Perhaps invoking font-lock to
> fontify the appropriate portion of the text, before taking the prefix
> string, will solve that?
> 
> > Perhaps this is a more an issue of adaptive-wrap-mode, I
> > don't know.
> 
> I think it is indeed an issue with adaptive-wrap-mode.

Yes, it seems to work. I used the attached patch for adaptive-wrap.el
(although I do not know if this is the correct way to do because
I'm not really familiar with font-lock), it just works for me.

Thanks again
Frank

--- adaptive-wrap-old.el	2013-08-23 17:02:00.150840918 +0200
+++ adaptive-wrap.el	2013-08-23 17:06:33.411490626 +0200
@@ -83,12 +83,20 @@
 (defun adaptive-wrap-prefix-function (beg end)
   "Indent the region between BEG and END with adaptive filling."
   (goto-char beg)
-  (while (< (point) end)
-    (let ((lbp (line-beginning-position)))
-      (put-text-property (point)
-                         (progn (search-forward "\n" end 'move) (point))
-                         'wrap-prefix
-                         (adaptive-wrap-fill-context-prefix lbp (point))))))
+  (and font-lock-fontify-region-function
+       (funcall font-lock-fontify-region-function beg end))
+  (let ((adaptive-fill-function
+         (or adaptive-fill-function
+             (and adaptive-fill-regexp
+                  (lambda ()
+                    (and (looking-at adaptive-fill-regexp)
+                         (match-string 0)))))))
+    (while (< (point) end)
+      (let ((lbp (line-beginning-position)))
+        (put-text-property (point)
+                           (progn (search-forward "\n" end 'move) (point))
+                           'wrap-prefix
+                           (adaptive-wrap-fill-context-prefix lbp (point)))))))
 
 ;;;###autoload
 (define-minor-mode adaptive-wrap-prefix-mode