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: Fri, 14 Aug 2020 10:01:04 +0200 Message-ID: References: <20200728183805.41537.qmail@mail.muc.de> <20200731194451.GA18275@ACM> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000039fae605acd1d36f" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22020"; 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 Fri Aug 14 10:02:11 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 1k6UfD-0005Xx-CQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Aug 2020 10:02:11 +0200 Original-Received: from localhost ([::1]:47072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6UfB-0000Zs-W8 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Aug 2020 04:02:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6Uf4-0000ZW-4k for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 04:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k6Uf3-0001TS-RI for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 04:02:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k6Uf3-0004ml-Ou for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 04:02:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephane A Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Aug 2020 08:02: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.159739208518346 (code B ref 42581); Fri, 14 Aug 2020 08:02:01 +0000 Original-Received: (at 42581) by debbugs.gnu.org; 14 Aug 2020 08:01:25 +0000 Original-Received: from localhost ([127.0.0.1]:51705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6UeS-0004lq-Un for submit@debbugs.gnu.org; Fri, 14 Aug 2020 04:01:25 -0400 Original-Received: from mail-io1-f52.google.com ([209.85.166.52]:38295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6UeP-0004lZ-Ay for 42581@debbugs.gnu.org; Fri, 14 Aug 2020 04:01:23 -0400 Original-Received: by mail-io1-f52.google.com with SMTP id h4so9978576ioe.5 for <42581@debbugs.gnu.org>; Fri, 14 Aug 2020 01:01:21 -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=zhcxxe9URlJOh6KQxH/aTrwwkW6HtfJbbdR6L3xbO+s=; b=iGU+pg8G9ZRPOSZlIFgSsKaVrDtkPfWOtVXoH8mNxbpOiVu8qiNZkRWTpOih5IKPod pHAIvUWpb3sGl0G9eAdl/JfEmV2YX5B6Rw/84leqyy7FGYMjd1obmhbie0Acd3RRMKMd dsVGskumSv4ACvFdkQhjPkyh6/c4bZSCVprTAeFIk/oOLFxjYAeKDBHFTCya+BqHpJWF 6mCIn0JkuVaqQt3IBs3E7PL0o8APQLdzeGOrgFUwWpkUEuVAaUqaPuD3o3Ms1jGIVr2m NJLNDV3Io6fGR+7KOGWaCrnDpuKIyMm6Q3fs70N4DQU48CK/O1dEo51wC1TKhhCtk1Yt IR6Q== 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=zhcxxe9URlJOh6KQxH/aTrwwkW6HtfJbbdR6L3xbO+s=; b=GfvYKJxiYbJzo7/XAU5RBVDHfRldSs37qbFdsOJf09+PwDnZZhsDI9R30l65Jzrdbt +qLeP6IzUz8YfTHOLlDJUBFe1ITVYRko+u51yMDYN4m6grPPDYz9jBbr3Zvdcvp8p+nx NR134mvA3a62TeeFuu7TatR+xsv8c+Rw7uWBopzxAs5UhN1b2QVMSCZjlRSfTkniUBni CTsL8pyprgXUfuNX8qhaSRgXFlJ0mo3tbqBJDZsdfSPoSOJddUBZC+T9CCKXBbORIyEq fOIr+umXBXs+ld2yZXNK6QOz5dXv8mShXdbdvRUyg6QqfaswZNwKAurwc5ucx1SiDxZ4 ewtA== X-Gm-Message-State: AOAM532tj/UFRrOoqtu8YkykryNgbAqe64PtZi+KtK29LC76BlQ+jwnc Hv+Itrnm0WdB7oiRx2tEKnetrjvSB1hVpuR2V2Xn9jTjXBA= X-Google-Smtp-Source: ABdhPJySmOFj/30cX9Gj9mwRxS4QODIuaR5D3k4j5JmcTPHoIHZadxbolE/0egETg2Zt6McezpQHqwtIVuoNVplq5Hc= X-Received: by 2002:a02:7786:: with SMTP id g128mr1624987jac.45.1597392075487; Fri, 14 Aug 2020 01:01:15 -0700 (PDT) In-Reply-To: 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:185083 Archived-At: --00000000000039fae605acd1d36f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, The noise macro works for indentation, but it seems to cause the syntax highlight to not be done correctly when opening a file. I must edit the file to force refresh so that grammatical elements are detected. Regards, St=C3=A9phane On Mon, Aug 3, 2020 at 11:30 AM Stephane A wrote= : > 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 line= s >> --] >> >> > > > 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 th= e >> > > 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 wron= g >> 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-F= ile.html#Sample-Init-File >> > [2] https://github.com/astephane/emacs/blob/master/emacs.el#L254 >> >> >> > Regards, >> >> > St=C3=A9phane >> >> -- >> Alan Mackenzie (Nuremberg, Germany). >> > --00000000000039fae605acd1d36f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

The noise macro works= for indentation, but it seems to cause the syntax highlight to not be done= correctly when opening a file. I must edit the file to force refresh so th= at grammatical elements are detected.

Regards,

St=C3=A9phane


On Mon, Aug 3, 2020 at 11:= 30 AM Stephane A <a.stephane= .fsw@gmail.com> wrote:
Hello Alan,

Th= ank you very much for your help. I succeeded in configuring my CC-mode succ= essfully :)

One more question: How would I do to s= et a list of macros ignored using c-n= oise-macro-names ?

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

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

Regards,

St=C3=A9phane

On Fri, Jul 31, 2020 at 9:44 = PM Alan Mackenzie <acm@m= uc.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).
--00000000000039fae605acd1d36f--