all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ivan Andrus <darthandrus@gmail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: 15211@debbugs.gnu.org
Subject: bug#15211: 24.3.50; Incorrect fontification in c++-mode
Date: Tue, 10 Sep 2013 14:04:31 -0600	[thread overview]
Message-ID: <143319A4-5908-4B0C-9B33-D3AA59142260@gmail.com> (raw)
In-Reply-To: <20130831205645.GA4066@acm.acm>


On Aug 31, 2013, at 2:56 PM, Alan Mackenzie <acm@muc.de> wrote:

> Hi, Ivan.
> 
>> In C and C++ it is legal to place the const to the right of the type as below:
> 
>> Json parseJson( string const &json );
> 
>> However, this results in "string" not being fontified as a type
>> (i.e. with `font-lock-type-face').  It seems to work some times, but the
>> minimal example above does not when starting from `emacs -q`.
> 
> Yes.  There is special code in `c-forward-type' that causes different
> return codes for "string const" and "string".  These two return codes are
> specifically differentiated (at the end of `c-forward-decl-or-cast-1')
> when deciding whether or not to fontify the identifier.
> 
> I've not been able to understand why this code does this - the code has
> been in place for well over a decade, and I've been looking at old change
> logs.  The following patch disables the distinction and always fontifies
> the identifier.  Please try it out and let me know if any undesirable
> side effects occur, or if it doesn't quite fix the problem in real code:

I have been using your diff below for a few days, and I haven't noticed any negative side effects.

There are still two things that don't fontify correctly:


#define DELETE_MEMBER = delete
class Bob
{
    Bob &operator=(Bob const &) = delete; // fontified (with diff applied)
    Bob &operator=(Bob const &) DELETE_MEMBER; // not fontified with or without diff

    Bob( string );    // string is a `font-lock-type-face'
    explicit Bob( string ); // string is `font-lock-variable-name-face'
};


The first bad fontification seems to be caused because it doesn't understand the macro which probably can't be helped.  The second though is a bit more concerning, though it seems to be unrelated to the current bug.  I will probably open another bug for it unless you'd prefer I didn't


> 
> diff -r 45df171f9859 cc-engine.el
> --- a/cc-engine.el	Sat Aug 31 11:09:30 2013 +0000
> +++ b/cc-engine.el	Sat Aug 31 20:32:22 2013 +0000
> @@ -7440,7 +7440,8 @@
> 	;; interactive refontification.
> 	(c-put-c-type-property (point) 'c-decl-arg-start))
> 
> -      (when (and c-record-type-identifiers at-type (not (eq at-type t)))
> +      (when (and c-record-type-identifiers at-type ;; (not (eq at-type t))
> +		 )
> 	(let ((c-promote-possible-types t))
> 	  (save-excursion
> 	    (goto-char type-start)
> 
> 
> After applying the patch to .../lisp/progmodes/cc-engine.el, just
> recompile cc-engine.el with M-x byte-compile-file <CR> cc-engine.el, then
> reload cc-engine.elc with M-x load-file <CR> cc-engine.elc.
> 
>> Although this is fairly uncommon, there are valid reasons for doing this
>> (see http://www.dansaks.com/articles/1999-02%20const%20T%20vs%20T%20const.pdf
>> for example), and at work it's ubiquitous.  The lack of fontification is
>> annoying since it gives me vi envy. :-)
> 
> We can't have that.  ;-)

Don't worry, it doesn't last long.  :-)

>> Thanks for the overall excellent cc-mode(s)!
> 
> And thank you for taking the trouble to report this bug, and even more
> for such a high quality bug report.

Based on how quickly you responded, I wish I had reported it long ago.

Thanks again,
Ivan




  reply	other threads:[~2013-09-10 20:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-29 20:48 bug#15211: 24.3.50; Incorrect fontification in c++-mode Ivan Andrus
2013-08-31 20:56 ` Alan Mackenzie
2013-09-10 20:04   ` Ivan Andrus [this message]
2013-09-18 21:19     ` Alan Mackenzie
2013-09-19  3:33       ` Ivan Andrus
2013-09-18 20:53 ` 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

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

  git send-email \
    --in-reply-to=143319A4-5908-4B0C-9B33-D3AA59142260@gmail.com \
    --to=darthandrus@gmail.com \
    --cc=15211@debbugs.gnu.org \
    --cc=acm@muc.de \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.