From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#42581: Wrong C++ indentation when using class MY_DLL_EXPORT_MACRO foo Date: Fri, 31 Jul 2020 19:44:51 +0000 Message-ID: <20200731194451.GA18275@ACM> References: <20200728183805.41537.qmail@mail.muc.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22348"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42581@debbugs.gnu.org, acm@muc.de To: Stephane A Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 31 21:46:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1ayq-0005j3-0s for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Jul 2020 21:46:12 +0200 Original-Received: from localhost ([::1]:43314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k1ayo-0000l8-Cn for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Jul 2020 15:46:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k1ayg-0000kp-8N for bug-gnu-emacs@gnu.org; Fri, 31 Jul 2020 15:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k1ayf-0006oS-Vk for bug-gnu-emacs@gnu.org; Fri, 31 Jul 2020 15:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k1ayf-00052G-Un for bug-gnu-emacs@gnu.org; Fri, 31 Jul 2020 15:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Jul 2020 19:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42581 X-GNU-PR-Package: emacs Original-Received: via spool by 42581-submit@debbugs.gnu.org id=B42581.159622470219276 (code B ref 42581); Fri, 31 Jul 2020 19:46:01 +0000 Original-Received: (at 42581) by debbugs.gnu.org; 31 Jul 2020 19:45:02 +0000 Original-Received: from localhost ([127.0.0.1]:38654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k1axh-00050k-Up for submit@debbugs.gnu.org; Fri, 31 Jul 2020 15:45:02 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:34280 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1k1axe-000500-JT for 42581@debbugs.gnu.org; Fri, 31 Jul 2020 15:45:00 -0400 Original-Received: (qmail 31327 invoked by uid 3782); 31 Jul 2020 19:44:51 -0000 Original-Received: from acm.muc.de (p4fe15eac.dip0.t-ipconnect.de [79.225.94.172]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Fri, 31 Jul 2020 21:44:51 +0200 Original-Received: (qmail 18418 invoked by uid 1000); 31 Jul 2020 19:44:51 -0000 Content-Disposition: inline In-Reply-To: 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-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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:183748 Archived-At: Hello, Stéphane. Just one little thing: could you please keep the buglist address in the Cc: when you reply, so that everybody can keep track of the conversation. Thanks. On Wed, Jul 29, 2020 at 10:28:07 +0200, Stephane A wrote: > On Tue, Jul 28, 2020 at 8:38 PM Alan Mackenzie wrote: > > In article you wrote: > > > [-- text/plain, encoding quoted-printable, charset: UTF-8, 41 lines --] > > > Hello, > > > Thank you for the advice :) I didn't know this one. > > > We have on *_EXPORT macro per module. So I would need to configure noise > > > macros by regexp. > > > I found *c-make-noise-macro-regexps *in the Emacs documentation > > > < > > https://www.gnu.org/software/emacs/manual/html_node/ccmode/Noise-Macros.html > > > but don't know how to set it up in my emacs file > > > since the > > syntax > > > is not documented. > > The syntax and semantics or regular expressions are documented > > thoroughly in the Emacs Lisp manual (elisp.info). > > The mechanics of the CC Mode hooks are similarly described in the CC > > Mode manual (ccmode.info). c-noise-macro-names can be either a list of > > strings (one of which would be "MY_EXPORT_DLL_MACRO") or just a regular > > expression, which you seem to need here. > > There is an example .emacs file in an appendix to the CC Mode manual. > > > I though of adding a call to the c++-mode-hook > > > . > > The c++-mode-hook would be an excellent place to make this setting, yes. > Following the CC mode example [1], I added (add-to-list 'c-noise-macro-names > "[:space:].+_EXPORT[:space:]") in the lambda of the c++-mode-hook [2], but > there's no difference of indentation in the code (I check with > linux/gnu/stroustrup styles). I don't know if I've done something wrong or > if this workaround does work. There are a couple of misunderstandings, here (for which I blame the documentation (largely written by me)). Firstly, the regexp must match the noise macro exactly, not also any spaces which may be around it, or anything like that. So your regexp should look something like: "[A-Z_]+_MACRO" ; which matches "MY_EXPORT_DLL_MACRO" or "MODULE_[A-Z_]_+EXPORT" ; which matches "MODULES_NAME_EXPORT". > Note: our macros are of the form MODULE_NAME_EXPORT. Also, your `add-to-list' form is mistaken. That would give you a one element list, that element being the regexp. What you need is the variable set to the regexp itself. For this, you want something like: (setq c-noise-macro-names "MODULE_[A-Z_]+_EXPORT") > [1] > https://www.gnu.org/software/emacs/manual/html_node/ccmode/Sample-Init-File.html#Sample-Init-File > [2] https://github.com/astephane/emacs/blob/master/emacs.el#L254 > Regards, > Stéphane -- Alan Mackenzie (Nuremberg, Germany).