Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode

From: Anders Lindgren <[email-masked]>
Date: Sat, 9 Jan 2016 14:40:24 +0100

Hi!

I just tested this and I can verify that this solved my multiline problem.

Thanks!

    -- Anders

On Sat, Jan 9, 2016 at 1:19 PM, Alan Mackenzie <[email-masked]> wrote:

> Hello, Anders.
>
> Thanks for doing all the donkey work.
>
> On Fri, Jan 08, 2016 at 10:34:09PM +0100, Anders Lindgren wrote:
> > Hi Alan (and the list),
>
> > I made a "git bisect" and found the culprit:
>
> > --------
> > b31d359d182eb252a11f0468a7dc1ee1eafb28e9 is the first bad commit
> > commit b31d359d182eb252a11f0468a7dc1ee1eafb28e9
> > Author: Alan Mackenzie <[email-masked]>
> > Date:   Sun Feb 1 21:20:35 2015 +0000
>
> >     CC Mode: Stop Font Lock forcing fontification from BOL.  Fixes
> > debbugs#19669.
> >     cc-mode.el (c-font-lock-init): Setq font-lock-extend-region-functions
> > to nil.
> > --------
>
> > The reason this breaks multiline keywords is that
> > `font-lock-extend-region-multiline' is normally part of
> > `font-lock-extend-region-functions'.
>
> OK.  The fix is then fairly obvious: to remove the one function from
> `font-lock-extend-region-functions' which was causing the problem,
> leaving the other functions (in particular
> `font-lock-extend-region-multiline') in place.
>
> Could you try out this patch, please.  It seems to work OK for me, here.
>
>
>
> diff -r a73bd5d1bd06 cc-mode.el
> --- a/cc-mode.el        Fri Jan 08 22:25:59 2016 +0000
> +++ b/cc-mode.el        Sat Jan 09 12:00:10 2016 +0000
> @@ -1324,12 +1324,13 @@
>            . c-mark-function)))
>
>    ;; Prevent `font-lock-default-fontify-region' extending the region it
> will
> -  ;; fontify to whole lines by removing
> `font-lock-extend-region-whole-lines'
> -  ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we
> do
> -  ;; not need)) from `font-lock-extend-region-functions'.  (Emacs only).
> This
> -  ;; fixes Emacs bug #19669.
> +  ;; fontify to whole lines by removing
> `font-lock-extend-region-wholelines'
> +  ;; from `font-lock-extend-region-functions'.  (Emacs only).  This fixes
> +  ;; Emacs bug #19669.
>    (when (boundp 'font-lock-extend-region-functions)
> -    (setq font-lock-extend-region-functions nil))
> +    (setq font-lock-extend-region-functions
> +         (delq 'font-lock-extend-region-wholelines
> +               font-lock-extend-region-functions)))
>
>    (make-local-variable 'font-lock-fontify-region-function)
>    (setq font-lock-fontify-region-function 'c-font-lock-fontify-region)
>
>
> >     -- Anders
>
> --
> Alan Mackenzie (Nuremberg, Germany).
>