emacs-devel
[Top][All Lists]
Advanced

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

Re: cc-mode fontification feels random


From: Alan Mackenzie
Subject: Re: cc-mode fontification feels random
Date: Sun, 6 Jun 2021 14:19:00 +0000

Hello, Eli.

On Sun, Jun 06, 2021 at 15:44:38 +0300, Eli Zaretskii wrote:
> > Date: Sun, 6 Jun 2021 12:27:05 +0000
> > Cc: dancol@dancol.org, emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>

> > > AFAIR, the way to tell JIT font-lock that a chunk of text was already
> > > fontified is to set the 'fontified' property on that text.

> > Sorry, I was unclear.  I was thinking of a signal from jit-lock to the
> > major mode, indicating that background fontification had been completed.
> > CC Mode could react to this by fontifying all occurrences in the buffer
> > of "newly found" types.  Or something like that.

> Sorry, I don't understand (probably because I missed the beginning of
> this discussion): what do you mean by "background fontification", and
> what does it mean for that to have been "completed"?  I'm afraid we
> are not on the same page wrt JIT font-lock related terminology.

CC Mode maintains a simple table of a buffer's types, which it uses to
fontify the same types when they occur again in the buffer.  Daniel's
main problem was that with JIT fontification, the occurrences of foo get
"fontified" to default face before foo has been entered into the table.
This happens because jit-lock doesn't scan the buffer from (point-min).

By "background fontification" I meant stealth fontification (and should
have said so).  This is, sadly, disabled by default.  If it were to be
enabled again, I was envisaging some sort of signal from jit-lock stealth
fontification when the stealth had determined a buffer was completely
fontified.  Reacting to this signal, CC Mode could then fontify all the
types which the stealth had caused to be added to the CC Mode table.

I no longer think this is a good idea.

> > Or maybe the fontification could be done immediately after parsing a new
> > type.

> Parsing by whom? by CC Mode?

Yes.  By CC Mode's fontification detecting a symbol, foo, must be a type,
and entering it into its internal table.  I am thinking that immediately
following, CC Mode could scan the entire buffer and refontify occurrences
of foo which hadn't yet got font-lock-type-face.

> If so, CC Mode parsing is itself part of fontification, AFAIU, and is
> invoked by the JIT font-lock machinery.  So I'm confused wrt what you
> are looking for.

I was looking for jit stealth locking to detect when it had completely
fontified a buffer (i.e. the `fontified' property was on the entire
buffer) and do something like calling a major mode function.  As I said,
I don't think this is a good idea, any more.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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