Subject: bug#39891: 26.3; C++ indenting error

From: Alan Mackenzie <[email-masked]>
Date: Sat, 7 Mar 2020 11:05:35 +0000

Hello, altlockg

On Tue, Mar 03, 2020 at 22:58:26 +0100, [email-masked] wrote:

> I was trying to reindent my file, but got the error, visible in the
> recent messages below.

Thanks for taking the trouble to report this bug.

> I tracked it down to a single line, line 34 of the following file:
> https://pastebin.com/kVJATcsF
> The line containing "rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, ",
> to be exact.
> When I remove the newline before this line, the issue does not occur.

The bug has actually already been fixed in the CC Mode and Emacs
repositories, although the fix hasn't yet appeared in a released
version.

> I wouldn't have a clue on how to dig deeper, so that's why I'm sending
> you this report. If it helps, my configuration is available here:
> https://github.com/Altlock/EmacsDots

What is happening is that the older CC Mode isn't recognising the brace
on L33 as a block containing data fields, and tries to parse it as
though it contained statements.  It thus gets horribly confused.

To get your CC Mode working until our next release happens, would you
please apply the following patch to .../lisp/progmodes/cc-engine.el in
your Emacs 26.3:

diff -r 26668f1829ba -r cc69c3edb59b cc-engine.el
--- a/cc-engine.el	Fri Nov 10 17:28:29 2017 +0000
+++ b/cc-engine.el	Fri Nov 10 17:32:55 2017 +0000
@@ -12558,7 +12558,11 @@
 			    (save-excursion
 			      (goto-char containing-sexp)
 			      (c-looking-at-special-brace-list)))
-		       (c-inside-bracelist-p containing-sexp paren-state t))))
+		       (c-inside-bracelist-p containing-sexp paren-state t)
+		       (save-excursion
+			 (goto-char containing-sexp)
+			 (and (eq (char-after) ?{)
+			      (not (c-looking-at-statement-block)))))))
 	(cond
 
 	 ;; CASE 9A: In the middle of a special brace list opener.

Then, please byte-compile cc-engine.el, and replace the current
cc-engine.elc with the one you've just built.  This should fix the bug.
(If you want any help with applying the patch or byte compiling, feel
free to send me personal email.)

> Thank you for your time.

Again, thank you for the report.

> In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10)
>  of 2019-08-29 built on juergen
> Windowing system distributor 'The X.Org Foundation', version 11.0.12007000

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).