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#66152: 30.0.50; Missing indent rules in c-ts-mode Date: Sun, 10 Dec 2023 18:41:35 -0800 Message-ID: <3e14a8c3-6518-44f5-a32a-25ffcf438e23@gmail.com> References: <1bb29ad2-270d-4b19-8d5f-90f23b9fd100@mailo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21880"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: Augustin =?UTF-8?Q?Ch=C3=A9neau?= (BTuin) , 66152@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 11 03:43:12 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 1rCWGE-0005V3-JY for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 11 Dec 2023 03:43:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCWFv-0005YU-Kv; Sun, 10 Dec 2023 21:42:51 -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 1rCWFs-0005Wq-5x for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 21:42:48 -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 1rCWFr-0006l3-U1 for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 21:42:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCWG6-0006U2-4M for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 21:43: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: Mon, 11 Dec 2023 02:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66152 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66152-submit@debbugs.gnu.org id=B66152.170226252424845 (code B ref 66152); Mon, 11 Dec 2023 02:43:02 +0000 Original-Received: (at 66152) by debbugs.gnu.org; 11 Dec 2023 02:42:04 +0000 Original-Received: from localhost ([127.0.0.1]:52183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCWF7-0006SL-D1 for submit@debbugs.gnu.org; Sun, 10 Dec 2023 21:42:04 -0500 Original-Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:44177) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCWF3-0006Rz-16 for 66152@debbugs.gnu.org; Sun, 10 Dec 2023 21:42:00 -0500 Original-Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b88f2a37deso3189785b6e.0 for <66152@debbugs.gnu.org>; Sun, 10 Dec 2023 18:41:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702262497; x=1702867297; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=a8OVCKas6c4qmLW7Lhia4bAVY1/dinoddjOsT3sGP4A=; b=NhJW9d+MyC0pSjXDNekU4XsY/BkslnCjYxEgSbTIPw5zgbHm2XeWtaM/iQNlfMbRwn vzhPF/q5TxjahqhsT9rFkrfZRimu6MxQCeuGInQ7kIE5s1eBXorSfuiw1VcL2hCawtXT gGAbw1X7YppL+LIN9vj/6tyo4eYUd2NXOSZRrVmqnaDfMGZOw6skWcNEJhq/LecRbbmm 2KrzFnTtowWCL1aUg/RwrJEX0JbYYPYDF+44GqXTT6UndzX1NDIyRQna7cdwIzoYjtgo dvJTuWegpUEOkClInc+4GghCr4WSqRlA0mIXOfVt7u7P0jnqJMzBNeSNTa7Sg2zDTioz b5fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702262497; x=1702867297; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a8OVCKas6c4qmLW7Lhia4bAVY1/dinoddjOsT3sGP4A=; b=GOjQ/A6sMGoXkQduR+yc/gCbXLdfmRF24A6dILAxCosBfX3jH954iJBBtEAnrHUxQJ UCGe1ex44tUpQvqYIrKfBXf+k8CAHoBwELsEQwi1qe3ixNBg8mkDRn92Cw5F0E3BjxWx GmU5IH1x1qEfjX1wxAq5Ooj+FreFyHWPpexcAE11JFP+HjhB8LwwTGhmBqk84MjE5auC mTokkBMW1DklcAahxkcRKTCJcS21MFhFT12w9KWfYh1NZZ4l5MdmSHw2uFLJgM843AdN ZP1jb+cqE2+R0KIaOoYWsjjt3MnB4q30I0wm6KWOxNElTGzFdMA41MrtBe2/OPSqk/h9 3tQA== X-Gm-Message-State: AOJu0Yyshmh5qkZPEAhbJY8qH5EdweDwNBsV1iD69TKWS81VI1bF/LF8 HYskh99WK+fk7hPbw5TZOoQ= X-Google-Smtp-Source: AGHT+IFAkeXP4wRjtyM9vsOKibEfkYqX6ei799hHqyaxSlFoIrmjwV4Td/+oCub2X3fPoOY1qJf6Ow== X-Received: by 2002:a05:6808:1401:b0:3b8:b063:5053 with SMTP id w1-20020a056808140100b003b8b0635053mr5037139oiv.84.1702262496816; Sun, 10 Dec 2023 18:41:36 -0800 (PST) Original-Received: from [192.168.1.7] (172-117-161-177.res.spectrum.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id n9-20020a056a000d4900b006ce7e75cfa7sm5146208pfv.57.2023.12.10.18.41.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Dec 2023 18:41:36 -0800 (PST) Content-Language: en-US In-Reply-To: <1bb29ad2-270d-4b19-8d5f-90f23b9fd100@mailo.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:275960 Archived-At: On 9/26/23 5:29 AM, Augustin Chéneau (BTuin) wrote: > I found some more issues. > > First, there is no rule for an element in an else clause: > > > if (true) >   do_something(); > else > do_something_else(); > > > "do_something_else" is not indented. Right. tree-sitter-c recently changed their grammar and added else_clause. The fix for this is pushed to emacs-29 a few days ago. > > There is also something weird with the bsd indent style.  It indents > do_something and do_something_else to parent-bol with 0 offset, so the > result is: > > if (true) > do_something(); > else > do_something_else(); > > > It is very different from the bsd style from c-mode, which produces this: > > if (true) >     do_something(); > else >     do_something_else(); > > By looking at random files from OpenBSD, they do indent their > expressions inside if and else: > > > > (lines 277, 484, and 527) > Thanks for reporting this, probably not a lot of people use c-ts-mode with bsd style, and things like this goes under the radar. I pushed a fix for it. > > Also there is a second patch which tries to handle specific types of > comments.  I don't know how popular it is, but some people use these > kind of comments: > > /*---------. > | %param.  | > `---------*/ > > Here we want the vertical bar ("|") to be indented at the same column > as the first "/". > > Currently the result is this: > > /*---------. >   | %param.  | >   `---------*/ > > This patch is a just proof of concept.  If this new behavior is indeed > wanted, I would clean it up and adapt other modes. The gallery of artisan C comments is just endless :-) If we can support this style, it's definitely good, the only thing to watch out for is that the rules could unintentionally match some other comments that aren't really this style. Like, does people do this: /*  |  |  |  */ in the wild? I don't know, maybe we need a embedded gpt-4 for formatting comments. Yuan