From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#74507: [PATCH] Indent compounds c-ts-mode when { is not BOL Date: Thu, 28 Nov 2024 20:56:26 -0800 Message-ID: <66722213-91AB-45C1-BD99-2BF823485E63@gmail.com> References: <87r071yov3.fsf@lambda.is> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30461"; mail-complaints-to="usenet@ciao.gmane.io" Cc: theo@thornhill.no, 74507@debbugs.gnu.org To: =?UTF-8?Q?J=C3=B8rgen?= Kvalsvik Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 29 05:58:22 2024 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 1tGt5C-0007mM-BW for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Nov 2024 05:58:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGt4v-0003Fd-Tj; Thu, 28 Nov 2024 23:58:05 -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 1tGt4s-0003FE-NZ for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 23:58:03 -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 1tGt4s-00007Z-E3 for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 23:58:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:Date:In-Reply-To:From:Mime-Version:To:Subject; bh=FcUaQnB+Yqnbra64uIlakx9lAqWGP9Mva3KL1MBt3Ss=; b=ueSzE6Yb2kyOqONKEDYP1hi5rFpYzetfye3etZ3/Llpvz6q8I1HAgrgDA4EiPy7WM2rNh11uz3nO1r7khqD9/X+osY9jVh+E6grdoriLcRLT1LtUG+T9UrYihpXJITqeharqhOYtONyqqFuRa8zDoYNyDMfXp8g9VjooBsrZGDq+omgG1O329VyFgj/tShqTLANWM4+MQlOz8fShDI4m10bweQUtrY/AsIzEjpO56BDwfx68oCge3Q8KFwlgiQWUBt9eFav9/RCq6VzLRUnSuhOZ35YIv86dZ7nnpQHhYtcRepRjVxydoTcXM7G8wUnO/ajq+9SIeYOG0hkDw4OQvw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGt4s-00086C-8U for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 23:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Nov 2024 04:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74507-submit@debbugs.gnu.org id=B74507.173285626131089 (code B ref 74507); Fri, 29 Nov 2024 04:58:02 +0000 Original-Received: (at 74507) by debbugs.gnu.org; 29 Nov 2024 04:57:41 +0000 Original-Received: from localhost ([127.0.0.1]:40574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGt4X-00085N-8G for submit@debbugs.gnu.org; Thu, 28 Nov 2024 23:57:41 -0500 Original-Received: from mail-pl1-f172.google.com ([209.85.214.172]:59712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGt4V-00085D-AC for 74507@debbugs.gnu.org; Thu, 28 Nov 2024 23:57:40 -0500 Original-Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-21532055aebso7504555ad.3 for <74507@debbugs.gnu.org>; Thu, 28 Nov 2024 20:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732856199; x=1733460999; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FcUaQnB+Yqnbra64uIlakx9lAqWGP9Mva3KL1MBt3Ss=; b=KvfuxRhk/V7olSxe4IaBMFCuI83Upd1t0RXLTTw3PzEKRgvYl+1j2hKJ7pKf5xyGfo S980zmOCyqEg877bdT/NEkArvOygfdRJSn7AUHu9Cn0sI57d3fSRddt5Lxu0WftHUYbF AtxFyj72yi3C7uhiamYd7I7f2H/4iMTOjLNhcD0vpHvo5xJAEw4aDdMoG+ajM7TfmgeE JSQakdAAi35HofOckvoMTRDCm18lVbLeCjKXC97CJpWXz15vTJyklSHihU5i12uMKiW8 9EPf9pDVZYrzeh6ZyEWmG9O54ZpgyggXDlzKCKP+2+snXQ4gXozy9VOg2BeqNeTa5jIW 2koQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732856199; x=1733460999; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FcUaQnB+Yqnbra64uIlakx9lAqWGP9Mva3KL1MBt3Ss=; b=e/YO5jIJSaFDXm6nWWIih98+YOqmUDVWuDagxq8LFhSaIr2tPVigwMDvgyS10sn5FU HOLzECcxCHoozouHXk7sPoIMiQa61Kk0hjA/0d77//D5zzBa6vR2tXrJz8WChHJBFAxl Ami5TUHkrj6Vgwg7yBdzqiweDQ/lV2ykMgAP0mvKbmEDPsO89YdLAZaSp5F4zPQV0Ois xr6Z6DP2P3CrZ4CgQQ/5l9ukVcBtTA5QEDe8oe5wUAAg+fnZ6ulxCkIO81FSdkYXV44g oD+803LqJcUe8Nlo5yoiSfKiJGUA7GoZatU4Cw/RK8ady712acNyrX1gipgQ65dM/ZSL /U9w== X-Gm-Message-State: AOJu0Yxs2pdYwKk0fZEqXoYisdPj5nUsD23EdTvZLhfHDhuDhQEi/Rtf lM5KAjQxrIBALU5tOxf40t1CUHRUpAtHrdWxEwkdaYCS/ENjNAj/3UGZOw== X-Gm-Gg: ASbGncsWlPFdJi6Rp5JeshUwgIcHYPBBbV5oyiivdCBGJLPoO1IFs5q1axw8h2C+I60 RpH9TIH3e6y7NvGfEZj23THSRNrFWN+AxT9XnHZ9nagb+k6P1RlS7gQHQg+JBCmbns4kwIQCy6n kWECFw7e1+DsnlZhnqFgCGxOsjdiTsXyroaqMZBZfE00qOPRPTTukFxx98TCTxRlMMFMXeZa4bS WUHebdOUyvvAAHiwkTOhsruJh1wEQZSmUO9peti7cH7977sIM/jsQtYZZGYm1lqJT0ewtyg2g== X-Google-Smtp-Source: AGHT+IHfrD2OUHVbCncb6KNWA4fvqqgW3ALRfsrrue6DzMl9vzwSJhZszdmeEYViokhed1OCjK0CDg== X-Received: by 2002:a17:902:f54a:b0:215:4362:bc76 with SMTP id d9443c01a7336-2154362bf24mr14974545ad.54.1732856198630; Thu, 28 Nov 2024 20:56:38 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:c885:af5e:9679:e419]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215219ac205sm22088735ad.235.2024.11.28.20.56.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Nov 2024 20:56:37 -0800 (PST) In-Reply-To: <87r071yov3.fsf@lambda.is> X-Mailer: Apple Mail (2.3776.700.51) 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:296075 Archived-At: > On Nov 24, 2024, at 1:15=E2=80=AFAM, J=C3=B8rgen Kvalsvik = wrote: >=20 > Tags: patch >=20 > Tags: patch >=20 >=20 > I found that the coumpounded statements are anchored to the wrong = object > when 1. the compound is not at beginning-of-line and 2. it is not > preceeded by a construct such as fndecl/for/if/while/etc., which = differs > from how c-mode indents it. >=20 > Non-BOL compound statements is actually quite common with macros and > testing frameworks (see the test case). For example, you want this to > indent: >=20 > TEST_CASE(1) { > assert (...); > } >=20 > The heuristic is quite course - it simply checks if the grandparent is > function-definition or not, which is really if this node is a = top-level > sibling in the function body. If that is the case, the old rules = should > apply and standalone-parent should be the guide; otherwise, it should = be > the parent-BOL. This feels a bit shaky but does seem to work well for > the test cases, and can be refined in the future. >=20 > <0001-Indent-compounds-c-ts-mode-when-is-not-BOL.patch> Thank you very much! Especially for the test case ;-) What=E2=80=99s the = progress of your copyright assignment? Has it completed? I=E2=80=99m working on refactoring the indentation rules for c-ts-mode. = Let me see if I can integrate this situation into the new rules I=E2=80=99= m writing. Yuan=