--- 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