GNU bug report logs - #62717
29.0.60; c-ts-mode does not indent the first line in a function after RET

Previous Next

Package: emacs;

Reported by: Daniel Martín <mardani29 <at> yahoo.es>

Date: Fri, 7 Apr 2023 19:50:01 UTC

Severity: normal

Found in version 29.0.60

Full log


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

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, theo <at> thornhill.no, 62717 <at> debbugs.gnu.org,
 mardani29 <at> yahoo.es, joaotavora <at> gmail.com, acm <at> muc.de
Subject: Re: bug#62717: 29.0.60; c-ts-mode does not indent the first line in a
 function after RET
Date: Mon, 10 Apr 2023 03:36:35 +0300
On 09/04/2023 20:37, Eli Zaretskii wrote:
>> Date: Sun, 9 Apr 2023 19:33:20 +0300
>> Cc:mardani29 <at> yahoo.es,theo <at> thornhill.no,casouri <at> gmail.com,
>>   62717 <at> debbugs.gnu.org,joaotavora <at> gmail.com,acm <at> muc.de
>> From: Dmitry Gutov<dmitry <at> gutov.dev>
>>
>>> If the patch solves some of the problems, passes the test suite, and
>>> doesn't introduce any regressions you see, I think you should install
>>> it (unless someone here objects).
>> With this kind of change, it's hard to judge regression potential in
>> advance. I don't really write C/C++ myself with any regularity. And our
>> test suite doesn't really work incomplete parse trees, I think.
>>
>> So if we want this in emacs-29, I think someone interested should try
>> running with this patch applied, at least for a little bit. Maybe just
>> wait for a couple of days, if Daniel is testing it already.
> The pretest will be out VSN.  Maybe you should install this, and we
> can then back it out if people complain.  FWIW, I intend to use only
> c-ts-mode when I the pretest is out, so if there are regressions, I
> think I will see it soon enough.

Okay, SGTM. I've pushed the patch to emacs-29.

Note that there remains a bunch of more complex cases that don't indent 
well while there are no closing braces in the buffer.

Examples:

  int main() {
    for (;;) {<RET>

(including every variation where some chars are deleted from the end of 
the second line), or

  int main() {
    if (2 == 2)<RET>

or

  int main() {
    if (2 == 2)
      foo();
    else<RET>

etc.

Enumerating every such case to create a special indentation logic seems 
a little tiring. Though if 2-3 of them are determined to be the most 
important ones, that might be doable.

But again, as long as there is at least one '}' after point, though, 
indentation in all of these cases improves. Though perhaps not ideally 
sometimes (e.g. for parenless if/else clauses the indentation starts out 
without the additional level).

Anyway, the case described in the report should now be working. Whether 
to close the bug or not, it's up to you and other interested parties.




This bug report was last modified 2 years and 67 days ago.

Previous Next


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