emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: C++-mode: Syntax highlighting: wrong color for funct


From: Alan Mackenzie
Subject: Re: address@hidden: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows]
Date: Thu, 16 Feb 2006 09:51:50 +0000 (GMT)

Good Morning!

On Wed, 15 Feb 2006, Stefan Monnier wrote:

>>>>> This patch to font-lock is exactly the sort of change I was thinking of.
>>>>> Could someone please install it, then rename
>>>>> before-font-lock-after-change-function to
>>>>> font-lock-extend-region-function, and rename
>>>>> font-lock-run-before-after-change-hook to font-lock-extend-region?

>>> .... Based on the name, I suppose it's some kind of hook in
>>> font-lock-after-change-function, in which case I'd be tempted to suggest
>>> to move it to font-lock-fontify-region instead, to reduce the
>>> performance impact and make it easier to deal with lazy-lock&jit-lock
>>> since these tend to use their own after-change-function.

My original patch patched the \(lazy\|jit\)-lock after-change-functions,
too.  Maybe it would be cleaner to have a new function,
(font-lock-get-after-change-region BEG END OLD-LEN), to return that
region.  This function would also deal with extending the region to whole
lines.

After all, the region to fontify must be the same, regardless of the
support mode (if any) in use.

>> I strongly oppose such a change.  With that change:

>> (i) font-lock-fontify-region would no longer be fontifying the region
>> specified by its paramters, but a different (possibly larger) one.

>That's already the case since font-lock-fontify-region will typically not
>fontify from BEG to END from the beginning of line before BEG to the end of
>line after END.  Then that can be extended yet further because of
>font-lock-multiline.  Nobody has ever complained about this.

>So why is it a problem?

"Nobody complaining" has never been good evidence for something being OK.
Intimidation by authorities (though that doesn't happen here, hi
Richard!) will produce the same effect.  In fact, if Emacs 22 introduced
some wonderful new user facility, and there were NO complaints (or
feature requests), most likely nobody would be using it.

I think, in general, functions MUST do what they say they do, on the
exact parameters given by the caller.  For example, if SQRT (9) is
returned rather than SQRT (9.00322), because it's "easier to calculate",
this would be a bad thing.  In fact, Intel did more or less this with
some of their chips ~10 years ago.  Nobody complained, at least, not for
a while.  That didn't make it OK.

The burden of proof is surely the other way round.  If somebody believes
that, when a caller calls (font-lock-fontify-region 173 258), it's OK to
font lock the region (1 250) instead, the onus is on him to show that
this really is OK.

>> (ii) the hook function (which recalculates BEG and END) might well refer
>> to variables set by a before-change-functions hook.  (This is done in AWK
>> mode, for example).

>Which variables would that be?

Just one, actually - c-awk-old-EOLL, in cc-awk.el ~L787 - L811.  This
records the end-of-logical-line position before the change, in case the
change deletes the \ of an escaped newline.

>> f-l-f-region is regularly called when there is no buffer change in progress.

>Indeed.  Again, why is it a problem?

It would be a problem if f-l-f-region called the hook function, because
it would use c-awk-old-EOLL, which wouldn't now have a meaningful value.
Or, the hook would have to code round this, behaving differently
depending on where f-l-f-region was called from, which would be a Very
Bad Thing.

Or have I totally lost the thread of the argument, here?

>> Both of these things would make debugging a hook function much more
>> difficult than it already is.  Determining the region to fontify and
>> actually fontifying it are two logically distinct operations.

>With jit-lock, the region to fontify is not determined by the
>after-change-functions either.

(jit-lock-after-change BEG END OLD-LEN) determines that region in a
well defined fashion, surely?

The after-change (BEG END OLD-LEN) has a critically different meaning
from the (BEG END) in (font-lock-fontify-region BEG END).  The first of
these says how the buffer has been changed, the second defines a region
to fontify.  Deriving the second of these from the first is precisely the
problem we're trying to solve.

>        Stefan

-- 
Alan.






reply via email to

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