* bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets
@ 2018-01-14 23:13 Gaétan Allaert
2018-01-19 18:01 ` Alan Mackenzie
0 siblings, 1 reply; 2+ messages in thread
From: Gaétan Allaert @ 2018-01-14 23:13 UTC (permalink / raw)
To: 30115
It is about an indentation issue in C++.
The closing curly bracket at the end of the function is wrongly indented
when:
1. at least one base_1 exists (the comma at the end of base_1 is
required);
2. base_2 is the last call before the opening curly bracket of the
function;
3. base_2 has only 1 argument that must be a symbol, not a literal or a
string.
Example:
foo_good::foo_good (int arg_1, int arg_2) :
base_1 (),
base_2 (arg_1, arg_2) {
} // good indentation
foo_bad::foo_bad (int arg_1, int arg_2) :
base_1 (),
base_2 (arg_1) {
} // bad identation
Thanks to have a look at this issue.
In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian built on trouble
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9.3 (stretch)
Configured using:
'configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs25:/etc/emacs:/usr/local/share/emacs/25.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --with-x=yes --with-x-toolkit=gtk3
--with-toolkit-scroll-bars 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/emacs25-wN2qS3/emacs25-25.1+1=. -fstack-protector-strong
-Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
-D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11
Important settings:
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix
Major mode: C++/l
Minor modes in effect:
show-paren-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent messages:
Mark set [2 times]
Replaced 2 occurrences
Saving file /home/allaert/bug.cpp...
Wrote /home/allaert/bug.cpp
(No changes need to be saved) [2 times]
Making completion list...
Quit
Mark set
Saving file /home/allaert/bug.cpp...
Wrote /home/allaert/bug.cpp
next-line: End of buffer
Load-path shadows:
/usr/share/emacs/25.1/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs25/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/25.1/site-lisp/slime/lib/ert hides /usr/share/emacs/25.1/lisp/emacs-lisp/ert
/usr/share/emacs/25.1/site-lisp/slime/lib/ert-x hides /usr/share/emacs/25.1/lisp/emacs-lisp/ert-x
Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils tabify dabbrev
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs multiple-cursors mc-hide-unmatched-lines-mode
mc-separate-operations rectangular-region-mode mc-mark-pop mc-mark-more
thingatpt mc-cycle-cursors mc-edit-lines multiple-cursors-core advice
rect solarized-theme solarized-definitions finder-inf package epg-config
seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv
edmacro kmacro cl-loaddefs pcase cl-lib paren cus-start cus-load
slime-autoloads haskell-mode-autoloads time-date mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 231074 14250)
(symbols 48 29159 1)
(miscs 40 95 375)
(strings 32 49655 7602)
(string-bytes 1 1441279)
(vectors 16 22232)
(vector-slots 8 568868 6249)
(floats 8 204 199)
(intervals 56 481 133)
(buffers 976 19))
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets
2018-01-14 23:13 bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets Gaétan Allaert
@ 2018-01-19 18:01 ` Alan Mackenzie
0 siblings, 0 replies; 2+ messages in thread
From: Alan Mackenzie @ 2018-01-19 18:01 UTC (permalink / raw)
To: Gaétan Allaert; +Cc: 30115
Hello, Gaétam/
On Sun, Jan 14, 2018 at 23:13:23 +0000, Gaétan Allaert wrote:
> It is about an indentation issue in C++.
> The closing curly bracket at the end of the function is wrongly indented
> when:
> 1. at least one base_1 exists (the comma at the end of base_1 is
> required);
> 2. base_2 is the last call before the opening curly bracket of the
> function;
> 3. base_2 has only 1 argument that must be a symbol, not a literal or a
> string.
> Example:
> foo_good::foo_good (int arg_1, int arg_2) :
> base_1 (),
> base_2 (arg_1, arg_2) {
> } // good indentation
> foo_bad::foo_bad (int arg_1, int arg_2) :
> base_1 (),
> base_2 (arg_1) {
> } // bad identation
> Thanks to have a look at this issue.
> In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
> of 2017-09-15, modified by Debian built on trouble
> Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
> System Description: Debian GNU/Linux 9.3 (stretch)
[ .... ]
Thanks for taking the trouble to report this bug, and thanks even more
for cutting your example down to a concise, easy to work with snippet.
It seems already to be fixed in the emacs-26 branch, the fix being for
an entirely different symptom, but appears to fix this, too.
It will be some time before Emacs 26 gets released. In the meantime,
can I ask you to apply the following patch to cc-engine.el in your Emacs
25.1 (in .../emacs/lisp/progmodes), compile it, and test it with your
real code. (If you want any help applying the patch or compiling the
file, feel free to contact me by private mail.) Would you please let me
know how well it solves the problem in your real code. Thanks.
--- cc-engine.20180119.eeel 2017-10-01 17:14:49.185254672 +0000
+++ cc-engine.el 2018-01-19 17:49:09.308202347 +0000
@@ -7615,8 +7615,10 @@
;; CASE 11
(when (and got-identifier
- (not context)
(looking-at c-after-suffixed-type-decl-key)
+ (or (eq context 'top)
+ (and (eq context nil)
+ (match-beginning 1)))
(if (and got-parens
(not got-prefix)
(not got-suffix)
@@ -8287,7 +8289,7 @@
(c-forward-objc-directive)))
(setq id-start
- (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))
+ (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil)))
(< id-start beg)
;; There should not be a '=' or ',' between beg and the
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-19 18:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-14 23:13 bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets Gaétan Allaert
2018-01-19 18:01 ` Alan Mackenzie
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).