Subject: bug#20240: 25.0.50; CC Mode broken fontification and commenting

From: Stefan Monnier <[email-masked]>
Date: Fri, 03 Apr 2015 18:09:12 -0400

> -          (run-hook-with-args 'jit-lock-after-change-extend-region-functions
> -                              start end old-len)
> -          ;; Make sure we change at least one char (in case of deletions).
> -          (setq jit-lock-end (min (max jit-lock-end (1+ start)) (point-max)))
> -          ;; Request refontification.
> -          (put-text-property jit-lock-start jit-lock-end 'fontified nil))
> +          (save-restriction
> +           (widen)
> +           (run-hook-with-args 'jit-lock-after-change-extend-region-functions
> +                               start end old-len)
> +           ;; Make sure we change at least one char (in case of deletions).
> +           (setq jit-lock-end (min (max jit-lock-end (1+ start)) (point-max)))
> +           ;; Request refontification.
> +           (put-text-property jit-lock-start jit-lock-end 'fontified nil)))

Widening during the call to
jit-lock-after-change-extend-region-functions seems wrong.  But I guess
there can be meaningful cases where
jit-lock-after-change-extend-region-functions could return positions
outside of the narrowed region, so I'd be OK with widening during the
subsequent `put-text-property'.

        Stefan