bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66152: 30.0.50; Missing indent rules in c-ts-mode


From: Yuan Fu
Subject: bug#66152: 30.0.50; Missing indent rules in c-ts-mode
Date: Sun, 10 Dec 2023 18:16:49 -0800
User-agent: Mozilla Thunderbird



On 10/5/23 12:16 AM, Eli Zaretskii wrote:
Ping!  Yuan, I would really like to use the first patch in Emacs 29.2,
if it looks OK to you.

Cc: 66152@debbugs.gnu.org
Date: Fri, 29 Sep 2023 10:17:29 +0300
From: Eli Zaretskii <eliz@gnu.org>

Date: Tue, 26 Sep 2023 14:29:07 +0200
From: Augustin Chéneau (BTuin) <btuin@mailo.com>

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.

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:

<https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/net/bsd-comp.c?rev=1.17&content-type=text/plain>
(lines 277, 484, and 527)



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.
Yuan, any comments?  If the first patch looks good to you, I'd like to
install it on the release branch.
LGTM, I applied the first patch to emacs-29.

Yuan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]