From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#67417: 29.1.50; c-ts-mode syntax issues with no brackets Date: Mon, 27 Nov 2023 04:22:50 +0200 Message-ID: <33b587b2-1ea1-f756-704f-e75a3193c147@gutov.dev> References: <83h6lbfwcu.fsf@gnu.org> <2ba91823-bf3c-4d5d-e556-1622135ab2fd@gutov.dev> <8f8aa9c5-95cb-44e5-b41e-4cf58f024624@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6322"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 67417@debbugs.gnu.org To: Yuan Fu , Eli Zaretskii , Arteen Abrishami Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 27 03:24:28 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r7RIR-0001RL-3s for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Nov 2023 03:24:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7RHy-0005GD-RW; Sun, 26 Nov 2023 21:23:58 -0500 Original-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 1r7RHw-0005Fl-Je for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 21:23:56 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7RHw-0002jm-Bs for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 21:23:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7RI2-00047n-Af for bug-gnu-emacs@gnu.org; Sun, 26 Nov 2023 21:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2023 02:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67417 X-GNU-PR-Package: emacs Original-Received: via spool by 67417-submit@debbugs.gnu.org id=B67417.170105179215795 (code B ref 67417); Mon, 27 Nov 2023 02:24:02 +0000 Original-Received: (at 67417) by debbugs.gnu.org; 27 Nov 2023 02:23:12 +0000 Original-Received: from localhost ([127.0.0.1]:43004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7RHD-00046h-T9 for submit@debbugs.gnu.org; Sun, 26 Nov 2023 21:23:12 -0500 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:36433) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7RH9-00046C-V6 for 67417@debbugs.gnu.org; Sun, 26 Nov 2023 21:23:11 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id AAAAA32001E9; Sun, 26 Nov 2023 21:22:55 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 26 Nov 2023 21:22:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1701051775; x=1701138175; bh=iGEA9YPeWlzyBsqkw2geFi6rFSBSgrFj6Gb 2/RfT3CA=; b=TPiZsJMcBs4D0oHpivZsQuFWx18GxrwnLvsI/V0DV7PRDItiQgD nMK3d3CyqxUyItygF4LT2Mmxti8vgHWm10lfWJuQr9c70x7ksE5y9cM/YTUiM7L/ 9Larz11HU3bs23JNEBsf2X0Wi/hRVL8eKohcenRuoqoirRKlJG6f7p+V5xFRpEcc FP29D16WPvyjMAytqKeNgA7jZ45jI/KDDbZXLhFQRwkKpb7nD5i76dASgNs5Az6Q z2r4FpYFl/qSsaTZYB78SU4odqJtnhjmJNxT32JPgPxR1kNa8ObMgeuvlwiAxsT2 pExTbRf0UYaW524lsaDIgVXWYSrZ3GCeumQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1701051775; x=1701138175; bh=iGEA9YPeWlzyBsqkw2geFi6rFSBSgrFj6Gb 2/RfT3CA=; b=XBKD+BqQNoRT2RqwuaTZ1Y4rLngXAFZrKjv6r72ZHY9b3ywxRX+ u7aWKcrYgGPhYcr0gk3wSX9ZonXbTk8Edn28ePE+HTT/4zbDMljilN5Uy0OJRg5+ oX5G6NZXZX3v2Ix3Z/nh9ikw8iLpUgOJYbAbtxI2dg0NLzvwqKoQJRkx0PS2ohLA 2U3Lsp5COFFIjaK2zHsTQMTV+bPWdla2pcu/RwgQ5+VVpD1XaPSvahojPHfSqXwY WNibd1WH85TknJ+uzyYMCNGDptfuelwZ5LHkRQOGIjsnYtAbeuIVr9RtTL0HbfeZ yQHhhQWsJqorGn1s+7ymUp0iMC/NUg8riqA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeitddggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Nov 2023 21:22:53 -0500 (EST) Content-Language: en-US In-Reply-To: <8f8aa9c5-95cb-44e5-b41e-4cf58f024624@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275099 Archived-At: On 27/11/2023 03:47, Yuan Fu wrote: > I pushed two commits which should fix the indentation for "break" after > "else", and indentation for empty lines after if/else/for/while in > general. The fix for the general case doesn't use the parse tree, since > the parse tree is often incomplete when you type if (...) and hit > return. Instead it uses a plain regexp match to see if the previous line > starts with if/else/for/while. This seems like a reasonable heuristic to > use before user types more things, at which point more accurate > indentation rules would be used, since the parse tree should be more > complete then. Sorry, two counter-examples right away: Type 'elsewhere();' and RET -> the next line is indented 1 level extra, at least until you type some more and then have the line reindented either with pressing TAB or adding semicolon. Type 'for (;;) {}' and RET -> same. The first case is easy to guard against (just check that the next char is either space of opening paren), but the second one less so. OTOH, the second case is likely to have a parse tree without errors, so if we also check for that... the heuristic might work.