From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Jul 2019 14:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36650 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 36650@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.156311575220279 (code B ref -1); Sun, 14 Jul 2019 14:50:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Jul 2019 14:49:12 +0000 Received: from localhost ([127.0.0.1]:45611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmfoO-0005H1-75 for submit@debbugs.gnu.org; Sun, 14 Jul 2019 10:49:12 -0400 Received: from lists.gnu.org ([209.51.188.17]:51308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmfoM-0005Gt-7x for submit@debbugs.gnu.org; Sun, 14 Jul 2019 10:49:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54225) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmfoL-0001QT-3H for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmfoJ-0001Ff-Vi for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:09 -0400 Received: from relayout01.e.movistar.es ([86.109.101.201]:57489 helo=relayout01-redir.e.movistar.es) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hmfoJ-0001Cx-O5 for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:07 -0400 Received: from sky (162.red-79-151-6.dynamicip.rima-tde.net [79.151.6.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 45mqL63m2bzfZjC for ; Sun, 14 Jul 2019 16:49:02 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes Date: Sun, 14 Jul 2019 16:49:01 +0200 Message-ID: <87y310acyq.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain X-CTCH-Score: 0.000 X-CTCH-ScoreCust: 0.000 X-TnetOut-Country: IP: 79.151.6.162 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 45mqL63m2bzfZjC.A62BF X-TnetOut-SpamCheck: no es spam, Unknown X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1563720542.73903@6ZshC0fvkjMYTK4+76tJ5Q X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.109.101.201 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) CC Mode does not recognize C++ attributes. Just as an example, the presence of an attribute causes wrong indentation on this example: struct C { C([[maybe_unused]] int x, int y) : a(y) {} int a; }; The line that begins with the colon should get another indentation level. Attributes are described here: https://en.cppreference.com/w/cpp/language/attributes In general, considering them part of the following token for indentation purposes and fontifying with some existing or new face should be enough. In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit) of 2019-06-29 built on sky Repository revision: 0b2841f9fb0ffd8514b0fb99c5673adad6b07abb Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes References: <87y310acyq.fsf@telefonica.net> Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 15 Jul 2019 14:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: =?UTF-8?Q?=C3=93scar?= Fuentes Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.15632008482111 (code B ref 36650); Mon, 15 Jul 2019 14:28:02 +0000 Received: (at 36650) by debbugs.gnu.org; 15 Jul 2019 14:27:28 +0000 Received: from localhost ([127.0.0.1]:48671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hn1wt-0000Xy-9x for submit@debbugs.gnu.org; Mon, 15 Jul 2019 10:27:28 -0400 Received: from colin.muc.de ([193.149.48.1]:23820 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hn1wp-0000Xi-4G for 36650@debbugs.gnu.org; Mon, 15 Jul 2019 10:27:23 -0400 Received: (qmail 71904 invoked by uid 3782); 15 Jul 2019 14:27:18 -0000 Date: 15 Jul 2019 14:27:18 -0000 Message-ID: <20190715142718.71903.qmail@mail.muc.de> From: Alan Mackenzie Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p9 (amd64)) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, =C3=93scar. In article you wrote= : > CC Mode does not recognize C++ attributes. Just as an example, the > presence of an attribute causes wrong indentation on this example: > struct C { > C([[maybe_unused]] int x, int y) > : a(y) > {} > int a; > }; > The line that begins with the colon should get another indentation > level. Yes. I'll have a look at this. > Attributes are described here: > https://en.cppreference.com/w/cpp/language/attributes Thanks. > In general, considering them part of the following token for indentatio= n > purposes and fontifying with some existing or new face should be enough= . I will probably end up treating attributes as syntactic whitespace. They have no syntactic connection with the code they are embedded in, any more than macros do. > In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit) > of 2019-06-29 built on sky > Repository revision: 0b2841f9fb0ffd8514b0fb99c5673adad6b07abb > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12004= 000 > System Description: Debian GNU/Linux 10 (buster) --=20 Alan Mackenzie (Nuremberg, Germany). From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 15 Jul 2019 15:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.156320386223987 (code B ref 36650); Mon, 15 Jul 2019 15:18:01 +0000 Received: (at 36650) by debbugs.gnu.org; 15 Jul 2019 15:17:42 +0000 Received: from localhost ([127.0.0.1]:48766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hn2jW-0006EF-65 for submit@debbugs.gnu.org; Mon, 15 Jul 2019 11:17:42 -0400 Received: from relayout02-redir.e.movistar.es ([86.109.101.202]:48571) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hn2jQ-00066Q-On for 36650@debbugs.gnu.org; Mon, 15 Jul 2019 11:17:40 -0400 Received: from sky (162.red-79-151-6.dynamicip.rima-tde.net [79.151.6.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout02.e.movistar.es (Postfix) with ESMTPSA id 45nRwS297Tzdbgw; Mon, 15 Jul 2019 17:17:28 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes References: <20190715142718.71903.qmail@mail.muc.de> Date: Mon, 15 Jul 2019 17:17:27 +0200 In-Reply-To: <20190715142718.71903.qmail@mail.muc.de> (Alan Mackenzie's message of "15 Jul 2019 14:27:18 -0000") Message-ID: <87muhf9vjs.fsf@telefonica.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-CTCH-Score: 0.000 X-CTCH-ScoreCust: 0.000 X-TnetOut-Country: IP: 79.151.6.162 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout02 X-TnetOut-MsgID: 45nRwS297Tzdbgw.AD743 X-TnetOut-SpamCheck: no es spam, Unknown X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1563808648.99414@4wseS6/oBrpisn3zgmKoOA X-Spam-Status: No X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alan Mackenzie writes: > Yes. I'll have a look at this. Thanks. >> In general, considering them part of the following token for indentation >> purposes and fontifying with some existing or new face should be enough. > > I will probably end up treating attributes as syntactic whitespace. > They have no syntactic connection with the code they are embedded in, > any more than macros do. I don't know how syntactic whitespace works on CC Mode, so just in case I'll mention that this code int foo([[maybe_unused]] int a, int b); should not be formatted as int foo([[maybe_unused]] int a, int b); From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 20 Jul 2019 18:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: =?UTF-8?Q?=C3=93scar?= Fuentes Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.15636457561379 (code B ref 36650); Sat, 20 Jul 2019 18:03:01 +0000 Received: (at 36650) by debbugs.gnu.org; 20 Jul 2019 18:02:36 +0000 Received: from localhost ([127.0.0.1]:57893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hotgp-0000M9-Mk for submit@debbugs.gnu.org; Sat, 20 Jul 2019 14:02:36 -0400 Received: from colin.muc.de ([193.149.48.1]:63633 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hotgn-0000M0-0d for 36650@debbugs.gnu.org; Sat, 20 Jul 2019 14:02:34 -0400 Received: (qmail 21688 invoked by uid 3782); 20 Jul 2019 17:10:07 -0000 Received: from acm.muc.de (p2E5D5FE3.dip0.t-ipconnect.de [46.93.95.227]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 20 Jul 2019 19:10:05 +0200 Received: (qmail 29830 invoked by uid 1000); 20 Jul 2019 18:02:30 -0000 Date: Sat, 20 Jul 2019 18:02:30 +0000 Message-ID: <20190720180230.GB27030@ACM> References: <20190715142718.71903.qmail@mail.muc.de> <87muhf9vjs.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87muhf9vjs.fsf@telefonica.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Óscar. On Mon, Jul 15, 2019 at 17:17:27 +0200, Óscar Fuentes wrote: > Alan Mackenzie writes: > > Yes. I'll have a look at this. > Thanks. > >> In general, considering them part of the following token for indentation > >> purposes and fontifying with some existing or new face should be enough. > > I will probably end up treating attributes as syntactic whitespace. > > They have no syntactic connection with the code they are embedded in, > > any more than macros do. The patch below (which should apply cleanly to the master branch) is a first attempt at handling C++ attributes. > I don't know how syntactic whitespace works on CC Mode, so just in case > I'll mention that this code > int foo([[maybe_unused]] int a, > int b); > should not be formatted as > int foo([[maybe_unused]] int a, > int b); Understood. Happily, the code appears to do the right thing anyway, without needing tedious fixing. :-) Could you please try out this patch, and let me know how well it works. Thanks! diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index cb88fc3e58..7963ab0d43 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1827,45 +1827,122 @@ c-remove-is-and-in-sws (def-edebug-spec c-remove-is-and-in-sws t) ;; The type of literal position `end' is in a `before-change-functions' -;; function - one of `c', `c++', `pound', or nil (but NOT `string'). +;; function - one of `c', `c++', `pound', `attribute', or nil (but NOT +;; `string'). (defvar c-sws-lit-type nil) -;; A cons (START . STOP) of the bounds of the comment or CPP construct +;; A cons (START . STOP) of the bounds of the comment or CPP construct, etc., ;; enclosing END, if any, else nil. (defvar c-sws-lit-limits nil) +(defmacro c-looking-at-c++-attribute () + ;; If we're in C++ Mode, and point is at the [[ introducing an attribute, + ;; return the position of the end of the attribute, otherwise return nil. + ;; The match data are NOT preserved over this macro. + `(and + (c-major-mode-is 'c++-mode) + (looking-at "\\[\\[") + (save-excursion + (and + (c-go-list-forward) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]) + (point))))) + +;; (defmacro c-enclosing-c++-attribute () +(defun c-enclosing-c++-attribute () + ;; If we're in C++ Mode, and point is within a correctly balanced [[ ... ]] + ;; attribute structure, return a cons of its starting and ending positions. + ;; Otherwise, return nil. We use the c-{in,is}-sws-face text properties for + ;; this determination, this macro being intended only for use in the *-sws-* + ;; functions and macros. The match data are NOT preserved over this macro. + (let (attr-end pos-is-sws) + (and + (c-major-mode-is 'c++-mode) + (> (point) (point-min)) + (setq pos-is-sws + (if (get-text-property (1- (point)) 'c-is-sws) + (1- (point)) + (1- (previous-single-property-change + (point) 'c-is-sws nil (point-min))))) + (save-excursion + (goto-char pos-is-sws) + (setq attr-end (c-looking-at-c++-attribute))) + (> attr-end (point)) + (cons pos-is-sws attr-end)))) + +(defun c-slow-enclosing-c++-attribute () + ;; Like `c-enclosing-c++-attribute', but does not depend on the c-i[ns]-sws + ;; properties being set. + (and + (c-major-mode-is 'c++-mode) + (save-excursion + (let ((paren-state (c-parse-state)) + cand) + (while + (progn + (setq cand + (catch 'found-cand + (while (cdr paren-state) + (when (and (numberp (car paren-state)) + (numberp (cadr paren-state)) + (eq (car paren-state) + (1+ (cadr paren-state))) + (eq (char-after (car paren-state)) ?\[) + (eq (char-after (cadr paren-state)) ?\[)) + (throw 'found-cand (cadr paren-state))) + (setq paren-state (cdr paren-state))))) + (and cand + (not + (and (c-go-list-forward cand) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]))))) + (setq paren-state (cdr paren-state))) + (and cand (cons cand (point))))))) + (defun c-invalidate-sws-region-before (beg end) ;; Called from c-before-change. BEG and END are the bounds of the change ;; region, the standard parameters given to all before-change-functions. ;; - ;; Note whether END is inside a comment, CPP construct, or noise macro, and - ;; if so note its bounds in `c-sws-lit-limits' and type in `c-sws-lit-type'. + ;; Note whether END is inside a comment, CPP construct, C++ attribute, or + ;; noise macro, and if so note its bounds in `c-sws-lit-limits' and type in + ;; `c-sws-lit-type'. (setq c-sws-lit-type nil c-sws-lit-limits nil) - (save-excursion - (goto-char end) - (let* ((limits (c-literal-limits)) - (lit-type (c-literal-type limits))) - (cond - ((memq lit-type '(c c++)) - (setq c-sws-lit-type lit-type - c-sws-lit-limits limits)) - ((c-beginning-of-macro) - (setq c-sws-lit-type 'pound - c-sws-lit-limits (cons (point) - (progn (c-end-of-macro) (point))))) - ((progn (skip-syntax-backward "w_") - (looking-at c-noise-macro-name-re)) - (setq c-sws-lit-type 'noise - c-sws-lit-limits (cons (match-beginning 1) (match-end 1)))) - (t)))) - (save-excursion - (goto-char beg) - (skip-syntax-backward "w_") - (when (looking-at c-noise-macro-name-re) - (setq c-sws-lit-type 'noise) - (if (consp c-sws-lit-limits) - (setcar c-sws-lit-limits (match-beginning 1)) - (setq c-sws-lit-limits (cons (match-beginning 1) (match-end 1))))))) + (save-match-data + (save-excursion + (goto-char end) + (let* ((limits (c-literal-limits)) + (lit-type (c-literal-type limits))) + (cond + ((memq lit-type '(c c++)) + (setq c-sws-lit-type lit-type + c-sws-lit-limits limits)) + ((c-beginning-of-macro) + (setq c-sws-lit-type 'pound + c-sws-lit-limits (cons (point) + (progn (c-end-of-macro) (point))))) + ((eq lit-type 'string)) + ((setq c-sws-lit-limits (c-enclosing-c++-attribute)) + (setq c-sws-lit-type 'attribute)) + ((progn (skip-syntax-backward "w_") + (looking-at c-noise-macro-name-re)) + (setq c-sws-lit-type 'noise + c-sws-lit-limits (cons (match-beginning 1) (match-end 1)))) + (t)))) + (save-excursion + (goto-char beg) + (let ((attr-limits (c-enclosing-c++-attribute))) + (if attr-limits + (if (consp c-sws-lit-limits) + (setcar c-sws-lit-limits (car attr-limits)) + (setq c-sws-lit-limits attr-limits)) + (skip-syntax-backward "w_") + (when (looking-at c-noise-macro-name-re) + (setq c-sws-lit-type 'noise) + (if (consp c-sws-lit-limits) + (setcar c-sws-lit-limits (match-beginning 1)) + (setq c-sws-lit-limits (cons (match-beginning 1) + (match-end 1)))))))))) (defun c-invalidate-sws-region-after-del (beg end _old-len) ;; Text has been deleted, OLD-LEN characters of it starting from position @@ -1940,7 +2017,7 @@ c-invalidate-sws-region-after (when (and (eolp) (not (eobp))) (setq end (1+ (point))))) - (when (eq c-sws-lit-type 'noise) + (when (memq c-sws-lit-type '(noise attribute)) (setq beg (car c-sws-lit-limits) end (cdr c-sws-lit-limits))) ; This last setting may be redundant. @@ -1990,6 +2067,8 @@ c-forward-sws (when (or (looking-at c-syntactic-ws-start) (and c-opt-cpp-prefix (looking-at c-noise-macro-name-re)) + (and (c-major-mode-is 'c++-mode) + (looking-at "\\[\\[")) (looking-at c-doc-line-join-re)) (setq rung-end-pos (min (1+ (point)) (point-max))) @@ -2126,6 +2205,16 @@ c-forward-sws (goto-char (match-end 1)) (not (eobp))) + ((and (c-major-mode-is 'c++-mode) + (looking-at "\\[\\[") + (save-excursion + (and (c-go-list-forward) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]) + (setq next-rung-pos (point)))) + (goto-char next-rung-pos)) + (not (eobp))) + ((looking-at c-doc-line-join-re) ;; Skip over a line join in (e.g.) Pike autodoc. (goto-char (match-end 0)) @@ -2240,6 +2329,13 @@ c-backward-sws (memq (char-before) c-doc-line-join-end-ch) ; For speed. (re-search-backward doc-line-join-here (c-point 'bopl) t)) + (and + (c-major-mode-is 'c++-mode) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]) + (save-excursion + (and (c-go-list-backward) + (looking-at "\\(\\)\\[\\[")))) (progn (backward-char) (or (looking-at c-syntactic-ws-end) @@ -2250,7 +2346,7 @@ c-backward-sws ;; Try to find a rung position in the simple ws preceding point, so that ;; we can get a cache hit even if the last bit of the simple ws has ;; changed recently. - (setq simple-ws-beg (or (match-end 1) ; Noise macro + (setq simple-ws-beg (or (match-end 1) ; Noise macro, etc. (match-end 0))) ; c-syntactic-ws-end (skip-chars-backward " \t\n\r\f\v") (if (setq rung-is-marked (text-property-any @@ -2388,6 +2484,16 @@ c-backward-sws (goto-char next-rung-pos) t) + ((and (c-major-mode-is 'c++-mode) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]) + (save-excursion + (and (c-go-list-backward) + (setq next-rung-pos (point)) + (looking-at "\\[\\[")))) + (goto-char next-rung-pos) + t) + ((and (memq (char-before) c-doc-line-join-end-ch) ; For speed. (re-search-backward doc-line-join-here (c-point 'bopl) t))))) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 5ae7e0f09d..a5e158933b 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -2158,9 +2158,11 @@ c-fl-decl-end ;; count as being in a declarator (on pragmatic grounds). (goto-char pos) (let ((lit-start (c-literal-start)) - pos1) + enclosing-attribute pos1) (unless lit-start (c-backward-syntactic-ws) + (when (setq enclosing-attribute (c-slow-enclosing-c++-attribute)) + (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. (when (setq pos1 (c-on-identifier)) (goto-char pos1) (let ((lim (save-excursion -- Alan Mackenzie (Nuremberg, Germany). From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 20 Jul 2019 22:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.156366131527511 (code B ref 36650); Sat, 20 Jul 2019 22:22:01 +0000 Received: (at 36650) by debbugs.gnu.org; 20 Jul 2019 22:21:55 +0000 Received: from localhost ([127.0.0.1]:57969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hoxjm-00079f-PG for submit@debbugs.gnu.org; Sat, 20 Jul 2019 18:21:54 -0400 Received: from relayout03-redir.e.movistar.es ([86.109.101.203]:26259) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hoxjk-00079P-MW for 36650@debbugs.gnu.org; Sat, 20 Jul 2019 18:21:53 -0400 Received: from sky (162.red-79-151-6.dynamicip.rima-tde.net [79.151.6.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout03.e.movistar.es (Postfix) with ESMTPSA id 45rj5h0Jl7zMlMq; Sun, 21 Jul 2019 00:21:43 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes References: <20190715142718.71903.qmail@mail.muc.de> <87muhf9vjs.fsf@telefonica.net> <20190720180230.GB27030@ACM> Date: Sun, 21 Jul 2019 00:21:43 +0200 In-Reply-To: <20190720180230.GB27030@ACM> (Alan Mackenzie's message of "Sat, 20 Jul 2019 18:02:30 +0000") Message-ID: <87d0i48hzc.fsf@telefonica.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-CTCH-Score: 0.000 X-CTCH-ScoreCust: 0.000 X-TnetOut-Country: IP: 79.151.6.162 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout03 X-TnetOut-MsgID: 45rj5h0Jl7zMlMq.A82BE X-TnetOut-SpamCheck: no es spam, Unknown X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1564266104.43689@5Mv8JYHPHSYZFEC138PPkA X-Spam-Status: No X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alan Mackenzie writes: > The patch below (which should apply cleanly to the master branch) is a > first attempt at handling C++ attributes. Thank you Alan. Wow, it required more changes than I would expect. Seems that it mostly works. The only issue I've found so far is struct S { S[[using : const]]() : data(0) {} int data; }; Note how ": data(0)" is not indented. If the attribute is moved before the name: struct S { [[using : const]] S() : data(0) {} int data; }; or after the parameter list: struct S { S() [[using: const]] : data(0) {} int data; }; then the indentation is correct. This only happens if the attribute is of the form "using:" (it is irrelevant if there is space between "using" and the colon). From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 21 Jul 2019 11:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: =?UTF-8?Q?=C3=93scar?= Fuentes Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.156370879124389 (code B ref 36650); Sun, 21 Jul 2019 11:34:01 +0000 Received: (at 36650) by debbugs.gnu.org; 21 Jul 2019 11:33:11 +0000 Received: from localhost ([127.0.0.1]:58174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpA5X-0006LJ-FF for submit@debbugs.gnu.org; Sun, 21 Jul 2019 07:33:11 -0400 Received: from colin.muc.de ([193.149.48.1]:60119 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hpA5V-0006L7-1O for 36650@debbugs.gnu.org; Sun, 21 Jul 2019 07:33:10 -0400 Received: (qmail 48460 invoked by uid 3782); 21 Jul 2019 10:40:42 -0000 Received: from acm.muc.de (p2E5D592F.dip0.t-ipconnect.de [46.93.89.47]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 21 Jul 2019 12:40:40 +0200 Received: (qmail 11253 invoked by uid 1000); 21 Jul 2019 11:33:05 -0000 Date: Sun, 21 Jul 2019 11:33:05 +0000 Message-ID: <20190721113305.GA11223@ACM> References: <20190715142718.71903.qmail@mail.muc.de> <87muhf9vjs.fsf@telefonica.net> <20190720180230.GB27030@ACM> <87d0i48hzc.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87d0i48hzc.fsf@telefonica.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Óscar. Thanks for the rapid response! On Sun, Jul 21, 2019 at 00:21:43 +0200, Óscar Fuentes wrote: > Alan Mackenzie writes: > > The patch below (which should apply cleanly to the master branch) is > > a first attempt at handling C++ attributes. > Thank you Alan. Wow, it required more changes than I would expect. These attributes can appear anywhere. That's why. > Seems that it mostly works. The only issue I've found so far is > struct S { > S[[using : const]]() > : data(0) > {} > int data; > }; > Note how ": data(0)" is not indented. If the attribute is moved before the > name: > struct S { > [[using : const]] S() > : data(0) > {} > int data; > }; > or after the parameter list: > struct S { > S() [[using: const]] > : data(0) > {} > int data; > }; > then the indentation is correct. This only happens if the attribute is > of the form "using:" (it is irrelevant if there is space between "using" > and the colon). Yes. More precisely, it was the presence of the colon inside the attribute which confused a low level CC Mode function (c-crosses-statement-barrier-p). This function scans forward for a character which might be relevant for statement boundaries, and one of these characters is :. I've added handling for [[...]] into this function, and it now seems to be working. Would you please apply the following supplementary patch to your current master state, try it out again, and let me know how it goes. Thanks! --- cc-engine.el~ 2019-07-20 17:45:13.944753490 +0000 +++ cc-engine.el 2019-07-21 10:43:31.470078502 +0000 @@ -697,6 +697,21 @@ (overlay-put (make-overlay end ol-end) 'face face)))) +(defmacro c-looking-at-c++-attribute () + ;; If we're in C++ Mode, and point is at the [[ introducing an attribute, + ;; return the position of the end of the attribute, otherwise return nil. + ;; The match data are NOT preserved over this macro. + `(and + (c-major-mode-is 'c++-mode) + (looking-at "\\[\\[") + (save-excursion + (and + (c-go-list-forward) + (eq (char-before) ?\]) + (eq (char-before (1- (point))) ?\]) + (point))))) + + ;; `c-beginning-of-statement-1' and accompanying stuff. ;; KLUDGE ALERT: c-maybe-labelp is used to pass information between @@ -1420,9 +1435,15 @@ c-opt-cpp-symbol ; usually "#" (substring c-stmt-delim-chars 1)) ; e.g. ";{}?:" c-stmt-delim-chars)) + (skip-chars + (if (c-major-mode-is 'c++-mode) + (concat (substring skip-chars 0 1) ; "^" + "[" ; to catch C++ attributes + (substring skip-chars 1)) ; e.g. "#;{}?:" + skip-chars)) (non-skip-list (append (substring skip-chars 1) nil)) ; e.g. (?# ?\; ?{ ?} ?? ?:) - lit-range lit-start vsemi-pos) + lit-range lit-start vsemi-pos attr-end) (save-restriction (widen) (save-excursion @@ -1446,6 +1467,11 @@ ;; In a string/comment? ((setq lit-range (c-literal-limits from)) (goto-char (cdr lit-range))) + ;; Skip over a C++ attribute? + ((eq (char-after) ?\[) + (if (setq attr-end (c-looking-at-c++-attribute)) + (goto-char attr-end) + (forward-char))) ((eq (char-after) ?:) (forward-char) (if (and (eq (char-after) ?:) @@ -1839,21 +1865,6 @@ ;; enclosing END, if any, else nil. (defvar c-sws-lit-limits nil) -(defmacro c-looking-at-c++-attribute () - ;; If we're in C++ Mode, and point is at the [[ introducing an attribute, - ;; return the position of the end of the attribute, otherwise return nil. - ;; The match data are NOT preserved over this macro. - `(and - (c-major-mode-is 'c++-mode) - (looking-at "\\[\\[") - (save-excursion - (and - (c-go-list-forward) - (eq (char-before) ?\]) - (eq (char-before (1- (point))) ?\]) - (point))))) - -;; (defmacro c-enclosing-c++-attribute () (defun c-enclosing-c++-attribute () ;; If we're in C++ Mode, and point is within a correctly balanced [[ ... ]] ;; attribute structure, return a cons of its starting and ending positions. -- Alan Mackenzie (Nuremberg, Germany). From unknown Sat Sep 20 23:20:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36650: 27.0.50; CC Mode: Support C++ attributes Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 21 Jul 2019 14:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36650 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: To: Alan Mackenzie Cc: 36650@debbugs.gnu.org Received: via spool by 36650-submit@debbugs.gnu.org id=B36650.156372102715229 (code B ref 36650); Sun, 21 Jul 2019 14:58:02 +0000 Received: (at 36650) by debbugs.gnu.org; 21 Jul 2019 14:57:07 +0000 Received: from localhost ([127.0.0.1]:59293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpDGr-0003xX-Hd for submit@debbugs.gnu.org; Sun, 21 Jul 2019 10:57:07 -0400 Received: from relayout02-redir.e.movistar.es ([86.109.101.202]:23481) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpDGo-0003x0-UJ for 36650@debbugs.gnu.org; Sun, 21 Jul 2019 10:57:03 -0400 Received: from sky (162.red-79-151-6.dynamicip.rima-tde.net [79.151.6.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout02.e.movistar.es (Postfix) with ESMTPSA id 45s79y447mzdb9N; Sun, 21 Jul 2019 16:56:53 +0200 (CEST) From: =?UTF-8?Q?=C3=93scar?= Fuentes References: <20190715142718.71903.qmail@mail.muc.de> <87muhf9vjs.fsf@telefonica.net> <20190720180230.GB27030@ACM> <87d0i48hzc.fsf@telefonica.net> <20190721113305.GA11223@ACM> Date: Sun, 21 Jul 2019 16:56:53 +0200 In-Reply-To: <20190721113305.GA11223@ACM> (Alan Mackenzie's message of "Sun, 21 Jul 2019 11:33:05 +0000") Message-ID: <87v9vv77wq.fsf@telefonica.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-CTCH-Score: 0.000 X-CTCH-ScoreCust: 0.000 X-TnetOut-Country: IP: 79.151.6.162 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout02 X-TnetOut-MsgID: 45s79y447mzdb9N.A077C X-TnetOut-SpamCheck: no es spam, Unknown X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1564325815.43484@zMr9kPXiH9gMNAO/wIwzAg X-Spam-Status: No X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alan Mackenzie writes: > Would you please apply the following supplementary patch to your current > master state, try it out again, and let me know how it goes. I repeated my attempts of breaking the new feature and now I was defeated :-) Thanks again Alan. From unknown Sat Sep 20 23:20:36 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=C3=93scar?= Fuentes Subject: bug#36650: closed (Re: bug#36650: 27.0.50; CC Mode: Support C++ attributes) Message-ID: References: <20190721211634.GB11223@ACM> <87y310acyq.fsf@telefonica.net> X-Gnu-PR-Message: they-closed 36650 X-Gnu-PR-Package: emacs,cc-mode Reply-To: 36650@debbugs.gnu.org Date: Sun, 21 Jul 2019 21:17:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1563743822-15106-1" This is a multi-part message in MIME format... ------------=_1563743822-15106-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #36650: 27.0.50; CC Mode: Support C++ attributes which was filed against the emacs,cc-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 36650@debbugs.gnu.org. --=20 36650: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D36650 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1563743822-15106-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 36650-done) by debbugs.gnu.org; 21 Jul 2019 21:16:40 +0000 Received: from localhost ([127.0.0.1]:59591 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpJCC-0003uy-7S for submit@debbugs.gnu.org; Sun, 21 Jul 2019 17:16:40 -0400 Received: from colin.muc.de ([193.149.48.1]:14294 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hpJCA-0003uo-Hc for 36650-done@debbugs.gnu.org; Sun, 21 Jul 2019 17:16:39 -0400 Received: (qmail 27822 invoked by uid 3782); 21 Jul 2019 20:24:11 -0000 Received: from acm.muc.de (p2E5D592F.dip0.t-ipconnect.de [46.93.89.47]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 21 Jul 2019 22:24:10 +0200 Received: (qmail 16077 invoked by uid 1000); 21 Jul 2019 21:16:34 -0000 Date: Sun, 21 Jul 2019 21:16:34 +0000 To: =?iso-8859-1?Q?=D3scar?= Fuentes Subject: Re: bug#36650: 27.0.50; CC Mode: Support C++ attributes Message-ID: <20190721211634.GB11223@ACM> References: <20190715142718.71903.qmail@mail.muc.de> <87muhf9vjs.fsf@telefonica.net> <20190720180230.GB27030@ACM> <87d0i48hzc.fsf@telefonica.net> <20190721113305.GA11223@ACM> <87v9vv77wq.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87v9vv77wq.fsf@telefonica.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36650-done Cc: 36650-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello again, Óscar. On Sun, Jul 21, 2019 at 16:56:53 +0200, Óscar Fuentes wrote: > Alan Mackenzie writes: > > Would you please apply the following supplementary patch to your current > > master state, try it out again, and let me know how it goes. > I repeated my attempts of breaking the new feature and now I was > defeated :-) Excellent! > Thanks again Alan. I've committed the enhancement to savannah master (warning: it's not quite identical to the patches I sent you), and I'm closing the bug with this post. -- Alan Mackenzie (Nuremberg, Germany). ------------=_1563743822-15106-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Jul 2019 14:49:12 +0000 Received: from localhost ([127.0.0.1]:45611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmfoO-0005H1-75 for submit@debbugs.gnu.org; Sun, 14 Jul 2019 10:49:12 -0400 Received: from lists.gnu.org ([209.51.188.17]:51308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmfoM-0005Gt-7x for submit@debbugs.gnu.org; Sun, 14 Jul 2019 10:49:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54225) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmfoL-0001QT-3H for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmfoJ-0001Ff-Vi for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:09 -0400 Received: from relayout01.e.movistar.es ([86.109.101.201]:57489 helo=relayout01-redir.e.movistar.es) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hmfoJ-0001Cx-O5 for bug-gnu-emacs@gnu.org; Sun, 14 Jul 2019 10:49:07 -0400 Received: from sky (162.red-79-151-6.dynamicip.rima-tde.net [79.151.6.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 45mqL63m2bzfZjC for ; Sun, 14 Jul 2019 16:49:02 +0200 (CEST) From: =?utf-8?Q?=C3=93scar_Fuentes?= To: bug-gnu-emacs@gnu.org Subject: 27.0.50; CC Mode: Support C++ attributes Date: Sun, 14 Jul 2019 16:49:01 +0200 Message-ID: <87y310acyq.fsf@telefonica.net> MIME-Version: 1.0 Content-Type: text/plain X-CTCH-Score: 0.000 X-CTCH-ScoreCust: 0.000 X-TnetOut-Country: IP: 79.151.6.162 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 45mqL63m2bzfZjC.A62BF X-TnetOut-SpamCheck: no es spam, Unknown X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1563720542.73903@6ZshC0fvkjMYTK4+76tJ5Q X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 86.109.101.201 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) CC Mode does not recognize C++ attributes. Just as an example, the presence of an attribute causes wrong indentation on this example: struct C { C([[maybe_unused]] int x, int y) : a(y) {} int a; }; The line that begins with the colon should get another indentation level. Attributes are described here: https://en.cppreference.com/w/cpp/language/attributes In general, considering them part of the following token for indentation purposes and fontifying with some existing or new face should be enough. In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit) of 2019-06-29 built on sky Repository revision: 0b2841f9fb0ffd8514b0fb99c5673adad6b07abb Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) ------------=_1563743822-15106-1--