Subject: Re: bug#56682: Fix the long lines font locking related slowdowns

From: Stefan Monnier <[email-masked]>
Date: Sun, 31 Jul 2022 03:25:46 -0400

> IIUC, what Stefan suggests is the following, which seems (almost) fine to
> me.  The only problem I see is that jit-lock-function is not the only user
> of fontication-functions.  It has at least two other users: in ELPA
> multi-mode.el sets fontification-functions to multi-fontify, and in MELPA
> poly-lock.el sets fontification-functions to poly-lock-function.

Good point.

> @@ -4412,9 +4412,9 @@ handle_fontified_prop (struct it *it)
>  	  ptrdiff_t begv = it->narrowed_begv ? it->narrowed_begv : BEGV;
>  	  ptrdiff_t zv = it->narrowed_zv;
>  	  ptrdiff_t charpos = IT_CHARPOS (*it);
>  	  if (begv <= charpos && charpos <= zv)
> -	    Fnarrow_to_region (make_fixnum (begv), make_fixnum (zv), Qt);
> +	    specbind (Qfontification_functions_restriction,
> +		      Fcons (make_fixnum (begv), make_fixnum (zv)));
>  	}

Hpw 'bout we do the reverse then: set the narrowing, but let-bind
a variable to indicate that we're inside a line-length-induced
narrowing, together with the previous narrowing bounds, so jit-lock or
its clients can undo the narrowing when needed?

        Stefan