unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "Gaétan Allaert" <gaetan.allaert@belgacom.net>
Cc: 30115@debbugs.gnu.org
Subject: bug#30115: 25.1; cc-mode (C++) : bad indentation on function closing curly brackets
Date: Fri, 19 Jan 2018 18:01:36 +0000	[thread overview]
Message-ID: <20180119180136.GA6102__8979.08199481226$1516385324$gmane$org@ACM> (raw)
In-Reply-To: <87r2qsc9v0.fsf@deadstar.home.uk>

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).





      reply	other threads:[~2018-01-19 18:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20180119180136.GA6102__8979.08199481226$1516385324$gmane$org@ACM' \
    --to=acm@muc.de \
    --cc=30115@debbugs.gnu.org \
    --cc=gaetan.allaert@belgacom.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).