From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 15:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 64133@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168701425732422 (code B ref -1); Sat, 17 Jun 2023 15:05:01 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jun 2023 15:04:17 +0000 Received: from localhost ([127.0.0.1]:52271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXTN-0008Qp-Du for submit@debbugs.gnu.org; Sat, 17 Jun 2023 11:04:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:45556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXTJ-0008Qf-HC for submit@debbugs.gnu.org; Sat, 17 Jun 2023 11:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAXTI-0001aC-K1 for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 11:04:12 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qAXTE-0004Ql-MW for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 11:04:12 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666e6ecb52dso636539b3a.2 for ; Sat, 17 Jun 2023 08:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687014230; x=1689606230; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=HJsH+vKBbEP06bXCFs+lwhVzcxSyFGVNU09UzBBIgJw=; b=qMH6ZJJrcXa3PjgB+gF6smJhLTMD4V2OIoPp5TttnNF3fjeYzn1m+lAxkOl2BqwkWn 5JXNyGUAS/4ojyUica6D7WHKNvP1pI+YEhHnDIVtjEkpTHZooTxWZ3Is9g/ajgJUt/fz 32QJ5CaM4ZYAbZ76P0S98/gHi2yfbLl4gL2osgRJsejvIppYXBDTPPgZHA/VuC4ncwMZ MD2KQj3cW9o9pTqYsiGUj1wj0jC9lAxAqKi4v/9ADFwttpDzEV8PjVsNv9jqZ6hJH2vR igFpejqIdFk4sPwMKZKAeqgKnZufKofeKMXFWSyKyEIQb0iRqM1cx5x1G3IYgSG8/+0G Jgjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687014230; x=1689606230; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HJsH+vKBbEP06bXCFs+lwhVzcxSyFGVNU09UzBBIgJw=; b=A0iKbysnS2Jbh589SHOOZt39qwIOKRdyPpMiT7eWf8B81L5NfQ9s+WS5hakUY26U5Z Q5WrcStalZyNknX2soLwOuCix1sfai1H2WugjhPqIdd+0adfLlfi1aCGSHWcdxGKXJt1 Ln84HZDdiQDscudzee/BOo+SLK1buvmwdgtT2fD65eQCr5YNpR1KFcjCJIUxrpijGb+b YbFIQWsqWm2F3KY3IipdV1w+gu2AHLptRm+NCmd/x3CSRrhRle8e3dE/hdqG2e+L8wpe jKmHuHWJ5Mv5yYXKSTVHWwEij1QGhrByvkBpJa7Zh7d44q7hICxD8/2SK+6dpldGOAQr NnrQ== X-Gm-Message-State: AC+VfDyCKH0RblcH4cxXaI1rsZG6iAM2rfuSw26uvd+0OvkdygMHRK15 z6eELYmBF3CZ4vL0D1kSvuqv2vzIAuHiTZ3DNXbPSGoe8kM= X-Google-Smtp-Source: ACHHUZ5OEaFC7qAedYj+JxgQafAXzcDKW1HSm3yRmlxWIOftqrqFziGITFKGHnQSuBqU6GqhqD7ptWWkhHhoVM620Rk= X-Received: by 2002:a17:90a:fe8d:b0:255:b1d9:a206 with SMTP id co13-20020a17090afe8d00b00255b1d9a206mr2927991pjb.22.1687014230069; Sat, 17 Jun 2023 08:03:50 -0700 (PDT) MIME-Version: 1.0 From: Jeff Norden Date: Sat, 17 Jun 2023 10:03:24 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=norden.jeff@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) I've verified the following behavior with c-version 5.35.2 (emacs-29, and emacs-30 from git) and with 5.35.1 (emacs 28.2). Place the following text into a file with a ".c" extension, and load it with "emacs -Q". ========================================== #include struct three_ints { int a, b, c; }; int main () { struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; for (int i=0; i to indent the line. It will be incorrectly indented 2 spaces more than the previous line. Move to the next line, press , and you'll see: struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; Just using to re-indent the lines will not change anything. But, if you add or delete white-space before {0,1,2} or {3,4,5} and press , it *may* fix things. It seems to depend on just what you delete and where the cursor is. The pattern isn't clear to me. Once fixed, you get: struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; At this point it is stable, and will work correctly. If you restart c-mode with "M-x c-mode", the problem re-occurs. This bug only seems to occur when a loop or similar construct occurs after the array declaration/initialization. It doesn't need to immediately follow, though. When incorrectly indenting, "C-c C-s" shows 'defun-block-intro' syntax for the {0,1,2} line, and 'substatement-open' for {3,4,5} and {4,5,6}. Once it gets fixed, this changes to 'brace-list-intro' and 'brace-entry-open'. ========================================== For a more "real world" example, start with the example program at the end of the getopt_long(3) man page: https://linux.die.net/man/3/getopt_long and move the declaration of long_options[] from inside the while loop to before it. (This makes long_options a global variable, instead of local to the loop). ========================================== I'm afraid I can't offer a patch or suggestion for a fix. My own attempts at "parsing" the lisp in cc-engine.el come to an abrupt halt when my brain receives an urgent "Warning! Meltdown imminent!" message from my subconscious -- just kidding :-). However, I did stumble upon the following in the comments for the `c-inside-bracelist-p' function: ;; CONTAINING-SEXP is the buffer pos of the innermost containing ;; paren. NO IT ISN'T!!! [This function is badly designed, and ;; probably needs reformulating without its first argument, ... Thanks, -Jeff ---------------------------- If believing that "function is more important than form" and that "people are more important than technology" makes me a Luddite, then so be it! From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 15:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jeff Norden Cc: 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.16870148891097 (code B ref 64133); Sat, 17 Jun 2023 15:15:01 +0000 Received: (at 64133) by debbugs.gnu.org; 17 Jun 2023 15:14:49 +0000 Received: from localhost ([127.0.0.1]:52297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXdZ-0000Hd-14 for submit@debbugs.gnu.org; Sat, 17 Jun 2023 11:14:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXdU-0000HN-UV for 64133@debbugs.gnu.org; Sat, 17 Jun 2023 11:14:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAXdM-00070S-TA; Sat, 17 Jun 2023 11:14:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=e4XT5dYE71EagPHZvp/4i7fgGsEuSGaArZtm/hM/VD4=; b=CnSlo0sRV6Gr uI3+/ZLmE+airbXtNth0trdWD5tKAx3RGAqFzI7yVI5/BOGhdWJNOIg+7y5zKP0HzM8VVlH/va4fq d2goiN7DH4I/txlYDBK6Dv43eMe0l7a+Qopp8wzcEJfDZh2rR0prEf1Gl+d3ExS2sWgvdz9q3FqxW JKi+IK8YqJJnug2j2W/Q46yTYt3bm9CiARPx1s979bsvc6EBEBw5QFopAGPi8nQi57GOpvMZ1ViMS M66IlXLOkU7tlI5Sz9NjZC0exu0ZXsSk7P8pOAQ5GASWsDlorghNG68MtbuyGdT8mrE8LpXUQZ6Qs GNYs8vNDSqlSlqmiC+RfEA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAXdL-0008SP-BW; Sat, 17 Jun 2023 11:14:35 -0400 Date: Sat, 17 Jun 2023 18:14:34 +0300 Message-Id: <831qiaqfxh.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Jeff Norden on Sat, 17 Jun 2023 10:03:24 -0500) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Jeff Norden > Date: Sat, 17 Jun 2023 10:03:24 -0500 > > I've verified the following behavior with c-version 5.35.2 (emacs-29, > and emacs-30 from git) and with 5.35.1 (emacs 28.2). > > Place the following text into a file with a ".c" extension, and load > it with "emacs -Q". > ========================================== > #include > struct three_ints { > int a, b, c; > }; > int main () { > struct three_ints numbers[]= { > {0,1,2}, > {3,4,5}, > {6,7,8} > }; > for (int i=0; i printf("ack "); > } > printf("\n"); > } > ========================================== > Move the cursor to the beginning of the line with {3,4,5} and press > to indent the line. It will be incorrectly indented 2 spaces > more than the previous line. Move to the next line, press , > and you'll see: > > struct three_ints numbers[]= { > {0,1,2}, > {3,4,5}, > {6,7,8} > }; This source code uses the 'linux' indentation style, so you should do M-x c-set-style RET linux RET after which the problem goes away, AFAICT. From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 16:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jeff Norden , Alan Mackenzie Cc: 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.16870192485362 (code B ref 64133); Sat, 17 Jun 2023 16:28:01 +0000 Received: (at 64133) by debbugs.gnu.org; 17 Jun 2023 16:27:28 +0000 Received: from localhost ([127.0.0.1]:52511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAYls-0001OQ-GH for submit@debbugs.gnu.org; Sat, 17 Jun 2023 12:27:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAYlp-0001OA-D3 for 64133@debbugs.gnu.org; Sat, 17 Jun 2023 12:27:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAYlk-00037I-1H; Sat, 17 Jun 2023 12:27:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ckO69DdgZMHadWNODjPwoFq0eG9PktQAoN0rhG43Tnk=; b=AQiHsH9fLOAT Qi+XxQjYF3W+wfqok9zP/N/v6vRjl9XKtMtAOqrDaLASDSrpSIJMvJTrYhuV4j0FBtkyTwihFkOfh iOtCIF6UpF9kaNH7ORaV/XmrjMTpvCByX8sIbOeSsgMY6xLf/ISHuchH/j4+ymd5+uO6YIIebcXF4 fjpvRIvCUO/w8hyUza+15CK9HCWjXnTnRLQZ/RwMZ6RIQaP+BUXFyWwz9mU52I/utH/SrmTuuafxr mSETBZ9JBQPslZn1wR4p8hswPWFZHAYgyxjUnPXD+6cWKgghDbrSUm9L/qDdktXLOaj/COKCr3Rpn wrwJvPYS4rqQLaaSCcVA9A==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAYlh-0004iE-RU; Sat, 17 Jun 2023 12:27:19 -0400 Date: Sat, 17 Jun 2023 19:27:16 +0300 Message-Id: <83y1kioxzv.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Jeff Norden on Sat, 17 Jun 2023 10:43:40 -0500) References: <831qiaqfxh.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Jeff Norden > Date: Sat, 17 Jun 2023 10:43:40 -0500 > > > This source code uses the 'linux' indentation style, so you should do > > > > M-x c-set-style RET linux RET > > > > after which the problem goes away, AFAICT. > Eli: Thanks for the quick response. Changing the style works for me, > so this can be closed. > I didn't realize that the style effects parsing, not just the way > space, etc gets inserted by default. Thanks, I will let Alan chime in and decide whether this should be closed. From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: Alan Mackenzie , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.168702342612851 (code B ref 64133); Sat, 17 Jun 2023 17:38:02 +0000 Received: (at 64133) by debbugs.gnu.org; 17 Jun 2023 17:37:06 +0000 Received: from localhost ([127.0.0.1]:52582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAZrF-0003LC-Sn for submit@debbugs.gnu.org; Sat, 17 Jun 2023 13:37:06 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:62846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAZrD-0003Ka-GJ for 64133@debbugs.gnu.org; Sat, 17 Jun 2023 13:37:04 -0400 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1b4f8523197so21096875ad.1 for <64133@debbugs.gnu.org>; Sat, 17 Jun 2023 10:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687023417; x=1689615417; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=b+/NiHmLgsujgnWy0thPSGP0NfuiOqsJw017AJcWGyw=; b=c6Ju8/qor6ebNE44yCjDg3oP0vWO2x3l9/1SoSMzEtYkpUD0TKgL7kIgLi9s+tKcjO aIWzKXhsYFW4LOB4DHjVeQ25jRDV2d6jJpFxTr9lC7BDy3XuU2wzvgItwYJI8VXGSDl2 r61WNuDUC3dhx7Mbs5SMJQg0YHvgF7tP5HPr7/llw/STwaI8XK31PBphuTdW7BKIJD9k 7WY0JMd3rD2tDnZapxzS8k/30Nxm6eB1opFURuMclcRKVTdHCOKCz+auQWTFjmxnQnmA 2wzqgAZJNwU0T+Vavl08EANzRLhKad4O//acCUT7/iJtpDWETCNeWUZwGpU35HhKSpif REFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687023417; x=1689615417; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b+/NiHmLgsujgnWy0thPSGP0NfuiOqsJw017AJcWGyw=; b=F45vwwytzmIpqfwfZC27qFZMIpioaHU5GvisapnyrnpVXktJRd/segPc9oNOb8fop3 uMrGNlhd/bW+zDjkRpHNWYELb4McIcXm8xrX+ljx18bfusMv0tpU8p8yXD9/Rh5u0QpQ Q2asNVgzbfun7560ZRjZAY5Tg3QZXfeS/5eJqeZijXZjakUxYFmLPL5Z81uJsQFxnSTK tWdi5NuDuvEsuSUKWw0Fs3zuSqVHmlPFE82RGzsXNEP6LYbt875heXm07CsOnMsTv7Yp UQvwKDMIhjs88lFXQ2pKHWOie2CZCHaIJOoeTyOCCMXMHNURF+WYSms067fDzHz8UJCO HuRg== X-Gm-Message-State: AC+VfDzDhW5lvbVX++yyHlHPhhmlBS5RGL9qR0DqG0pdElM9P9Dd2Sqt y/fpxtUBDUYs5aZu7cS310FjCNWRu1Mehf8WWIcKrgjqg9Q= X-Google-Smtp-Source: ACHHUZ6TwNBbn9jah20Gtd1HIWE8F1fuVifRz5ZnspLAE7GePTONJNZ1UDLde3nQ/rN+Hfp4nhrYFx7Mt7Qe/hrC90A= X-Received: by 2002:a17:903:22c4:b0:1b1:1168:656b with SMTP id y4-20020a17090322c400b001b11168656bmr7866714plg.26.1687023417201; Sat, 17 Jun 2023 10:36:57 -0700 (PDT) MIME-Version: 1.0 References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> In-Reply-To: <83y1kioxzv.fsf@gnu.org> From: Jeff Norden Date: Sat, 17 Jun 2023 12:36:30 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, Jun 17, 2023 at 11:27=E2=80=AFAM Eli Zaretskii wrote= : > Thanks, I will let Alan chime in and decide whether this should be > closed. Actually, I now think that changing the style works because the gnu style has (substatement-open . +) in c-offsets-alist, while linux uses (substatement-open . 0). With either style, I initially get substatemnt syntax from "C-c C-s", which changes to brace-list when I delete space and re-indent. This issue *doesn't* occur if the opening brace is on its own line, and it looks like most styles other than gnu do not indent sub-statements. So, I still think this bug can be closed, but maybe the resolution could be "mostly harmless" :-). From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Jun 2023 13:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jeff Norden Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.16870940462142 (code B ref 64133); Sun, 18 Jun 2023 13:15:02 +0000 Received: (at 64133) by debbugs.gnu.org; 18 Jun 2023 13:14:06 +0000 Received: from localhost ([127.0.0.1]:53510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAsEI-0000YU-6w for submit@debbugs.gnu.org; Sun, 18 Jun 2023 09:14:06 -0400 Received: from mx3.muc.de ([193.149.48.5]:59577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAsEF-0000Xs-RW for 64133@debbugs.gnu.org; Sun, 18 Jun 2023 09:14:04 -0400 Received: (qmail 8911 invoked by uid 3782); 18 Jun 2023 15:13:57 +0200 Received: from acm.muc.de (p4fe157ae.dip0.t-ipconnect.de [79.225.87.174]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 18 Jun 2023 15:13:57 +0200 Received: (qmail 15065 invoked by uid 1000); 18 Jun 2023 13:13:56 -0000 Date: Sun, 18 Jun 2023 13:13:56 +0000 Message-ID: References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Jeff Thanks for taking the trouble to report this bug. On Sat, Jun 17, 2023 at 12:36:30 -0500, Jeff Norden wrote: > On Sat, Jun 17, 2023 at 11:27 AM Eli Zaretskii wrote: > > Thanks, I will let Alan chime in and decide whether this should be > > closed. I think, not yet. > Actually, I now think that changing the style works because the gnu > style has > (substatement-open . +) > in c-offsets-alist, while linux uses (substatement-open . 0). With > either style, I initially get substatemnt syntax from "C-c C-s", which > changes to brace-list when I delete space and re-indent. > This issue *doesn't* occur if the opening brace is on its own line, > and it looks like most styles other than gnu do not indent > sub-statements. So, I still think this bug can be closed, but maybe > the resolution could be "mostly harmless" :-). I've edebugged through c-guess-basic-syntax and subroutines, and it's now clear there's a bug in the handling of a cache. The cache, called c-laomib-cache (with "laomib" standing for "looking at or maybe in bracelist") speeds up the handling of very large brace lists which frequently occur in generated .h files. Without the cache, these would have to be scanned over repeatedly, which made C Mode very slow for these files. I think I should be able to fix this in the next day or three. -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Jun 2023 16:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.168710468022440 (code B ref 64133); Sun, 18 Jun 2023 16:12:02 +0000 Received: (at 64133) by debbugs.gnu.org; 18 Jun 2023 16:11:20 +0000 Received: from localhost ([127.0.0.1]:54871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAuzn-0005ps-Il for submit@debbugs.gnu.org; Sun, 18 Jun 2023 12:11:19 -0400 Received: from mail-pf1-f172.google.com ([209.85.210.172]:47316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAuzm-0005pe-JP for 64133@debbugs.gnu.org; Sun, 18 Jun 2023 12:11:19 -0400 Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6686ef86110so202602b3a.2 for <64133@debbugs.gnu.org>; Sun, 18 Jun 2023 09:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687104672; x=1689696672; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7c9NH02r9F0NKGKWPH74F41S1OP7zqijvv6MNbSVf6w=; b=MZwbITIEDoGrlfuC+hRmhrW9+XLLkHHWsRSUHrcm+0yO8NGxHme5CBXsKkMzezDNc6 GBd/F29ceYLzmsKYv0mPVTN/RAYSOdPtSiOTlEurqnRgAZ+cIKBpMINld/5ptRs9W2Ok wugIV3Q55X0pFtaB1OPQQV/meWseYTC90wiu0kqz2GpGydjjZ9nfty3dnsp4iwkd0xwu luNAR8/YLKoc3xQ5lwQQVz+H93m8+sSAiboELokqnluZbjUZAvCFtzowgPfSrmX3t1l6 3OF0u+F24tRFCqMCyTg7t0c5CrRgUD0FJJs5oeOkXB+psV3Yu31eXrgvIC1LVXpAMUya dr2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687104672; x=1689696672; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7c9NH02r9F0NKGKWPH74F41S1OP7zqijvv6MNbSVf6w=; b=DwMxQ+VvWqkHku7wLiTCRtJfUsbYKnASQDerF4KNiNJK3ESX47tX3oz5SbGVwTMJ8O k1sCGvzHr1/EjeRpQTFnIkYJR5GlEMwltbw32Hndx4WcX3jgd1Xd453bC9SWtQ2AxewR zH6EPf+b2KabJcWLwois4/k8rQC5CvpFQWpYhTXjsJh/DHPZ7WtqHXY4OVfHeTPbPQ6V eCqEpsALWFO+E6ztfuVfP6YOsIyPYMPXNkfIw8WaV2ca2bdqCmcC+rGZwwtDKkmhTBNv bUguDb3dBUJkbxfRwBDGJG4ibuW05EbQNtHsAiF0KTHh+CjxjvEteyDecEbqA5wN8rS8 1miQ== X-Gm-Message-State: AC+VfDw5zpCE7MNg+04F21dfMyVL4wEs3DxZUOU9OSH1tvz4KwdWB8V7 KoIAJaZKK9r9KW2Kk2goIJ3of3Rs9l8hJMTMEm4= X-Google-Smtp-Source: ACHHUZ605N41+bkUAGxGSg50sNySzdK2AYVUp4jSR3GqzPFfmjeLWjqoBnRW4O0kix+BlwfxgF3E+VurzbFcvbPR83k= X-Received: by 2002:a05:6a21:370a:b0:10c:5ff4:8bc6 with SMTP id yl10-20020a056a21370a00b0010c5ff48bc6mr3836979pzb.38.1687104672415; Sun, 18 Jun 2023 09:11:12 -0700 (PDT) MIME-Version: 1.0 References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> In-Reply-To: From: Jeff Norden Date: Sun, 18 Jun 2023 11:10:46 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, Jun 18, 2023 at 8:13=E2=80=AFAM Alan Mackenzie wrote: >... > > > Thanks, I will let Alan chime in and decide whether this should be > > > closed. > > I think, not yet. >... > I think I should be able to fix this in the next day or three. Hi Alan I don't know if this might help, but here is one more thing I found, which I can't explain at all. Tab is normally bound to c-indent-line-or-region. You can't directly re-bind tab to c-indent-line. However, if you create an interactive version with: (defun cil() (interactive) (c-indent-line)) and bind it to tab, it has the exact same behavior. This eliminates several levels of function calls between c-indent-line-or-region and c-indent-line. So, if you open the example with emacs -Q, define cil and bind it to tab with "M-x local-set-key", you can "fix" the syntax by moving to the beginning of the {3,4,5} line and pressing: At this point "C-c C-s" shows brace-list syntax. BUT, if you start again, and instead of defining "cil', just replace each with "M-: (c-indent-line)", it does *not* change the syntax that "C-c C-s" shows. For some reason that I don't understand, it seems that the minibuffer read affects the behavior. To see this, change the defun for "cil" by adding: (read-from-minibuffer "press ") after (interactive). You now need to hit after each , but I *cannot* get the syntax for the line to change with this function. -Jeff From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Jun 2023 17:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.16871090727681 (code B ref 64133); Sun, 18 Jun 2023 17:25:01 +0000 Received: (at 64133) by debbugs.gnu.org; 18 Jun 2023 17:24:32 +0000 Received: from localhost ([127.0.0.1]:54915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAw8e-0001zp-C3 for submit@debbugs.gnu.org; Sun, 18 Jun 2023 13:24:32 -0400 Received: from mail-pf1-f169.google.com ([209.85.210.169]:60825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAw8c-0001zc-Id for 64133@debbugs.gnu.org; Sun, 18 Jun 2023 13:24:31 -0400 Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-666eef03ebdso449527b3a.1 for <64133@debbugs.gnu.org>; Sun, 18 Jun 2023 10:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687109064; x=1689701064; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vq+UDoFruZeCajWSK2aOSdKC/p143HJhkk0MY4wrjPo=; b=RDoh+p0n8d9UhfbnkuRRbqBq+l0xjKC0+HDASBq9E3FwYAB66TgTij4j9E7vTqrLQ/ uPtXfYP/TvfnCeA8JPPrME3Og2zgWTTDG+3YCM1YoNvUEJiTYYNJDp0Jhr36Vz5hnzC9 VmeYVXiFBYLL03W59SDfXS2HIsFblPZsvuvcw0UaDv5k7OTDNxhqGu+pEqaoM+jxqxmX njKJ89MBWOOtH2avzcR2JCzHnf1IGuA7TEuZEBBXXPOUVtieC/+f1dxKKt6+uVgPsFGU kP0U+bHg4z790rB1YgfJmRN4wxoMDyz+MCjhvvlG4J9ZtGN9JPvj1064DCAzXH8oURwD JEKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687109064; x=1689701064; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vq+UDoFruZeCajWSK2aOSdKC/p143HJhkk0MY4wrjPo=; b=IE2SYa6smqodDPzBVtWymp5kpYeymhabori8WCgUcfEs/sP1d95aPuLyWQO55hCf2Q mecnaM+7ELgZ0wJWAaZXtXexFwSY7QWIHWVO8VAF5wkuBM2mo1JjCgul6/1OfslyGT3t yHcsaXDHoon3fmau32mVqZtdbDfHrQ+nb39MFKNZyd/denN0xOh7c4ItC1/uGHKbfAy+ FJaIcrlcz5wfcgg4ebr7IX6pEaFVMMAwjs3BWwDAiLoApelP7YVnv7m2eC7ClKntvC5z PQmmPJHT8mMuZxFa1fR9YO3aXDYo8Gv9tRaT2/vX3vfMfcDvJ+v28jCVFdR0VQSpU69U UBUQ== X-Gm-Message-State: AC+VfDyGYyNjRT76hjCA+m3lh3Bh0qH9abP0qmr3O52PW++xb/n79XmO 1yjUkDWtIpdfHz+i9faprAkhH+lroMPU87Mmqzk= X-Google-Smtp-Source: ACHHUZ4CpCX7TpIcqyzFP2Ltaf80gHJS4HdsW1ntqeOivc9Ynx82ewQ6WFUjMRjrSKq7WfIqdRJkvjlKmiAXj/yNxk0= X-Received: by 2002:a05:6a20:3955:b0:106:c9b7:c932 with SMTP id r21-20020a056a20395500b00106c9b7c932mr5911103pzg.1.1687109064501; Sun, 18 Jun 2023 10:24:24 -0700 (PDT) MIME-Version: 1.0 References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> In-Reply-To: From: Jeff Norden Date: Sun, 18 Jun 2023 12:23:58 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) The only reason the minibuffer-read affects things is timing. This seems obvious now, but somehow it didn't occur to me until after I sent the previous message. If I do ..wait a few seconds.. then the syntax does *not* change to brace-list. I tried changing c-progress-interval, but that didn't seem to affect things. Maybe there is another timer, or maybe a race condition involved somehow. Hope this helps, -Jeff From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2023 11:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jeff Norden Cc: acm@muc.de, Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.168717520117733 (code B ref 64133); Mon, 19 Jun 2023 11:47:02 +0000 Received: (at 64133) by debbugs.gnu.org; 19 Jun 2023 11:46:41 +0000 Received: from localhost ([127.0.0.1]:55654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBDLF-0004bx-3o for submit@debbugs.gnu.org; Mon, 19 Jun 2023 07:46:41 -0400 Received: from mx3.muc.de ([193.149.48.5]:43285) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBDLD-0004bf-6a for 64133@debbugs.gnu.org; Mon, 19 Jun 2023 07:46:39 -0400 Received: (qmail 89611 invoked by uid 3782); 19 Jun 2023 13:46:32 +0200 Received: from acm.muc.de (p4fe15cec.dip0.t-ipconnect.de [79.225.92.236]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 19 Jun 2023 13:46:32 +0200 Received: (qmail 6266 invoked by uid 1000); 19 Jun 2023 11:46:32 -0000 Date: Mon, 19 Jun 2023 11:46:32 +0000 Message-ID: References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Jeff. On Sun, Jun 18, 2023 at 12:23:58 -0500, Jeff Norden wrote: > The only reason the minibuffer-read affects things is timing. This > seems obvious now, but somehow it didn't occur to me until after I > sent the previous message. If I do > ..wait a few seconds.. > then the syntax does *not* change to brace-list. I tried changing > c-progress-interval, but that didn't seem to affect things. Maybe > there is another timer, or maybe a race condition involved somehow. No, I think it really is the cache bug I mentioned in my last post. Caches are wonderful things when they work properly, but the utter devil to debug when they don't. I've currently got a CC Mode version with this cache corrected, such that it parses your test file correctly, but I want to make sure the correction is correct before I send you a patch and release the fix. I'll be back again soon. > Hope this helps, > -Jeff -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Jun 2023 14:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.16871850843638 (code B ref 64133); Mon, 19 Jun 2023 14:32:02 +0000 Received: (at 64133) by debbugs.gnu.org; 19 Jun 2023 14:31:24 +0000 Received: from localhost ([127.0.0.1]:56945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBFud-0000wc-Kw for submit@debbugs.gnu.org; Mon, 19 Jun 2023 10:31:23 -0400 Received: from mail-pl1-f178.google.com ([209.85.214.178]:58570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBFub-0000wI-08 for 64133@debbugs.gnu.org; Mon, 19 Jun 2023 10:31:21 -0400 Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1b55bc0c907so12559025ad.0 for <64133@debbugs.gnu.org>; Mon, 19 Jun 2023 07:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687185075; x=1689777075; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4LHasMG5M351+JeYB5/eEhxqcMhL4XWtOOxoQXotgx4=; b=PzR2SdgzP8qL0neIanwDK7N5UOZ8Nw39A8uNvKyEYDSUcQJtsjZ2etu/gZmTbiJOJ4 mkPEpHij6M+Q0wkmWXrO43KEKVUnG1YsuWNu90cxFN3WY9pfxuMO/+wy+q9CPgqMkVbk oqvdZDLaqikwNRtUyVFB1y9rOepeSAeGM003AEeitHSeGN6ezOxBfravuAVP0F3LVgIQ AOsWuoO98l9AkhUMR6YiZ+qlq7mZ22N+p1I1Qc/9VKFmk90+KK7/E6r1jfvGOT/VaAcQ GVofr6dvNss49PAfh/ryK/aBnrpNao4PRcxWO+qYiLBUoIIMABX/pH0gosOzP5tOrBUa kW2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687185075; x=1689777075; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4LHasMG5M351+JeYB5/eEhxqcMhL4XWtOOxoQXotgx4=; b=WFpyZ2XAuV5bGs2mutC5YmGgXCukdIYzfoFbaOi3zWZob6QinPvr1A8YQIxq4hQiKy YOyoev2qJFv/XO25vlb51GoMP+5PS14NMVa0YC4/SbfkMXHpntlYHu95OT0j8j2prCLY bxn3QlLML92sQOf27169z5/N4ZO3QwzPr4eaZF56OZcPWn9DDxjZpbACu0H+78NiwuGc /CobCBLhjiGLKTjRVhEwyoIEL/51kLHSA4tx6eLDwwCMzHMdBSG8FZJJUZJ5DV03q6yB MG+W+QobVKwHxdpouPs1kHOlXTszHDOoZho52hi2BVrYCVgZAMwGYK5Hx+jzblrVB2Ym 4uPA== X-Gm-Message-State: AC+VfDxkGgR5Ol1vHrtWjJyPLBz1IzCyhrYFa4onQJRJ6fehnYEGPTCr /R1z5/Dlta/Y6AAP/pyPlFS6EOVj8E9YWF3Y2cNDHhXbPZXbNA== X-Google-Smtp-Source: ACHHUZ7SX5ssq6eoLwXRh2z14qFLoPt3TBd1K04tmHY8KpT/fagXAIE7s2oMo+KGMiFdIWBL/MezypBy0N9Txe4EkJo= X-Received: by 2002:a17:903:1208:b0:1a5:150f:8558 with SMTP id l8-20020a170903120800b001a5150f8558mr11014448plh.17.1687185074758; Mon, 19 Jun 2023 07:31:14 -0700 (PDT) MIME-Version: 1.0 References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> In-Reply-To: From: Jeff Norden Date: Mon, 19 Jun 2023 09:30:48 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, Jun 19, 2023 at 6:46=E2=80=AFAM Alan Mackenzie wrote: > No, I think it really is the cache bug I mentioned in my last post. I agree. In fact, a "brute force" fix is to use advice-add to reset c-laomib-cache to nil before each call to c-indent-line. What puzzled me is that certain buffer changes also fix the issue, and that timing makes a difference in when and how that happens. I'm now guessing that the bug is triggered by calls from the fontification system. If I start "emacs -Q", and do `M-x global-font-lock-mode' to turn all fontifcation off, then "C-c C-s" shows correct syntax when I open the example file. Thanks again, -Jeff From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Jun 2023 10:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Jeff Norden Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.168734398732679 (code B ref 64133); Wed, 21 Jun 2023 10:40:02 +0000 Received: (at 64133) by debbugs.gnu.org; 21 Jun 2023 10:39:47 +0000 Received: from localhost ([127.0.0.1]:60726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBvFb-0008V0-A5 for submit@debbugs.gnu.org; Wed, 21 Jun 2023 06:39:47 -0400 Received: from mx3.muc.de ([193.149.48.5]:17092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBvFZ-0008Uo-Po for 64133@debbugs.gnu.org; Wed, 21 Jun 2023 06:39:46 -0400 Received: (qmail 65077 invoked by uid 3782); 21 Jun 2023 12:39:40 +0200 Received: from acm.muc.de (pd953aea6.dip0.t-ipconnect.de [217.83.174.166]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 21 Jun 2023 12:39:39 +0200 Received: (qmail 4446 invoked by uid 1000); 21 Jun 2023 10:39:39 -0000 Date: Wed, 21 Jun 2023 10:39:39 +0000 Message-ID: References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello again, Jeff. On Mon, Jun 19, 2023 at 11:46:32 +0000, Alan Mackenzie wrote: > On Sun, Jun 18, 2023 at 12:23:58 -0500, Jeff Norden wrote: > > The only reason the minibuffer-read affects things is timing. This > > seems obvious now, but somehow it didn't occur to me until after I > > sent the previous message. If I do > > ..wait a few seconds.. > > then the syntax does *not* change to brace-list. I tried changing > > c-progress-interval, but that didn't seem to affect things. Maybe > > there is another timer, or maybe a race condition involved somehow. > No, I think it really is the cache bug I mentioned in my last post. > Caches are wonderful things when they work properly, but the utter devil > to debug when they don't. > I've currently got a CC Mode version with this cache corrected, such > that it parses your test file correctly, but I want to make sure the > correction is correct before I send you a patch and release the fix. > I'll be back again soon. OK, here's the patch which I think fixes the bug completely. Would you please apply this patch to your ..../lisp/progmodes/cc-engine.el, byte-compile (or native-compile) that file, and then try it out on your real code. (In the unlikely event that you want help with the patching or compilation, feel free to send me personal email.) Then, please confirm that the bug is fixed, or tell me what's still not working. Thanks! diff -r 2cd57c62754a cc-engine.el --- a/cc-engine.el Sat Jun 17 12:45:10 2023 +0000 +++ b/cc-engine.el Wed Jun 21 10:27:21 2023 +0000 @@ -12816,11 +12816,19 @@ (defvar c-laomib-cache nil) (make-variable-buffer-local 'c-laomib-cache) -(defun c-laomib-get-cache (containing-sexp) - ;; Get an element from `c-laomib-cache' matching CONTAINING-SEXP. +(defun c-laomib-get-cache (containing-sexp start) + ;; Get an element from `c-laomib-cache' matching CONTAINING-SEXP, and which + ;; is suitable for start postiion START. ;; Return that element or nil if one wasn't found. - (let ((elt (assq containing-sexp c-laomib-cache))) - (when elt + (let ((ptr c-laomib-cache) + elt) + (while + (and ptr + (setq elt (car ptr)) + (or (not (eq (car elt) containing-sexp)) + (< start (car (cddr elt))))) + (setq ptr (cdr ptr))) + (when ptr ;; Move the fetched `elt' to the front of the cache. (setq c-laomib-cache (delq elt c-laomib-cache)) (push elt c-laomib-cache) @@ -12832,18 +12840,26 @@ ;; the components of the new element (see comment for `c-laomib-cache'). ;; The return value is of no significance. (when lim - (let ((old-elt (assq lim c-laomib-cache)) - ;; (elt (cons containing-sexp (cons start nil))) + (let (old-elt (new-elt (list lim start end result)) big-ptr (cur-ptr c-laomib-cache) - togo (size 0) cur-size - ) - (if old-elt (setq c-laomib-cache (delq old-elt c-laomib-cache))) + togo (size 0) cur-size) + + ;; If there is an elt which overlaps with the new element, remove it. + (while + (and cur-ptr + (setq old-elt (car cur-ptr)) + (or (not (eq (car old-elt) lim)) + (not (and (> start (car (cddr old-elt))) + (<= start (cadr old-elt)))))) + (setq cur-ptr (cdr cur-ptr))) + (when (and cur-ptr old-elt) + (setq c-laomib-cache (delq old-elt c-laomib-cache))) (while (>= (length c-laomib-cache) 4) ;; We delete the least recently used elt which doesn't enclose START, - ;; or.. + ;; or ... (dolist (elt c-laomib-cache) (if (or (<= start (cadr elt)) (> start (car (cddr elt)))) @@ -12851,8 +12867,10 @@ ;; ... delete the least recently used elt which isn't the biggest. (when (not togo) + (setq cur-ptr c-laomib-cache) (while (cdr cur-ptr) - (setq cur-size (- (nth 2 (cadr cur-ptr)) (car (cadr cur-ptr)))) + (setq cur-size (- (cadr (cadr cur-ptr)) + (car (cddr (cadr cur-ptr))))) (when (> cur-size size) (setq size cur-size big-ptr cur-ptr)) @@ -13044,7 +13062,7 @@ (goto-char pos) (when (eq braceassignp 'dontknow) (let* ((cache-entry (and containing-sexp - (c-laomib-get-cache containing-sexp))) + (c-laomib-get-cache containing-sexp pos))) (lim2 (or (cadr cache-entry) lim)) sub-bassign-p) (if cache-entry @@ -13066,6 +13084,8 @@ ) (setq braceassignp (nth 3 cache-entry)) (goto-char (nth 2 cache-entry))) + (c-laomib-put-cache containing-sexp + start (point) sub-bassign-p) (setq braceassignp sub-bassign-p))) (t)) > > Hope this helps, > > -Jeff -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Jun 17 22:12:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Resent-From: Jeff Norden Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Jun 2023 18:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64133 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan Mackenzie Cc: Eli Zaretskii , 64133@debbugs.gnu.org Received: via spool by 64133-submit@debbugs.gnu.org id=B64133.168737303430006 (code B ref 64133); Wed, 21 Jun 2023 18:44:01 +0000 Received: (at 64133) by debbugs.gnu.org; 21 Jun 2023 18:43:54 +0000 Received: from localhost ([127.0.0.1]:34209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qC2o6-0007nt-8E for submit@debbugs.gnu.org; Wed, 21 Jun 2023 14:43:54 -0400 Received: from mail-pj1-f51.google.com ([209.85.216.51]:44429) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qC2o4-0007ne-GF for 64133@debbugs.gnu.org; Wed, 21 Jun 2023 14:43:53 -0400 Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-25eee11a9f1so2647221a91.1 for <64133@debbugs.gnu.org>; Wed, 21 Jun 2023 11:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687373026; x=1689965026; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uusnF4EKON45qTDBHX3WGpYhU8gWhBQO60+ZnDSfICo=; b=Prbiu1FDwhj6LQV8YcjaXx8ljcNdrnE8bXU/Zj+Nr41bkwtgXtssozsasua8DT07ms 5cEt/C4eswfshGdU3Y2A/3mdttJlHpJzbeT5T/7hsj9Ma16vqjJ8mV0gsyDFs5WQ9hpf +kapzNaVckiZDl33MC+kBGIIoUypl65og2aJms8IFIkDZ9Ws3AvwNqvWt+AHB2n39Sk2 72qLTra7Www/tZQZA7LYaIA4e/6AjdcE0zVAGXf66itYycsI3JbW+EafanJpuVvr212x UDsUIJjJ2UsER7jMDhq66rEWw22eUP4kPYO/1jrEopuJ6a4+MX4vVjtFzMR3l3aqVJN6 qRWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687373026; x=1689965026; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uusnF4EKON45qTDBHX3WGpYhU8gWhBQO60+ZnDSfICo=; b=HuydbJJDuKPLrGmYnu6HUN/KGssbY6uw6+kOt42pXUSbkmDYxpvjeVzC4LJJXQ9Rwr BJtqWPHVK5doyOwe9I80XLFkWLr/7eTXU58PS6EQ4hzCgG0S6QnJP26E/uvMNPAfZRMX 2ubLH5j6G/a5xi/r3XqP5E8Cmm8m9vy2MAEb0ahsED44nwekXkSmQtle2i9akpXarhaC RFoa40SxkYMT2ERdipb27cqzIJ7b//MDrXvuqFG1JhDT4yXCcxM4GzbM12CUW5uB6uNR n3NM4jpq0XhQV22SsQccK+JKfxNFsfwsQ6tbBeEalbXMk5Oh5ysE86PRMyjdXfQod3yG q0Jg== X-Gm-Message-State: AC+VfDw0AiaWTQbzwLpSnb2CZBoig6irdFKMcsf25SWA6SSgfEKdpRvp A2uN16HZQyMn93mqeSjpD2t6FFcPNfrKQ0Nbt1Q= X-Google-Smtp-Source: ACHHUZ46VgWv556MLPt3r1CvbrPaal9nNpvwbk5xWq2ZkWnGOc57b2VzFBsQDM4TZyPjW4I0UGj6Yf2nOaWt9VZqX5k= X-Received: by 2002:a17:90a:cb08:b0:258:d910:619d with SMTP id z8-20020a17090acb0800b00258d910619dmr12550164pjt.14.1687373026499; Wed, 21 Jun 2023 11:43:46 -0700 (PDT) MIME-Version: 1.0 References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> In-Reply-To: From: Jeff Norden Date: Wed, 21 Jun 2023 13:43:20 -0500 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Wed, Jun 21, 2023 at 5:39=E2=80=AFAM Alan Mackenzie wrote: > Hello again, Jeff. > > OK, here's the patch which I think fixes the bug completely. Would you > please apply this patch ... Then, please confirm that the bug is fixed= , or > tell me what's still not working. Hi Alan, Thanks for taking care of this so quickly. The patch seems to work perfectly for me. I've tried it with 29.0.91 (2nd emacs-29 pretest) and with my current git build of emacs from the master branch (which is from June 11). Patch gives differing "offset" messages, but all of the "hunks" succeed in both cases. I haven't built the 3rd emacs-29 pretest yet, but I can't foresee that there will be a problem. I will be using this some more over the next few days. I'll post again if I notice any issues, but I don't expect to. -Jeff From unknown Tue Jun 17 22:12:10 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jeff Norden Subject: bug#64133: closed (Re: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs.) Message-ID: References: X-Gnu-PR-Message: they-closed 64133 X-Gnu-PR-Package: emacs Reply-To: 64133@debbugs.gnu.org Date: Tue, 27 Jun 2023 20:20:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1687897202-9650-1" This is a multi-part message in MIME format... ------------=_1687897202-9650-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of struc= ts. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 64133@debbugs.gnu.org. --=20 64133: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D64133 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1687897202-9650-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 64133-done) by debbugs.gnu.org; 27 Jun 2023 20:19:36 +0000 Received: from localhost ([127.0.0.1]:49587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEF9z-0002Uy-Uy for submit@debbugs.gnu.org; Tue, 27 Jun 2023 16:19:36 -0400 Received: from mx3.muc.de ([193.149.48.5]:15422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEF9w-0002Uj-Kb for 64133-done@debbugs.gnu.org; Tue, 27 Jun 2023 16:19:34 -0400 Received: (qmail 81529 invoked by uid 3782); 27 Jun 2023 22:19:26 +0200 Received: from acm.muc.de (pd953a258.dip0.t-ipconnect.de [217.83.162.88]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 27 Jun 2023 22:19:26 +0200 Received: (qmail 3389 invoked by uid 1000); 27 Jun 2023 20:19:25 -0000 Date: Tue, 27 Jun 2023 20:19:25 +0000 To: Jeff Norden Subject: Re: bug#64133: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. Message-ID: References: <831qiaqfxh.fsf@gnu.org> <83y1kioxzv.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 64133-done Cc: acm@muc.de, Eli Zaretskii , 64133-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Jeff. On Wed, Jun 21, 2023 at 13:43:20 -0500, Jeff Norden wrote: > On Wed, Jun 21, 2023 at 5:39 AM Alan Mackenzie wrote: > > OK, here's the patch which I think fixes the bug completely. Would you > > please apply this patch ... Then, please confirm that the bug is fixed, or > > tell me what's still not working. > Hi Alan, > Thanks for taking care of this so quickly. The patch seems to work > perfectly for me. I've tried it with 29.0.91 (2nd emacs-29 pretest) > and with my current git build of emacs from the master branch (which > is from June 11). Patch gives differing "offset" messages, but all of > the "hunks" succeed in both cases. I haven't built the 3rd emacs-29 > pretest yet, but I can't foresee that there will be a problem. I will > be using this some more over the next few days. I'll post again if I > notice any issues, but I don't expect to. Thanks for such comprehensive testing! I've now committed the patch to the Emacs master branch (it is too intricate a patch to go to the release branch at this late stage), and I'm closing the bug with this post. If any other problems become apparent in this area (or anywhere else), feel free to raise another bug report. > -Jeff -- Alan Mackenzie (Nuremberg, Germany). ------------=_1687897202-9650-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 17 Jun 2023 15:04:17 +0000 Received: from localhost ([127.0.0.1]:52271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXTN-0008Qp-Du for submit@debbugs.gnu.org; Sat, 17 Jun 2023 11:04:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:45556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAXTJ-0008Qf-HC for submit@debbugs.gnu.org; Sat, 17 Jun 2023 11:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAXTI-0001aC-K1 for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 11:04:12 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qAXTE-0004Ql-MW for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 11:04:12 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666e6ecb52dso636539b3a.2 for ; Sat, 17 Jun 2023 08:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687014230; x=1689606230; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=HJsH+vKBbEP06bXCFs+lwhVzcxSyFGVNU09UzBBIgJw=; b=qMH6ZJJrcXa3PjgB+gF6smJhLTMD4V2OIoPp5TttnNF3fjeYzn1m+lAxkOl2BqwkWn 5JXNyGUAS/4ojyUica6D7WHKNvP1pI+YEhHnDIVtjEkpTHZooTxWZ3Is9g/ajgJUt/fz 32QJ5CaM4ZYAbZ76P0S98/gHi2yfbLl4gL2osgRJsejvIppYXBDTPPgZHA/VuC4ncwMZ MD2KQj3cW9o9pTqYsiGUj1wj0jC9lAxAqKi4v/9ADFwttpDzEV8PjVsNv9jqZ6hJH2vR igFpejqIdFk4sPwMKZKAeqgKnZufKofeKMXFWSyKyEIQb0iRqM1cx5x1G3IYgSG8/+0G Jgjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687014230; x=1689606230; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HJsH+vKBbEP06bXCFs+lwhVzcxSyFGVNU09UzBBIgJw=; b=A0iKbysnS2Jbh589SHOOZt39qwIOKRdyPpMiT7eWf8B81L5NfQ9s+WS5hakUY26U5Z Q5WrcStalZyNknX2soLwOuCix1sfai1H2WugjhPqIdd+0adfLlfi1aCGSHWcdxGKXJt1 Ln84HZDdiQDscudzee/BOo+SLK1buvmwdgtT2fD65eQCr5YNpR1KFcjCJIUxrpijGb+b YbFIQWsqWm2F3KY3IipdV1w+gu2AHLptRm+NCmd/x3CSRrhRle8e3dE/hdqG2e+L8wpe jKmHuHWJ5Mv5yYXKSTVHWwEij1QGhrByvkBpJa7Zh7d44q7hICxD8/2SK+6dpldGOAQr NnrQ== X-Gm-Message-State: AC+VfDyCKH0RblcH4cxXaI1rsZG6iAM2rfuSw26uvd+0OvkdygMHRK15 z6eELYmBF3CZ4vL0D1kSvuqv2vzIAuHiTZ3DNXbPSGoe8kM= X-Google-Smtp-Source: ACHHUZ5OEaFC7qAedYj+JxgQafAXzcDKW1HSm3yRmlxWIOftqrqFziGITFKGHnQSuBqU6GqhqD7ptWWkhHhoVM620Rk= X-Received: by 2002:a17:90a:fe8d:b0:255:b1d9:a206 with SMTP id co13-20020a17090afe8d00b00255b1d9a206mr2927991pjb.22.1687014230069; Sat, 17 Jun 2023 08:03:50 -0700 (PDT) MIME-Version: 1.0 From: Jeff Norden Date: Sat, 17 Jun 2023 10:03:24 -0500 Message-ID: Subject: CC Mode 5.35.2 (C/*l); incorrect indentation for an arrays of structs. To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=norden.jeff@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) I've verified the following behavior with c-version 5.35.2 (emacs-29, and emacs-30 from git) and with 5.35.1 (emacs 28.2). Place the following text into a file with a ".c" extension, and load it with "emacs -Q". ========================================== #include struct three_ints { int a, b, c; }; int main () { struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; for (int i=0; i to indent the line. It will be incorrectly indented 2 spaces more than the previous line. Move to the next line, press , and you'll see: struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; Just using to re-indent the lines will not change anything. But, if you add or delete white-space before {0,1,2} or {3,4,5} and press , it *may* fix things. It seems to depend on just what you delete and where the cursor is. The pattern isn't clear to me. Once fixed, you get: struct three_ints numbers[]= { {0,1,2}, {3,4,5}, {6,7,8} }; At this point it is stable, and will work correctly. If you restart c-mode with "M-x c-mode", the problem re-occurs. This bug only seems to occur when a loop or similar construct occurs after the array declaration/initialization. It doesn't need to immediately follow, though. When incorrectly indenting, "C-c C-s" shows 'defun-block-intro' syntax for the {0,1,2} line, and 'substatement-open' for {3,4,5} and {4,5,6}. Once it gets fixed, this changes to 'brace-list-intro' and 'brace-entry-open'. ========================================== For a more "real world" example, start with the example program at the end of the getopt_long(3) man page: https://linux.die.net/man/3/getopt_long and move the declaration of long_options[] from inside the while loop to before it. (This makes long_options a global variable, instead of local to the loop). ========================================== I'm afraid I can't offer a patch or suggestion for a fix. My own attempts at "parsing" the lisp in cc-engine.el come to an abrupt halt when my brain receives an urgent "Warning! Meltdown imminent!" message from my subconscious -- just kidding :-). However, I did stumble upon the following in the comments for the `c-inside-bracelist-p' function: ;; CONTAINING-SEXP is the buffer pos of the innermost containing ;; paren. NO IT ISN'T!!! [This function is badly designed, and ;; probably needs reformulating without its first argument, ... Thanks, -Jeff ---------------------------- If believing that "function is more important than form" and that "people are more important than technology" makes me a Luddite, then so be it! ------------=_1687897202-9650-1--