From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 02 10:57:38 2023 Received: (at submit) by debbugs.gnu.org; 2 Jan 2023 15:57:38 +0000 Received: from localhost ([127.0.0.1]:43864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCNBy-0007Xd-Gx for submit@debbugs.gnu.org; Mon, 02 Jan 2023 10:57:38 -0500 Received: from lists.gnu.org ([209.51.188.17]:33370) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCNBw-0007XU-0w for submit@debbugs.gnu.org; Mon, 02 Jan 2023 10:57:37 -0500 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 1pCNBt-0003Zs-7D for bug-gnu-emacs@gnu.org; Mon, 02 Jan 2023 10:57:35 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCNBp-0004Xb-Uo for bug-gnu-emacs@gnu.org; Mon, 02 Jan 2023 10:57:32 -0500 Received: (Authenticated sender: sadiq@sadiqpk.org) by mail.gandi.net (Postfix) with ESMTPA id 1DA4A60008 for ; Mon, 2 Jan 2023 15:57:25 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 02 Jan 2023 21:27:25 +0530 From: Mohammed Sadiq To: bug-gnu-emacs@gnu.org Subject: 29.0.60; c-ts-mode: Broken indentation with linux style conditionals Message-ID: <91001d1f8d7fe3db33aefffaa0829f26@sadiqpk.org> X-Sender: sadiq@sadiqpk.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=217.70.183.195; envelope-from=sadiq@sadiqpk.org; helo=relay3-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) 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.6 (--) Indentation of the following C code with linux style is broken: int main (void) { if (a) { func_a (); } else if (b) { func_b (); } else { func_c (); } } In GNU Emacs 29.0.60 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.16.0) of 2023-01-02 built on purism Repository revision: 2569ede9c496bb060e0b88428cb541088aaba1f9 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12101005 System Description: Debian GNU/Linux bookworm/sid From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 02 17:29:14 2023 Received: (at 60496) by debbugs.gnu.org; 2 Jan 2023 22:29:14 +0000 Received: from localhost ([127.0.0.1]:44269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCTIw-000613-42 for submit@debbugs.gnu.org; Mon, 02 Jan 2023 17:29:14 -0500 Received: from mail-qt1-f181.google.com ([209.85.160.181]:43777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCTIs-00060j-3f for 60496@debbugs.gnu.org; Mon, 02 Jan 2023 17:29:13 -0500 Received: by mail-qt1-f181.google.com with SMTP id a16so23323456qtw.10 for <60496@debbugs.gnu.org>; Mon, 02 Jan 2023 14:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=CsgmGDF5e72sEU8vojvu1w9L8JXVYTrHJFrx+O0Xtik=; b=GDrl7uitw0clU9Jd6asLFcByylqSq7etG5i+GYb3Lm5i+Gc6z/xtZBt0RKZ+g93qXA 8fG999lPxVHjD7LLQRrFIJu4s5j1vRhYsgsbjVh5o/OiP3N4A9jNFWS0UpYMv8OwzZ1K 2ujiBWhgRAHVK8zfpG6WAWphpq9Z272ribTedx8JItfSTi/LPJgi7I5qvJTxNDKBqKLt vGA/si8kE2kgPSd9bhv4TA82Ahe/9c6oFHVmUmt5CBAfAsOE5plIDfpC9/xYWHqr1wwM aYa7EQkrRb3EOE81GVo3t1v1ylLfzco7yx/o5iU2FnH6ZlT3tPPmq1IIcYJEpxuPSr2g LxEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CsgmGDF5e72sEU8vojvu1w9L8JXVYTrHJFrx+O0Xtik=; b=r8r6UDo7h5cx73oRLHaPK6hcpKoSaMLI2RFZpBHt+PTF0vLu1KCRxidIgYhMxmdqfV ffnSxCUq0P5C5WGPudATBUWtvzaKQPrESMmAiQOivEho0lKQitCkxSA8lm9vimo/RPTR a0ip5WYA0s16bhLmK1SDXGnoat/h7kaCtFKnjpKO/1nuv7pd4GP/G9AKCGFtdolWU1W1 5H1/sIXhhOjrVinxU5KbYyMKUC8sPUoQhq0/1p+Nz65yAsuJY6cWJt/tSV4LEe/MDHSv ynYJptSP6vzStrIYsABFS8HnOCH0HgJiOvBFYX4n2xA8dxdlrhEx1lL2yb7Iedn81skJ 9q/A== X-Gm-Message-State: AFqh2kopKqkSfLf4YGqs80fZraf0/MQpdV+G63Vkwu7kw4sswvp16+ua GfLtzg3b2TDLivEfWOo2dTS89szFNZaK+w== X-Google-Smtp-Source: AMrXdXsrwrZsQ/fkj0hQqK+SOx7On6D5slLJjT0wTshfWA5/d/sP35WiANMtlh+FCTjaD8mb00lb2w== X-Received: by 2002:ac8:128b:0:b0:3a5:758d:8f5e with SMTP id y11-20020ac8128b000000b003a5758d8f5emr56468798qti.19.1672698544571; Mon, 02 Jan 2023 14:29:04 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z18-20020ac875d2000000b003995f6513b9sm17923136qtq.95.2023.01.02.14.29.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2023 14:29:04 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#60496: 29.0.60; c-ts-mode: Broken indentation with linux style conditionals Message-Id: <68A07E57-06EE-4F38-A2BC-A426B85BE56A@gmail.com> Date: Mon, 2 Jan 2023 14:29:02 -0800 To: Mohammed Sadiq X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60496 Cc: 60496@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 (-) Mohammed Sadiq writes: > Indentation of the following C code with linux style is broken: > > int main (void) > { > if (a) { > func_a (); > } else if (b) { > func_b (); > } else { > func_c (); > } > } > Thanks. I=E2=80=99m not familiar with the linux style, is the problem = with the closing brackets? Could you give me a correct example so I know exactly what=E2=80=99s wrong? Yuan From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 03 04:10:05 2023 Received: (at 60496) by debbugs.gnu.org; 3 Jan 2023 09:10:05 +0000 Received: from localhost ([127.0.0.1]:44721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCdJ6-0002NX-PH for submit@debbugs.gnu.org; Tue, 03 Jan 2023 04:10:05 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:53879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCdJ4-0002Mv-8V for 60496@debbugs.gnu.org; Tue, 03 Jan 2023 04:10:04 -0500 Received: (Authenticated sender: sadiq@sadiqpk.org) by mail.gandi.net (Postfix) with ESMTPA id 17236240011; Tue, 3 Jan 2023 09:09:52 +0000 (UTC) MIME-Version: 1.0 Date: Tue, 03 Jan 2023 14:39:52 +0530 From: Mohammed Sadiq To: Yuan Fu Subject: Re: bug#60496: 29.0.60; c-ts-mode: Broken indentation with linux style conditionals In-Reply-To: <68A07E57-06EE-4F38-A2BC-A426B85BE56A@gmail.com> References: <68A07E57-06EE-4F38-A2BC-A426B85BE56A@gmail.com> Message-ID: <1d37d77b75e3ede545e68c9521fcb171@sadiqpk.org> X-Sender: sadiq@sadiqpk.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60496 Cc: 60496@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.7 (-) On 2023-01-03 03:59, Yuan Fu wrote: > Mohammed Sadiq writes: > >> Indentation of the following C code with linux style is broken: >> >> int main (void) >> { >> if (a) { >> func_a (); >> } else if (b) { >> func_b (); >> } else { >> func_c (); >> } >> } >> > > Thanks. I’m not familiar with the linux style, is the problem with the > closing brackets? Could you give me a correct example so I know exactly > what’s wrong? > > Yuan The expected indentation style for the given code (this one is provided by c-mode), with the default indentation values: int main (void) { if (a) { func_a (); } else if (b) { func_b (); } else { func_c (); } } From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 07:18:44 2023 Received: (at 60496) by debbugs.gnu.org; 7 Jan 2023 12:18:44 +0000 Received: from localhost ([127.0.0.1]:56649 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pE89s-00069f-5o for submit@debbugs.gnu.org; Sat, 07 Jan 2023 07:18:44 -0500 Received: from out2.migadu.com ([188.165.223.204]:24204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pE89p-00069U-Qm for 60496@debbugs.gnu.org; Sat, 07 Jan 2023 07:18:42 -0500 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=thornhill.no; s=key1; t=1673093920; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=No37CIdGg+jF0emiGDmwzmAWV4WHrnhks1luzB3AhX4=; b=N0pWBXpnE3MI1pR6t+t9qiFTPM9gQkzgkQqX2FBwInr9bKbVc5nvA08Nd9GLBIkNVtkkry V+Z9AfnLj7g/0Fqogh4Tua7LcY3ZAo4wM3GXu2zgYxWZVCth4z8ftGYfcnRn9NbJqZ541v nyqNY476k1b3tMv2PTGwYJy9TZY/7mDwma66t+S1L7sV1I62xPgj1XMSvIQRZrlF9kex73 F1XOcopusFwF+S3Ydg7+XJutBjm+PdiLXem4eUuK+rTlyhfu0UyZ5Tk+6O37nRnH3SilYV NUJ02Qhcqr7OXVlHbikXzlnnhSn3jS+kIXNRgHqiko49ch7QPHVvSz1SZOyRXQ== From: Theodor Thornhill To: Mohammed Sadiq Subject: Re: bug#60496: 29.0.60; c-ts-mode: Broken indentation with linux style conditionals In-Reply-To: <1d37d77b75e3ede545e68c9521fcb171@sadiqpk.org> (Mohammed Sadiq's message of "Tue, 03 Jan 2023 14:39:52 +0530") References: <68A07E57-06EE-4F38-A2BC-A426B85BE56A@gmail.com> <1d37d77b75e3ede545e68c9521fcb171@sadiqpk.org> Date: Sat, 07 Jan 2023 13:18:38 +0100 Message-ID: <87ilhitu5d.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60496 Cc: Yuan Fu , 60496@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 (-) Mohammed Sadiq writes: > On 2023-01-03 03:59, Yuan Fu wrote: >> Mohammed Sadiq writes: >>=20 >>> Indentation of the following C code with linux style is broken: >>> int main (void) >>> { >>> if (a) { >>> func_a (); >>> } else if (b) { >>> func_b (); >>> } else { >>> func_c (); >>> } >>> } >>>=20 >> Thanks. I=E2=80=99m not familiar with the linux style, is the problem wi= th the >> closing brackets? Could you give me a correct example so I know exactly >> what=E2=80=99s wrong? >> Yuan > > > The expected indentation style for the given code (this one is provided > by c-mode), with the default indentation values: > > int > main (void) > { > if (a) { > func_a (); > } else if (b) { > func_b (); > } else { > func_c (); > } > } Yuan, this is a regression after the c-ts-mode--bracket-children-anchor. IIRC this was one of the cases that gave me headeaches. IIUC now the grand-parent cannot help because we could have infinite else ifs, right? And the c grammar nests these "alternative:" nodes deeper and deeper. Reverting to diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index dec866f762f..6c8c671550a 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -118,7 +118,7 @@ c-ts-mode--indent-styles `(((parent-is "translation_unit") parent-bol 0) ((node-is ")") parent 1) ((node-is "]") parent-bol 0) - ((node-is "}") c-ts-mode--bracket-children-anchor 0) + ((node-is "}") parent-bol 0) ((node-is "else") parent-bol 0) ((node-is "case") parent-bol 0) ((node-is "preproc_arg") no-indent) @@ -134,7 +134,7 @@ c-ts-mode--indent-styles ((match "preproc_function_def" "compound_statement") point-min = 0) ((match "preproc_call" "compound_statement") point-min 0) ((parent-is "compound_statement") - c-ts-mode--bracket-children-anchor c-ts-mode-indent-offset) + parent-bol c-ts-mode-indent-offset) ((parent-is "function_definition") parent-bol 0) ((parent-is "conditional_expression") first-sibling 0) ((parent-is "assignment_expression") parent-bol c-ts-mode-inden= t-offset) @@ -155,7 +155,7 @@ c-ts-mode--indent-styles '(((node-is "access_specifier") parent-bol 0))) ((parent-is "field_declaration_list") parent-bol c-ts-mode-inde= nt-offset) ((parent-is "initializer_list") parent-bol c-ts-mode-indent-off= set) - ((parent-is "if_statement") parent-bol c-ts-mode-indent-offset) + ((parent-is "if_statement") c-ts-mode--bracket-children-anchor = c-ts-mode-indent-offset) ((parent-is "for_statement") parent-bol c-ts-mode-indent-offset) ((parent-is "while_statement") parent-bol c-ts-mode-indent-offs= et) ((parent-is "switch_statement") parent-bol c-ts-mode-indent-off= set) Fixes this issue, but then we again have the problem with code such as: ``` int main (void) { for(; ;) { // wrong... } } ``` Theo From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 18:05:57 2023 Received: (at control) by debbugs.gnu.org; 7 Jan 2023 23:05:57 +0000 Received: from localhost ([127.0.0.1]:59182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIGD-0007Cz-Cq for submit@debbugs.gnu.org; Sat, 07 Jan 2023 18:05:57 -0500 Received: from mail-pj1-f44.google.com ([209.85.216.44]:55892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEIGC-0007Cl-8U for control@debbugs.gnu.org; Sat, 07 Jan 2023 18:05:56 -0500 Received: by mail-pj1-f44.google.com with SMTP id dw9so3676557pjb.5 for ; Sat, 07 Jan 2023 15:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=rbPnXDr2oLEGCERADmABqLflv7ch6UIKQxg5POfh2XM=; b=a4lKvG6vxQAew4/AJfGKlFtnQRPJbrRwtS0mckL45ICA3UNq5Fsixu41Xf+v5i0pE5 zmFuM+FP4Ik+knxDlCVEQLlBUSSZwr2wDCkWZpKkLwf14EOU1aGUixwIATI9eJUmxyU8 sJrtWHn557huIzGdka3cpwRMs4FEpUCUZNOFLbA8N6Achkwm8J7cZdvJGsQxRT/L8Y+0 kXHyLMgwcCZgmwMYNy07CE1pe7yeASmRvx4x6CpO1xVEsqTbwDB+Wf4fwl726P7zSfgv JyJAXOLBXsYV7jpsb1whhA1hZWDS3lvx2hN5oTtpZkXvp8iPe1HxIW3bayDloIxxra7a zwww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rbPnXDr2oLEGCERADmABqLflv7ch6UIKQxg5POfh2XM=; b=v3Y9vz+6F6dMIYKw1aUoWAUNYYJyDVB8+oUN3taK7KRAPnhvz3JogFkIKgDqFQE66T Lx2Z4eW6DGgNfK+wANkXRbM/f/CB1KPF+9ls5fP/Jxb8ty089bSaTib4hAcd+wGRH6fX 7lt2YaAzNPjxUVJm7rhC9zrJX3O4HZX2ge4mOMZfuLArrfL5ndFmlpNUawsX/IqTwZ1+ /kGD9EC0WKXsa2BTKb6bVFH27gJnHbtRlzJTEd1TaooIz0XZxBDDOl0T00aoFsu73t4C G8WzBok9tyZblnHkBFvv9PoeZZoQ3hGYWe5X/SgRKt1RqWuDOYnwRm58kIy+m2HIvBWb Ouow== X-Gm-Message-State: AFqh2kqDazF0/ymbf8Cppd3wWOQJB9IFlhJJROMTFgEFj76TJXNrRbZc lr9IIWOC8DJpu9yU6qZynIHjMaH8yQw= X-Google-Smtp-Source: AMrXdXsFhD9oUkZ5zikz9WZ2VypBb7MK0I9tZHfSds+fmE/jSwayfpXHs3fmiolX6bHIJ7lzSa78/A== X-Received: by 2002:a17:902:bc81:b0:193:1e28:bc6b with SMTP id bb1-20020a170902bc8100b001931e28bc6bmr2862151plb.65.1673132750270; Sat, 07 Jan 2023 15:05:50 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id n3-20020a170903110300b00189f2fdbdd0sm3193701plh.234.2023.01.07.15.05.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2023 15:05:49 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: control message for bug #60496 Message-Id: <2715C543-798B-4A0B-8667-129EE9D885CB@gmail.com> Date: Sat, 7 Jan 2023 15:05:48 -0800 To: control@debbugs.gnu.org X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) merge 60496 59686 quit From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 07 19:15:14 2023 Received: (at control) by debbugs.gnu.org; 8 Jan 2023 00:15:14 +0000 Received: from localhost ([127.0.0.1]:59327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEJLG-0007es-8S for submit@debbugs.gnu.org; Sat, 07 Jan 2023 19:15:14 -0500 Received: from mail-pj1-f52.google.com ([209.85.216.52]:55039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEJLD-0007eY-Tg for control@debbugs.gnu.org; Sat, 07 Jan 2023 19:15:12 -0500 Received: by mail-pj1-f52.google.com with SMTP id q64so5196576pjq.4 for ; Sat, 07 Jan 2023 16:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=x0AGMkbVgFSJ3ClhD73RSGTBcK2htzQ65e3ADnjCRyE=; b=CrURiLWYg4wYpkNwJV++1hAAt1+1zGr82iUBctryHL0FQglVrql3+CuSTJ14JvkY2j EijkDRHJ+J1J2/FgTmV0H36Y2qsBvdgzDL6oKwmwkqa6ZJI+tDU1neMLhO+XtcA2gn74 M/xnPBTms+v8RHNYFLLgzaYKFSJ0w0c852RJOZMe086HNgwy/EzMv/0tEH0XJfAHo0CO RNb0QTttfZILb4/u60LQ1f6a5lMxDcLDBtFHZ64lVWmUFEwKWRBuRd6GKNN0FK90ANO+ 9QIdgTUB1GRyevyI1iUQTylJ77nY+aKPiZG6nCw6zvBkceknbHvu9QVcsQf8/SXzRtmz jmYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x0AGMkbVgFSJ3ClhD73RSGTBcK2htzQ65e3ADnjCRyE=; b=q1pxygVvBKNYZtctbhWwChCIbWN7/Yw25VoV2biPdNjtsHKIFMQDsoPZztiBdKT0FT GXn+TM12Hm8ZpgpoENVvEIj1X5p/NgCsvuyZs9blt180Z2/o6Cny3LxJUjrlPyDidOW9 Xu/eO8qycWicFtSwqDdj1++Q7syMxsha149f1W0p6LZf4GjZAb+wpz1gMCfOBPZfIWPj u+Q+F6Wt/cgsw0FThX9Th2aA+JWdXhrN4FuBx65q5Uk+laLV3wkDnL9/Kj7awcAStmRD mcdZY96mTFqMj4sfowOnhIfMc9qHweWxP2UP1Jz5w3v1sJcFZKuMeNzLuig+HP4f/zBN L6Yg== X-Gm-Message-State: AFqh2koTFCpWKdQbWIU+J6XI/oeuuo/D6m73ea4zPXcFmmiJ/AnsqPEb 8h6Cm7ELKHNAII4/x6OZ271dAlK0kbeOGA== X-Google-Smtp-Source: AMrXdXuuHMxhhiPmTcdHxRtP9o5eVIfuN+SZU6SsSbTojcAPTJqjnalLR1F2EDh3SUGf+UrNswPZGA== X-Received: by 2002:a17:902:e54b:b0:191:24d1:8af6 with SMTP id n11-20020a170902e54b00b0019124d18af6mr91249521plf.42.1673136905813; Sat, 07 Jan 2023 16:15:05 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id n2-20020a170902d2c200b00192fe452e17sm3275242plc.162.2023.01.07.16.15.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2023 16:15:05 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: control message for bug #60496 Message-Id: <88F2E1ED-018C-4CA9-BBFE-9C4AD6EB29C3@gmail.com> Date: Sat, 7 Jan 2023 16:15:04 -0800 To: control@debbugs.gnu.org X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) merge 60496 60398 quit From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 15 04:24:00 2023 Received: (at 60496) by debbugs.gnu.org; 15 Jan 2023 09:24:00 +0000 Received: from localhost ([127.0.0.1]:56102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGzFA-0003W9-0N for submit@debbugs.gnu.org; Sun, 15 Jan 2023 04:24:00 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:43528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pGzF6-0003Ve-AQ; Sun, 15 Jan 2023 04:23:57 -0500 Received: by mail-pl1-f177.google.com with SMTP id d3so27501315plr.10; Sun, 15 Jan 2023 01:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=XUt8CmYvOAqndeajKxKqQoDiBG9HvdpRha5qDKw258Y=; b=LoNdkXnWInZWOyUSiz9jjvlDLEaJI3YYhz7Jh16SHWnG2iaCy8LdiHzCefShUrzPtf V2njRovqGxh7ga4S1GxfJ6ToEjUWAEAcKm8tnMGk3Kn+FgBT+slDFLNYgYvdLW2NF+c7 yYw7BbeVTbJE0K+aKj9SFTaytXg5J0yNXIed+hfhqQJzV4vrQ5YjYjXNInFmmXz17Pb7 wtMt9i96h1DVk8iUiflVT91DbsPCEbbQNDpEkFF+t6zUgKtcennOnMKgiRgO+/9ERkRF 3Q88CiqWDPmWEnxCLSq3vm4zORjiLpuGXX97Oid2fJ6AufrXh3x43I2PVZWVBwkuaccL 4xbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XUt8CmYvOAqndeajKxKqQoDiBG9HvdpRha5qDKw258Y=; b=PMmMqMDFpaY9hsPOWH+iwobxQA0wXuBaqGReLQDyPcPVkn7UaRCKhf1B04nL/CvTXK kwZkUSiEknF5mLYuBluNBWVVwLDGfNzMIaSKMnm6LI+7+pFkUboVpkejF8YlM7IrJ15/ FfzyUwfRty4CeiN/xxF1jJ8bcZWetrmvpsj1UgmklYYRtJ6KXUy9897CQkDmq76Yt9Kw zoiUzC/5lgID8lQ5/i0o+2f6k/ptLr9clsL855xV9ymeoMToH4/1v+OrzmGsIhq9zwvb RPvLezy0VCaxz+YqktSHW6G+axhXXdssVABvNXRiOcPocxU1Eq83AWLlx8ZAR5lvSe3r B/FA== X-Gm-Message-State: AFqh2krQ5HTS0IFdrtUx2mSem/LbM+D/T7TFljzjWkDnBhL38woeNjVS jax9YxPengPTEytxbo4DW3A= X-Google-Smtp-Source: AMrXdXv4DdrCUVMRZOCYDhE3ISRLMoEjW9CDGEUHknY+YlApmPtWuCis4TKAOt89Z6S7Jy91pxybaw== X-Received: by 2002:a17:903:1d2:b0:194:7aae:f272 with SMTP id e18-20020a17090301d200b001947aaef272mr7630081plh.30.1673774629138; Sun, 15 Jan 2023 01:23:49 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id ik9-20020a170902ab0900b00183c67844aesm17081200plb.22.2023.01.15.01.23.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jan 2023 01:23:48 -0800 (PST) From: Yuan Fu Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#60496: 29.0.60; c-ts-mode: Broken indentation with linux style conditionals Message-Id: <14D85B96-4968-45D9-8296-819E440F01C3@gmail.com> Date: Sun, 15 Jan 2023 01:23:45 -0800 To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60496 Cc: bruce.stephens@isode.com, eliz@gnu.org, 60496@debbugs.gnu.org, 59686@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 (-) Yuan Fu writes: >> On Dec 3, 2022, at 3:08 AM, Theodor Thornhill = wrote: >>=20 >>=20 >>=20 >> On 3 December 2022 11:48:34 CET, Yuan Fu wrote: >>>=20 >>> Theodor Thornhill writes: >>>=20 >>>> Bruce Stephens writes: >>>>=20 >>>>> On 02/12/2022 08:39, Eli Zaretskii wrote: >>>>>=20 >>>>>> FWIW, this is an unusual style, so I see no catastrophe if it is = not 110% >>>>>> according to expectations. Users can easily fix that by tweaking = their BOLs >>>>>> where important. >>>>>=20 >>>>>=20 >>>>> The example I gave would be unusual, I think, but I'd argue that = the >>>>> situations where I saw the problem are quite natural. >>>>>=20 >>>>> For example, >>>>>=20 >>>>> } else if ( MYSTRCMP (attname, = SOME_PREFIX_X400ADDRESS) || >>>>> MYSTRCMP (attname, SOME_PREFIX_X400) ) = { >>>>> FOO_ptr orp =3D foo_std2foo (val); >>>>>=20 >>>>> or a function declaration with several arguments with types that = are >>>>> rather long. >>>>>=20 >>>>> I agree it's not a critical bug but if there's no appropriate = general >>>>> fix it would be helpful to have some guidance for users to resolve = our >>>>> specific cases. >>>>=20 >>>> This is the case I was thinking of. In the for-loop a = grand-parent-bol >>>> on compound_statement rule would match the 'for' keyword, so the >>>> indentation will be correct, but this one will not, IIRC. I plan = to dig >>>> into this some more soon, but motivation left me a little on that = issue. >>>> Maybe we could make a preset like: >>>>=20 >>>> ``` >>>> (seq >>>> (parent-is "compound_statement") parent (parent-is "for_statement") = bol) >>>> ``` >>>>=20 >>>>=20 >>>> In other words, make other presets execute sequentially, move = point, >>>> check again, and if all are true, pick indent offset. Or allow = multiple >>>> captures, like so: >>>>=20 >>>> ``` >>>> (for_statement @offset-anchor >>>> body: (compound_statement (_) @to-indent)) >>>> ``` >>>>=20 >>>> Here the @to-indent capture would get the new indent level based on >>>> treesit-node-start of for_statement. >>>>=20 >>>> What do you think, Yuan? >>>=20 >>> I think we can just test for the grandparent, there is an >>> (undocumented) matcher n-p-gp which matches parent and grandparent. >>>=20 >>> Yuan >>=20 >> Yeah I know, but that doesn't work in every case we see this = behavior. > > I see, but at least it fixes common cases that I can think of right = now, namely if, for, while. What are some other cases? I just pushed a change (189d976dbae) that I think fixes this kind of problems. Instead of trying to figure out the right anchor, we simply count the number of {} blocks between the node at point and the root node, and use that number (multiplied by c-ts-mode-indent-offset) as the indentation. If you think about it, both for (a;b;c) { | } and for (a; b; c) { | =20 } are one block-level deep. So multi-line conditions is not an issue anymore. And int main() { if () { | } } is 2 block-level deep, etc. Yuan