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

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

bug#62717: 29.0.60; c-ts-mode does not indent the first line in a functi


From: Dmitry Gutov
Subject: 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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 09/04/2023 20:37, Eli Zaretskii wrote:
Date: Sun, 9 Apr 2023 19:33:20 +0300
Cc:mardani29@yahoo.es,theo@thornhill.no,casouri@gmail.com,
  62717@debbugs.gnu.org,joaotavora@gmail.com,acm@muc.de
From: Dmitry Gutov<dmitry@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.





reply via email to

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