From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephane A Newsgroups: gmane.emacs.bugs Subject: bug#42581: Wrong C++ indentation when using class MY_DLL_EXPORT_MACRO foo Date: Mon, 3 Aug 2020 11:30:46 +0200 Message-ID: References: <20200728183805.41537.qmail@mail.muc.de> <20200731194451.GA18275@ACM> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cd34f505abf5cbfd" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27241"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42581@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 03 11:32:14 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 1k2WpK-0006yW-Bb for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Aug 2020 11:32:14 +0200 Original-Received: from localhost ([::1]:52686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k2WpJ-0007wk-5E for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Aug 2020 05:32:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k2Wp9-0007w2-I5 for bug-gnu-emacs@gnu.org; Mon, 03 Aug 2020 05:32:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k2Wp8-0006hW-6y for bug-gnu-emacs@gnu.org; Mon, 03 Aug 2020 05:32:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k2Wp8-0001Cw-2w for bug-gnu-emacs@gnu.org; Mon, 03 Aug 2020 05:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephane A Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Aug 2020 09:32:02 +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.15964470684579 (code B ref 42581); Mon, 03 Aug 2020 09:32:02 +0000 Original-Received: (at 42581) by debbugs.gnu.org; 3 Aug 2020 09:31:08 +0000 Original-Received: from localhost ([127.0.0.1]:44339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k2WoG-0001Bm-CY for submit@debbugs.gnu.org; Mon, 03 Aug 2020 05:31:08 -0400 Original-Received: from mail-io1-f51.google.com ([209.85.166.51]:33823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k2WoC-0001BG-7K for 42581@debbugs.gnu.org; Mon, 03 Aug 2020 05:31:07 -0400 Original-Received: by mail-io1-f51.google.com with SMTP id q75so29677465iod.1 for <42581@debbugs.gnu.org>; Mon, 03 Aug 2020 02:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hxnXc4F+gLgtgcQtKvid8ccBLeT2bcV8RaXDeNtjwds=; b=T0eI7XMVs4rZJXo4WPtUCT6JsQpGU5KX3a6Ks+xOTqwC00ivYAGxmBM+3ccZ1Knk00 KZAartYhn+794cq3keOfuz5vx3zdSOr64uZX8Gy98UK5SxzlTtBv5GjXZ54+sO4k+R1Q 7yeLgaZFYNCFctqEVoi9ODrGcWT5WCiRRhjKUyAxhzG/ooKbipGIVVdBAyY3u35Jttv2 DrgO4fZJYc8wQY9JAA6LJEMXB5cjlWh97DBjFkBz+ptlalxE8KWn3bmwsi5du4VmdHJ7 ndfk7ZTRgqWgZ4mFxL+QNGaP4IMQNIjld1DuxIU3C17lv21ut4oPspelGMwFq2+qBWO4 nEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hxnXc4F+gLgtgcQtKvid8ccBLeT2bcV8RaXDeNtjwds=; b=DZ/n2ASkuPyv39JcjtkzRse9GQxPy6AL3wRF9l9eIcwh8OxmojiCOEtlKAewwQBQ9I qFSaICgKg+L/h+rEV5LC3YjrWh/tH6Gj9N8RLJCBPLWSesQ4YPNP+z1MmCzC3R7/+aa0 L8aNN84NtS6OyysS8myniP/HzYyPrScKzADs8sewDM41cRkblSKfoTyCFJypg8tfYX2Y z8g9NP4bb5wGGotIWu5vX1aJ4k4sQbnBbXIGPIXhaAo6XT/Bwm5BdVmy2Bq96NKvWJ3K tWWOJ8C/LaG9iD6dCK86MDm1BvoFLXrtauMoM2imkRxK64C8svt1pZbFHbIYHBB5FBPf ntZA== X-Gm-Message-State: AOAM5320LSiFZHYTghj+MhCmFDo++Gd9ej3Tli9OSXAQA91k6YfuAGUg dxVmiEoYIKmBZ1kexmTc54MV53IwEdvUcBIj/SjFE+bE X-Google-Smtp-Source: ABdhPJzKDiX1r8u/xK6IRptKUWpvAFrTC00tIe7G0hr6JGDS5bhU+i4/6cUfDaOA/HTjVWqtyr339aDyKmCxmpPDwk8= X-Received: by 2002:a05:6638:27a:: with SMTP id x26mr18687586jaq.43.1596447058112; Mon, 03 Aug 2020 02:30:58 -0700 (PDT) In-Reply-To: <20200731194451.GA18275@ACM> 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:183925 Archived-At: --000000000000cd34f505abf5cbfd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Alan, Thank you very much for your help. I succeeded in configuring my CC-mode successfully :) One more question: How would I do to set a list of macros ignored using c-noise-macro-names ? Sorry, for the bug report. This is my first time. Regarding the bug, I noticed that if there's a class derivation, the indentation world correctly, e.g.: class MY_EXPORT foo : public bar { public: foo(); // Indentation OK here if ': public bar', NOK otherwise. }; Regards, St=C3=A9phane On Fri, Jul 31, 2020 at 9:44 PM Alan Mackenzie wrote: > Hello, St=C3=A9phane. > > 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.h= tml > > > > > 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 regul= ar > > > 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-Fi= le.html#Sample-Init-File > > [2] https://github.com/astephane/emacs/blob/master/emacs.el#L254 > > > > Regards, > > > St=C3=A9phane > > -- > Alan Mackenzie (Nuremberg, Germany). > --000000000000cd34f505abf5cbfd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Alan,

Thank you very m= uch for your help. I succeeded in configuring my CC-mode successfully :)

One more question: How would I do to set a list of m= acros ignored using c-noise-macro-nam= es ?

Sorry, for the bug report. This is= my first time.

Regarding the bug, I noticed that = if there's a class derivation, the indentation world correctly, e.g.:
c= lass MY_EXPORT foo : public bar {
public:
=C2=A0=C2=A0=C2=A0 = foo(); // Indentation OK here if ': public bar', NOK otherwise.
=
};

Regards,

St=C3=A9phane

On Fri, Jul 31, 2020 at 9:44 PM Alan Mackenzi= e <acm@muc.de> wrote:
Hello, St=C3=A9phane.

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 <acm@muc.de> wrote:

> > In article <mailman.208.1595954047.2739.bug-gnu-em= acs@gnu.org> you wrote:
> > > [-- text/plain, encoding quoted-printable, charset: UTF-8, 4= 1 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 con= figure noise
> > > macros by regexp.

> > > I found *c-make-noise-macro-regexps *in the Emacs documentat= ion
> > > <
> > https://www.gn= u.org/software/emacs/manual/html_node/ccmode/Noise-Macros.html

> > > but don't know how to set it up in my emacs file
> > > <https://github.com/astepha= ne/emacs/blob/master/emacs.el> 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).=C2=A0 c-noise-macro-names can be either a= list of
> > strings (one of which would be "MY_EXPORT_DLL_MACRO") o= r just a regular
> > expression, which you seem to need here.

> > There is an example .emacs file in an appendix to the CC Mode man= ual.

> > > I though of adding a call to the c++-mode-hook
> > > <https://github.com/as= tephane/emacs/blob/master/emacs.el#L245>.

> > The c++-mode-hook would be an excellent place to make this settin= g, yes.


> Following the CC mode example [1], I added (add-to-list 'c-noise-m= acro-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 someth= ing 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.=C2=A0 So your regexp<= br> should look something like:

=C2=A0 =C2=A0 "[A-Z_]+_MACRO" ; which matches "MY_EXPORT_DLL= _MACRO"
=C2=A0 =C2=A0 or
=C2=A0 =C2=A0 "MODULE_[A-Z_]_+EXPORT" ; which matches "MODUL= ES_NAME_EXPORT".

> Note: our macros are of the form MODULE_NAME_EXPORT.

Also, your `add-to-list' form is mistaken.=C2=A0 That would give you a = one
element list, that element being the regexp.=C2=A0 What you need is the
variable set to the regexp itself.=C2=A0 For this, you want something like:=

=C2=A0 =C2=A0 (setq c-noise-macro-names "MODULE_[A-Z_]+_EXPORT")<= br>
> [1]
> https://www.gnu.org/software/emacs/manual/html_node/ccmode/Sample-Init-Fi= le.html#Sample-Init-File
> [2] https://github.com/astephane/em= acs/blob/master/emacs.el#L254


> Regards,

> St=C3=A9phane

--
Alan Mackenzie (Nuremberg, Germany).
--000000000000cd34f505abf5cbfd--