[Top][All Lists]

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

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

From: martin rudalics
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 10:07:19 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Why don't you construct a regular expression which would only find a "<<"
which isn't in a maths construct?

A regular expressions that knows about syntactic context?

I don't know LaTex, but assuming these
"<<" ">>" pairs can't be nested (is this the case?), you could make this
regexp stop (with "not found") at a second "<<" (not within a maths

This means when you change a "maths thingy" you have to check for "<<"s
and ">>"s that are now in- / outside the thingy as well.

In your font-lock matcher function, you would first go back to a "safe
place", then scan forward for this regexp.  Even though the regexp would
be quite intricate, it would still be reasonably fast, even if you end up
scanning to the end of the buffer.

That wouldn't be just-in-time any more.

Another idea would be to maintain a list of "<<" ">>" pairs, which
you would update in an after-change-function.

Using markers?

I suggest that you font lock only the complete construct "<< ..... >>".
You might want to give an unmated "<<" or ">>" font-lock-warning-face
until the user completes the construct.

That works efficiently for syntactically fontified text like comments or
strings.  In the present case it's yet another complication - typing
">>" might cause searching from bob till point.

reply via email to

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