all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: 15211@debbugs.gnu.org, Ivan Andrus <darthandrus@gmail.com>
Subject: bug#15211: 24.3.50; Incorrect fontification in c++-mode
Date: Sat, 31 Aug 2013 20:56:45 +0000	[thread overview]
Message-ID: <20130831205645.GA4066@acm.acm> (raw)
In-Reply-To: <C8804F8C-9B5B-48A1-BF41-4C11E9763AA3@gmail.com>

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:



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.  ;-)

> 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.

-Ivan

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2013-08-31 20:56 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 [this message]
2013-09-10 20:04   ` Ivan Andrus
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=20130831205645.GA4066@acm.acm \
    --to=acm@muc.de \
    --cc=15211@debbugs.gnu.org \
    --cc=darthandrus@gmail.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 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.