From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: john muhl via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65006: 29.1.50; c-ts-mode: else block not indented right on TAB Date: Wed, 02 Aug 2023 11:03:04 -0500 Message-ID: <87zg39xwhz.fsf@pub.pink> References: <59aa8ff84460f695fbf94db4849f1596@sadiqpk.org> <83zg39znkq.fsf@gnu.org> Reply-To: john muhl Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40082"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65006@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 02 19:38:36 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 1qRFnw-000A6N-1b for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Aug 2023 19:38:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRFnR-0000jc-Od; Wed, 02 Aug 2023 13:38:05 -0400 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 1qRFnP-0000jN-IP for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2023 13:38:04 -0400 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 1qRFnP-0007DX-6I for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2023 13:38:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRFnP-0006Q8-2c for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2023 13:38:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: john muhl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Aug 2023 17:38:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65006 X-GNU-PR-Package: emacs Original-Received: via spool by 65006-submit@debbugs.gnu.org id=B65006.169099785324629 (code B ref 65006); Wed, 02 Aug 2023 17:38:03 +0000 Original-Received: (at 65006) by debbugs.gnu.org; 2 Aug 2023 17:37:33 +0000 Original-Received: from localhost ([127.0.0.1]:50105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRFmu-0006PA-IU for submit@debbugs.gnu.org; Wed, 02 Aug 2023 13:37:33 -0400 Original-Received: from out-122.mta0.migadu.com ([91.218.175.122]:60799) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qREJc-00040a-0o for 65006@debbugs.gnu.org; Wed, 02 Aug 2023 12:03:14 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; s=key1; t=1690992190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ywC18CueqDVy4u6TGp+lIIavE83Oq4ygb81NNb116ns=; b=igTHiqV+PLZl42UcKmNB3tkomKWsAhBnYGDd/da2sGXu57klfRDc0LxEd1duLbYRFccF6b ovBBKYoikGNpInVlG7lP7E4UG6K1HeGLCSI6GmL7GZv9XBbxeO+59bbNqf6qYtjohRu+7X dl3y0mM0VSaG7dZhQzY/OWavgaDHC2s= In-Reply-To: <83zg39znkq.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 02 Aug 2023 14:32:53 +0300") X-Migadu-Flow: FLOW_OUT X-Mailman-Approved-At: Wed, 02 Aug 2023 13:37:31 -0400 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:266530 Archived-At: --=-=-= Content-Type: text/plain Here is a patch that makes it work and fixes a couple of tests that were failing in the BSD style. Hope it helps. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-indentation-after-else.patch Content-Description: c-ts-mode-indent-patch >From 43f63fa9fdb5c6e77fd8928a521686ea0b847b2f Mon Sep 17 00:00:00 2001 From: john muhl Date: Wed, 2 Aug 2023 10:30:22 -0500 Subject: [PATCH] Fix indentation after else * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Indent statement after else_clause. --- lisp/progmodes/c-ts-mode.el | 2 ++ test/lisp/progmodes/c-ts-mode-resources/indent.erts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index f16e06942b9..95d3d43c096 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -452,6 +452,7 @@ c-ts-mode--indent-styles ;; These rules are for cases where the body is bracketless. ;; Tested by the "Bracketless Simple Statement" test. ((parent-is "if_statement") standalone-parent c-ts-mode-indent-offset) + ((parent-is "else_clause") standalone-parent c-ts-mode-indent-offset) ((parent-is "for_statement") standalone-parent c-ts-mode-indent-offset) ((parent-is "while_statement") standalone-parent c-ts-mode-indent-offset) ((parent-is "do_statement") standalone-parent c-ts-mode-indent-offset) @@ -478,6 +479,7 @@ c-ts-mode--indent-styles ((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset) ((parent-is "compound_statement") parent-bol c-ts-mode-indent-offset) ((parent-is "if_statement") parent-bol 0) + ((parent-is "else_clause") parent-bol 0) ((parent-is "for_statement") parent-bol 0) ((parent-is "while_statement") parent-bol 0) ((parent-is "switch_statement") parent-bol 0) diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 221b3d809af..b6a30b8f969 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -478,3 +478,16 @@ main (void) { | =-=-= + +Name: Bracketless If/Else Clause + +=-= +int +main (void) +{ + if (true) + do_something (); + else + do_something_else (); +} +=-=-= -- 2.41.0 --=-=-=--