emacs-devel
[Top][All Lists]
Advanced

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

Re: CC-mode highlight change between 24.5 and 25


From: Alan Mackenzie
Subject: Re: CC-mode highlight change between 24.5 and 25
Date: Fri, 2 Sep 2016 13:27:04 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Oleh.

On Fri, Sep 02, 2016 at 01:58:15PM +0200, Oleh Krehel wrote:
> Hi all,

> I just noticed a difference in the highlight of this minimal file:

> 1    #include <fstream>
> 2    
> 3    int test (const char *file_name) {
> 4      std::ofstream fout (file_name);
> 5    }

> In version 24.5 the variable `fout' is properly highlighted with
> `font-lock-variable-name-face'.  But in 25 it's highlighted with
> `font-lock-function-name-face'.

Yes, some change (I can't remember exactly when or what) was made to
make a function declaration fontify properly.

The trouble is that L4 looks _exactly_ like a function declaration, the
function `fout' returning something of type `std::ofstream', and taking
a single parameter of type `file_name'.

> Sorry if this was reported before. I just hope it can be fixed.

I hope so, too.  ;-)

Can you help me out here, please - by what criterion is the C++ compiler
deciding that `fout' is a variable initialised to `file_name' rather
than a function declaration?  The only syntactic thing I can see for
this is that `fout' is declared inside a function rather than at the top
level (or directly inside a class, struct, or namespace).

At the moment, CC Mode's fontification functions don't keep track of
whether the "current position" is inside a function or not, and it would
be a fair amount of work to make it track this.

If the compiler makes the decision based on semantic things (i.e. that
`file_name' is already known to be a variable rather than a type),
things would be very difficult indeed for CC Mode, which isn't a
compiler.

> regards,
> Oleh

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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