bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#24271: 25.1; font-lock problem of c++-mode


From: Jiajian Huang
Subject: bug#24271: 25.1; font-lock problem of c++-mode
Date: Sat, 20 Aug 2016 15:57:02 +0800

(I’m sorry for resending this message.)

Hi, Thanks for your reply. 

I’m not meaning to write invalid C++ program intentionally, like making a “int test” into “in test”.

When we’re typing “int test”, we type the “i” first then “n”, then “t”, then “ “(space), then “test”, namely,

“i” -> “in” -> “int” -> “int “ -> … -> “int test”,

even “normally” typing, the syntax keeping changing. Let’s keep tracking this procedure.


As you can see, none of the above images shows a “valid” C++ program. But the color(or the font style) has at least
changed twice. Base on what you’ve point out, the color should change once the “i” is input  and keep unbold till image 4 
since none of them is valid.

This could happen in any other place when typing in c++-mode, like

Example 1

Why the “vector” in the first image and third is not turn into “bold red” ?
Why the “vec” in the second image is turn into “bold red” ?

Example 2

This is a more serious example. As you can see, I normally input such a short line “using std::string”, the color have change 6 times !
I don’s think any of them is a “valid” C++ program except the last one.

I’ve not seen any other major mode has such a “feature”. This is my first time get into c++-mode. Because of this mechanism,
the current input area keep “flashing” too much when keep typing fast within a buffer full of words even under such a light color theme. 
I feel that it’s so different from other major mode(python-mode etc.) soon as I switch to c++-mode. Maybe it’s not a bug, but I don’t think it’s a good feature.

Thanks.

On 20 Aug 2016, at 14:56, Eli Zaretskii <eliz@gnu.org> wrote:

From: Jiajian Huang <wherejoystarts@gmail.com>
Date: Sat, 20 Aug 2016 08:42:43 +0800

I recently notice that there's some strange behaviours of the font-lock of the c++-mode.

I don't see it as strange.

Let's start emacs by `emacs -Q` in the terminal, edit a new file `test.cpp` and save the following contents

Then put the cursor two lines above the `int main` line, type `int test`, you will find that the color of word `main` changes from *blue* to *black*

Backspace the current line to `in` or `i`, you will see that the color of `main` change back to *blue*

When you insert "int test", without the semi-colon, your buffer now
has an invalid C++ program, so it's a small wonder the colors change.
When you replace "int test" with "in test", the "in" part is no longer
a C++ type, so it's again small wonder that colors change.

Is this a emacs bug ?

I don't think it's a bug.

Thanks.

reply via email to

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