* The fixing of bug#73182 - the indentation of enum structures in CC Mode
@ 2024-09-24 21:41 Alan Mackenzie
2024-09-25 4:43 ` tomas
0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2024-09-24 21:41 UTC (permalink / raw)
To: emacs-devel
Hello, Emacs.
In CC Mode, I've taken the liberty of fixing the indentation of enum
structures, so that (at least in "gnu" style) this indentation matches
the GNU coding standards. This is bug#73182.
The reasons for this are several:
(i) c-ts-mode and friends indent this way anyhow, so it will lead to
more consistency.
(ii) The enums in the Emacs sources are inconsistent anyhow, with around
35% of them "standard" and the other 65% the old CC Mode way.
(iii) The decision I took in 2014 not to fix this indentation, so as not
to introduce a chaotic mix of indentations, was mistaken. Even then,
this chaos already existed.
Just to be explicit, the "old CC Mode way" indented an enum as:
enum double
{
ONE,
TWO
};
, and the GNU standard way looks like:
enum double
{
ONE,
TWO
};
..
I have committed this change to master. I haven't yet written a NEWS
entry, which I intend to do tomorrow.
For anybody who still wants the old CC Mode way, I suggest one of the
following:
(i) In a CC Mode buffer, put point on an enum's opening brace, and do
C-c C-o. Accept the default, and as the new value, type in
"brace-list-open" (without the quotes).
(ii) In an appropriate place (late) in your .emacs/init.el, insert the
following:
(c-set-offset 'enum-open 'brace-list-open)
.
(iii) Create/edit a CC Mode style so that there is an entry in the
c-offsets-alist alist:
(enum-open . brace-list-open)
.
The above uses a new CC Mode feature, that of having a syntactic symbol
as the cdr of a c-offsets-alist entry. Full instructions can be found
in the CC Mode manual (which has also been updated).
I suggest that we do NOT immediately "correct" the indentation of the
65% of enums. Rather, we should fix them gradually, at the same time as
other changes get made to them, much the way we amend the indentation of
our code by tabs/spaces.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-25 4:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 21:41 The fixing of bug#73182 - the indentation of enum structures in CC Mode Alan Mackenzie
2024-09-25 4:43 ` tomas
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).