From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23610: 25.0.94; c++-mode doesn't fontify typename... like typename Date: Thu, 30 Jun 2016 17:24:32 +0000 Message-ID: <20160630172432.GF3082__2032.71200084618$1467307693$gmane$org@acm.fritz.box> References: <20160619211440.86830.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1467307693 17231 80.91.229.3 (30 Jun 2016 17:28:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Jun 2016 17:28:13 +0000 (UTC) Cc: 23610@debbugs.gnu.org To: Ivan Andrus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 30 19:28:03 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bIfkw-0005bG-8g for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 19:28:02 +0200 Original-Received: from localhost ([::1]:51819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIfkv-0005jD-Fx for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Jun 2016 13:28:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIfi8-0003UH-S3 for bug-gnu-emacs@gnu.org; Thu, 30 Jun 2016 13:25:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIfi7-0000UJ-IV for bug-gnu-emacs@gnu.org; Thu, 30 Jun 2016 13:25:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIfi2-0000Qi-No; Thu, 30 Jun 2016 13:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bIfi2-0005DN-Ep; Thu, 30 Jun 2016 13:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 30 Jun 2016 17:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23610 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 23610-submit@debbugs.gnu.org id=B23610.146730747019994 (code B ref 23610); Thu, 30 Jun 2016 17:25:02 +0000 Original-Received: (at 23610) by debbugs.gnu.org; 30 Jun 2016 17:24:30 +0000 Original-Received: from localhost ([127.0.0.1]:32784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIfhW-0005CQ-EF for submit@debbugs.gnu.org; Thu, 30 Jun 2016 13:24:30 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:60834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIfhQ-0005C8-GI for 23610@debbugs.gnu.org; Thu, 30 Jun 2016 13:24:28 -0400 Original-Received: (qmail 85675 invoked by uid 3782); 30 Jun 2016 17:24:23 -0000 Original-Received: from acm.muc.de (p4FC460AB.dip0.t-ipconnect.de [79.196.96.171]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 30 Jun 2016 19:24:22 +0200 Original-Received: (qmail 6942 invoked by uid 1000); 30 Jun 2016 17:24:32 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120233 Archived-At: Hello again, Ivan. On Wed, Jun 22, 2016 at 09:22:01AM -0600, Ivan Andrus wrote: > On Sun, Jun 19, 2016 at 3:14 PM, Alan Mackenzie wrote: > > Hello, Ivan. > > In article you wrote: > >> Starting with emacs -Q, Y is not fontified in the snippet below, whereas > >> X is. > >> -Ivan > >> template > >> 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. > It looks pretty good. I didn't notice this before, but the following example > from Wikipedia is fontified differently if the ... is removed from before the > `args`. In that case args is fontified with `font-lock-variable-name-face`. > template inline void expand(Args&&... args) { > pass( some_function(args)... ); > } OK. I think the patch below fixes it. Please try it out and report back. (Same instructions about recompilation of CC Mode as last time apply, since further macros in cc-langs.el have been modified). Please note that the patch below is complete in itself, it isn't incremental, based on the last patch. It's based on a current Emacs master branch. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 48b9e5e..cc60175 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -7090,6 +7090,9 @@ c-forward-type (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 --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 4d36684..b903190 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -1329,6 +1329,14 @@ 'c-opt-op-identitier-prefix (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 @@ -2958,6 +2966,10 @@ 'c-opt-op-identitier-prefix "\\)" "\\([^=]\\|$\\)") c++ (concat "\\(" + "&&" + "\\|" + "\\.\\.\\." + "\\|" "[*(&]" "\\|" (c-lang-const c-type-decl-prefix-key) > -Ivan -- Alan Mackenzie (Nuremberg, Germany).