[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Major modes using `widen' is a good, even essential, programming pra

From: Stefan Monnier
Subject: Re: Major modes using `widen' is a good, even essential, programming practice.
Date: Sun, 07 Aug 2022 19:21:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> Where, exactly are the terms of this supposed contract formulated?

I'm not sure it's written anywhere.
More specifically, for `jit-lock-functions`, the contract is not
very constraining.

For font-lock the contract is not still very explicit but is more
constraining in that we expect major modes not to look before point-min
or after point-max.  For that reason font-lock normally widens the
buffer before it does anything else (unless `font-lock-dont-widen` is

> And which part of this supposed contract has CC Mode broken?

It calls `widen` within its font-lock code.

Eli Zaretskii [2022-08-07 17:20:52] wrote:
> jit-lock calls the functions with two arguments, BEG and END, and
> expects them to work only on that chunk of text.

That is not the case: it expects the function to "fontify" *at least*
from BEG to END, but is quite happy to let it fontify more (and the
function can return a value indicating which portion was actually
returned in that case).  Furthermore, it's clear that fontification of
BEG..END may need to look at text before BEG (and occasionally beyond
END as well).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]