unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Ivan Andrus <darthandrus@gmail.com>
Cc: 23610@debbugs.gnu.org
Subject: bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename
Date: 19 Jun 2016 21:14:40 -0000	[thread overview]
Message-ID: <20160619211440.86830.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.202.1464109329.1216.bug-gnu-emacs@gnu.org>

Hello, Ivan.

In article <mailman.202.1464109329.1216.bug-gnu-emacs@gnu.org> you wrote:
> Starting with emacs -Q, Y is not fontified in the snippet below, whereas
> X is.

> -Ivan


> template <typename X, typename... Y>
> class bob {

> };

[ .... ]

The following patch is a first attempt to fontify parameter packs.  After
applying it, please be sure either to recompile CC Mode entirely, or
first to compile cc-langs.el (which contains macros), and then all three
of cc-fonts.el, cc-engine.el, and cc-mode.el.

It seems to fontify the "Y" above OK.  I've tried it on a stock example
out of Wikipedia, and that works.  Could you try it out on your code,
please, and let me know how well it works.

Here's the patch:




diff -r f70569e7cf8e cc-engine.el
--- a/cc-engine.el	Sun Jun 19 11:54:55 2016 +0000
+++ b/cc-engine.el	Sun Jun 19 21:05:32 2016 +0000
@@ -6910,6 +6910,9 @@
       (while (cond
 	      ((looking-at c-decl-hangon-key)
 	       (c-forward-keyword-clause 1))
+	      ((looking-at c-pack-key)
+	       (goto-char (match-end 1))
+	       (c-forward-syntactic-ws))
 	      ((and c-opt-cpp-prefix
 		    (looking-at c-noise-macro-with-parens-name-re))
 	       (c-forward-noise-clause))))
diff -r f70569e7cf8e cc-langs.el
--- a/cc-langs.el	Sun Jun 19 11:54:55 2016 +0000
+++ b/cc-langs.el	Sun Jun 19 21:05:32 2016 +0000
@@ -1304,6 +1304,14 @@
 (c-lang-defvar c-stmt-delim-chars-with-comma
   (c-lang-const c-stmt-delim-chars-with-comma))
 
+(c-lang-defconst c-pack-ops
+  "Ops which signal C++11's \"parameter pack\""
+  t nil
+  c++ '("..."))
+(c-lang-defconst c-pack-key
+  t (c-make-keywords-re 'appendable (c-lang-const c-pack-ops)))
+(c-lang-defvar c-pack-key (c-lang-const c-pack-key))
+
 (c-lang-defconst c-auto-ops
   ;; Ops which signal C++11's new auto uses.
   t nil


-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2016-06-19 21:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 17:01 bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename Ivan Andrus
     [not found] ` <mailman.202.1464109329.1216.bug-gnu-emacs@gnu.org>
2016-05-30 12:57   ` Alan Mackenzie
2016-05-30 13:49     ` Óscar Fuentes
2016-05-30 15:25       ` Alan Mackenzie
2016-07-23 15:13     ` Alan Mackenzie
2016-06-19 21:14   ` Alan Mackenzie [this message]
2016-06-22 15:22     ` Ivan Andrus
2016-06-30 14:36       ` Alan Mackenzie
2016-06-30 15:10         ` John Yates
2016-06-30 16:47           ` Alan Mackenzie
2016-06-30 17:24       ` 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=20160619211440.86830.qmail@mail.muc.de \
    --to=acm@muc.de \
    --cc=23610@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 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).