GNU bug report logs - #23610
25.0.94; c++-mode doesn't fontify typename... like typename

Previous Next

Packages: emacs, cc-mode;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Tue, 24 May 2016 17:02:02 UTC

Severity: minor

Found in version 25.0.94

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 23610 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Ivan Andrus <darthandrus <at> gmail.com>
Cc: 23610 <at> debbugs.gnu.org
Subject: Re: bug#23610: 25.0.94;
 c++-mode doesn't fontify typename... like typename
Date: 19 Jun 2016 21:14:40 -0000
Hello, Ivan.

In article <mailman.202.1464109329.1216.bug-gnu-emacs <at> 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).





This bug report was last modified 8 years and 307 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.