GNU bug report logs - #74507
[PATCH] Indent compounds c-ts-mode when { is not BOL

Previous Next

Package: emacs;

Reported by: Jørgen Kvalsvik <j <at> lambda.is>

Date: Sun, 24 Nov 2024 09:16:02 UTC

Severity: normal

Tags: patch

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jørgen Kvalsvik <j <at> lambda.is>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Indent compounds c-ts-mode when { is not BOL
Date: Sun, 24 Nov 2024 10:15:12 +0100
[Message part 1 (text/plain, inline)]
Tags: patch

Tags: patch


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.

Non-BOL compound statements is actually quite common with macros and
testing frameworks (see the test case). For example, you want this to
indent:

TEST_CASE(1) {
    assert (...);
}

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.

[0001-Indent-compounds-c-ts-mode-when-is-not-BOL.patch (text/patch, attachment)]

This bug report was last modified 229 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.