unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Oleh Krehel <oleh@oremacs.com>
Cc: emacs-devel@gnu.org
Subject: Re: CC-mode highlight change between 24.5 and 25
Date: Fri, 2 Sep 2016 13:27:04 +0000	[thread overview]
Message-ID: <20160902132704.GC4439@acm.fritz.box> (raw)
In-Reply-To: <878tvaeco8.fsf@oremacs.com>

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	other threads:[~2016-09-02 13:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 11:58 CC-mode highlight change between 24.5 and 25 Oleh Krehel
2016-09-02 13:27 ` Alan Mackenzie [this message]
2016-09-02 14:10   ` Yuri Khan
2016-09-02 14:40     ` Alan Mackenzie
2016-09-02 17:39       ` Davis Herring
2016-09-02 17:48         ` Eli Zaretskii
2016-09-04 22:29         ` Alan Mackenzie
2016-09-02 14:18   ` Oleh Krehel
2016-09-02 14:31     ` Alan Mackenzie
2016-09-02 17:21       ` Davis Herring
2016-09-04 15:38     ` Alan Mackenzie
2016-09-05  9:27       ` Oleh Krehel
2016-09-05 15:20         ` Alan Mackenzie
2016-09-06 13:37           ` Oleh Krehel
2016-09-06 17:02             ` Alan Mackenzie
2016-09-07 14:10               ` Alan Mackenzie
2016-09-09 10:01                 ` Oleh Krehel
2016-09-11 21:22                   ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160902132704.GC4439@acm.fritz.box \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=oleh@oremacs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).