GNU bug report logs -
#42581
Wrong C++ indentation when using class MY_DLL_EXPORT_MACRO foo
Previous Next
Reported by: Stephane A <a.stephane.fsw <at> gmail.com>
Date: Tue, 28 Jul 2020 14:04:02 UTC
Severity: normal
Tags: moreinfo
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42581 in the body.
You can then email your comments to 42581 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Tue, 28 Jul 2020 14:04:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stephane A <a.stephane.fsw <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 28 Jul 2020 14:04:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
There is a C++ indentation problem when using:
class MY_EXPORT_DLL_MACRO foo {
// with a
public:
foo(); // This line is not indented
// section.
};
The problem is not reproduced if, either:
- the "MY_DLL_EXPORT_MACRO" is removed; or
- the "public:" section is removed
Please find enclosed a sample C++ file containing the indentation problem
using different C++ styles (stroustrup, linux and gnu) and the following
emacs information.
Best regards,
Stéphane
[Message part 2 (text/html, inline)]
[emacs-cxx-indentation.txt (text/plain, attachment)]
[emacs-cxx-indentation.cpp (text/x-c++src, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Tue, 28 Jul 2020 14:33:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 42581 <at> debbugs.gnu.org (full text, mbox):
> From: Stephane A <a.stephane.fsw <at> gmail.com>
> Date: Tue, 28 Jul 2020 13:34:43 +0200
>
> There is a C++ indentation problem when using:
> class MY_EXPORT_DLL_MACRO foo {
> // with a
> public:
> foo(); // This line is not indented
> // section.
> };
>
> The problem is not reproduced if, either:
>
> * the "MY_DLL_EXPORT_MACRO" is removed; or
> * the "public:" section is removed
Does it help to add MY_DLL_EXPORT_MACRO to the list in
c-noise-macro-names?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Tue, 28 Jul 2020 16:34:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 42581 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
<https://github.com/astephane/emacs/blob/master/emacs.el> since the syntax
is not documented. I though of adding a call to the c++-mode-hook
<https://github.com/astephane/emacs/blob/master/emacs.el#L245>.
Regards,
Stéphane
On Tue, Jul 28, 2020 at 4:31 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Stephane A <a.stephane.fsw <at> gmail.com>
> > Date: Tue, 28 Jul 2020 13:34:43 +0200
> >
> > There is a C++ indentation problem when using:
> > class MY_EXPORT_DLL_MACRO foo {
> > // with a
> > public:
> > foo(); // This line is not indented
> > // section.
> > };
> >
> > The problem is not reproduced if, either:
> >
> > * the "MY_DLL_EXPORT_MACRO" is removed; or
> > * the "public:" section is removed
>
> Does it help to add MY_DLL_EXPORT_MACRO to the list in
> c-noise-macro-names?
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Tue, 28 Jul 2020 18:39:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 42581 <at> debbugs.gnu.org (full text, mbox):
In article <mailman.208.1595954047.2739.bug-gnu-emacs <at> gnu.org> 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
> <https://github.com/astephane/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). 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
> <https://github.com/astephane/emacs/blob/master/emacs.el#L245>.
The c++-mode-hook would be an excellent place to make this setting, yes.
> Regards,
> Stéphane
> On Tue, Jul 28, 2020 at 4:31 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>> > From: Stephane A <a.stephane.fsw <at> gmail.com>
>> > Date: Tue, 28 Jul 2020 13:34:43 +0200
>> >
>> > There is a C++ indentation problem when using:
>> > class MY_EXPORT_DLL_MACRO foo {
>> > // with a
>> > public:
>> > foo(); // This line is not indented
>> > // section.
>> > };
>> >
>> > The problem is not reproduced if, either:
>> >
>> > * the "MY_DLL_EXPORT_MACRO" is removed; or
>> > * the "public:" section is removed
>>
>> Does it help to add MY_DLL_EXPORT_MACRO to the list in
>> c-noise-macro-names?
>>
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Fri, 31 Jul 2020 19:46:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 42581 <at> debbugs.gnu.org (full text, mbox):
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 <acm <at> muc.de> wrote:
> > In article <mailman.208.1595954047.2739.bug-gnu-emacs <at> gnu.org> 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
> > > <https://github.com/astephane/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). 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
> > > <https://github.com/astephane/emacs/blob/master/emacs.el#L245>.
> > 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).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Mon, 03 Aug 2020 09:32:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 42581 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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éphane
On Fri, Jul 31, 2020 at 9:44 PM Alan Mackenzie <acm <at> muc.de> wrote:
> 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 <acm <at> muc.de> wrote:
>
> > > In article <mailman.208.1595954047.2739.bug-gnu-emacs <at> gnu.org> 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
> > > > <https://github.com/astephane/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). 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
> > > > <https://github.com/astephane/emacs/blob/master/emacs.el#L245>.
>
> > > 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).
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Fri, 14 Aug 2020 08:02:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 42581 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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éphane
On Mon, Aug 3, 2020 at 11:30 AM Stephane A <a.stephane.fsw <at> gmail.com> 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éphane
>
> On Fri, Jul 31, 2020 at 9:44 PM Alan Mackenzie <acm <at> muc.de> wrote:
>
>> 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 <acm <at> muc.de> wrote:
>>
>> > > In article <mailman.208.1595954047.2739.bug-gnu-emacs <at> gnu.org> 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
>> > > > <https://github.com/astephane/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). 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
>> > > > <https://github.com/astephane/emacs/blob/master/emacs.el#L245>.
>>
>> > > 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).
>>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Sun, 05 Dec 2021 01:04:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 42581 <at> debbugs.gnu.org (full text, mbox):
Stephane A <a.stephane.fsw <at> gmail.com> writes:
> 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.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
Skimming this bug report, it's not entirely clear to me what the actual
problem here is. If it's still a problem, could you post a recipe to
reproduce the problem, starting from "emacs -Q"?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 05 Dec 2021 01:04:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#42581
; Package
emacs
.
(Fri, 21 Jan 2022 13:39:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 42581 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Skimming this bug report, it's not entirely clear to me what the actual
> problem here is. If it's still a problem, could you post a recipe to
> reproduce the problem, starting from "emacs -Q"?
More information was requested, but no response was given within a
month, so I'm closing this bug report. If the problem still exists,
please respond to this email and we'll reopen the bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug closed, send any further explanations to
42581 <at> debbugs.gnu.org and Stephane A <a.stephane.fsw <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 21 Jan 2022 13:39:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 19 Feb 2022 12:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 61 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.