GNU bug report logs - #76908
31.0.50; Extending c-ts-common-baseline-indent-rule

Previous Next

Package: emacs;

Reported by: jm <at> pub.pink

Date: Mon, 10 Mar 2025 02:56:02 UTC

Severity: wishlist

Found in version 31.0.50

Done: john muhl <jm <at> pub.pink>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76908 in the body.
You can then email your comments to 76908 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#76908; Package emacs. (Mon, 10 Mar 2025 02:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to jm <at> pub.pink:
New bug report received and forwarded. Copy sent to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Mon, 10 Mar 2025 02:56:02 GMT) Full text and rfc822 format available.

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

From: jm <at> pub.pink
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; Extending c-ts-common-baseline-indent-rule
Date: Sun, 09 Mar 2025 21:55:24 -0500
Hi Yuan.

I’ve been working on replacing some of the bespoke indentation
rules in lua-ts-mode with c-ts-common-baseline-indent-rule and ran
into one spot it didn’t handle.

If the parent (table, args, params) starts with a comment all the
siblings follow that indentation instead of ignoring the comment
and falling back to the default indent-offset; e.g.

  -- currently lua-ts-mode indents like:
  local my_table = { -- there is a comment here
      x_offset = 12,
      y_offset = 30,
  }

  -- using c-ts-common-baseline-indent-rule we get:
  local my_table = { -- there is a comment here
                     x_offset = 12,
                     y_offset = 30,
  }

And similarly for arguments & parameters:

  -- current:
  very_fun(-- do the very fun stuff
      "This is a string",
      3.1415926535897932,
      { x = 1, y = 2 },
  )

  -- c-t-c-b-i-r:
  very_fun(-- do the very fun stuff
           "This is a string",
           3.1415926535897932,
           { x = 123, y = 99 },
  )

Is this something it could be extended to do or should I just
stick with custom rules for this kind of thing?

Other than that it’s pretty much eliminated the need for all the
other rules I was using to get this stuff working.

Thanks.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 10 Mar 2025 21:06:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76908; Package emacs. (Tue, 11 Mar 2025 09:54:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: jm <at> pub.pink
Cc: 76908 <at> debbugs.gnu.org
Subject: Re: bug#76908: 31.0.50; Extending c-ts-common-baseline-indent-rule
Date: Tue, 11 Mar 2025 02:52:54 -0700

> On Mar 9, 2025, at 7:55 PM, jm <at> pub.pink wrote:
> 
> Hi Yuan.
> 
> I’ve been working on replacing some of the bespoke indentation
> rules in lua-ts-mode with c-ts-common-baseline-indent-rule and ran
> into one spot it didn’t handle.

Glad to hear it’s getting used!

> 
> If the parent (table, args, params) starts with a comment all the
> siblings follow that indentation instead of ignoring the comment
> and falling back to the default indent-offset; e.g.
> 
>  -- currently lua-ts-mode indents like:
>  local my_table = { -- there is a comment here
>      x_offset = 12,
>      y_offset = 30,
>  }
> 
>  -- using c-ts-common-baseline-indent-rule we get:
>  local my_table = { -- there is a comment here
>                     x_offset = 12,
>                     y_offset = 30,
>  }
> 
> And similarly for arguments & parameters:
> 
>  -- current:
>  very_fun(-- do the very fun stuff
>      "This is a string",
>      3.1415926535897932,
>      { x = 1, y = 2 },
>  )
> 
>  -- c-t-c-b-i-r:
>  very_fun(-- do the very fun stuff
>           "This is a string",
>           3.1415926535897932,
>           { x = 123, y = 99 },
>  )
> 
> Is this something it could be extended to do or should I just
> stick with custom rules for this kind of thing?

The first example seems to work fine for me. The second example is indeed a bug, I fixed it.

I tried 

(defvar lua-ts--simple-indent-rules
  `((lua
     c-ts-common-baseline-indent-rule)))

with

(setq-local c-ts-common-indent-offset 'lua-ts-indent-offset)
(setq-local c-ts-common-list-indent-style 'simple)

(BTW you don’t need to set c-ts-common-indent-type-regexp-alist to use the baseline-indent-rule. I forgot to update the comment in Commentary.)

Yuan



Reply sent to john muhl <jm <at> pub.pink>:
You have taken responsibility. (Tue, 11 Mar 2025 17:18:03 GMT) Full text and rfc822 format available.

Notification sent to jm <at> pub.pink:
bug acknowledged by developer. (Tue, 11 Mar 2025 17:18:03 GMT) Full text and rfc822 format available.

Message #15 received at 76908-done <at> debbugs.gnu.org (full text, mbox):

From: john muhl <jm <at> pub.pink>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 76908-done <at> debbugs.gnu.org
Subject: Re: bug#76908: 31.0.50; Extending c-ts-common-baseline-indent-rule
Date: Tue, 11 Mar 2025 12:09:24 -0500
Yuan Fu <casouri <at> gmail.com> writes:

>> On Mar 9, 2025, at 7:55 PM, jm <at> pub.pink wrote:
>> 
>> Hi Yuan.
>> 
>> I’ve been working on replacing some of the bespoke indentation
>> rules in lua-ts-mode with c-ts-common-baseline-indent-rule and ran
>> into one spot it didn’t handle.
>
> Glad to hear it’s getting used!
>
>> 
>> If the parent (table, args, params) starts with a comment all the
>> siblings follow that indentation instead of ignoring the comment
>> and falling back to the default indent-offset; e.g.
>> 
>>  -- currently lua-ts-mode indents like:
>>  local my_table = { -- there is a comment here
>>      x_offset = 12,
>>      y_offset = 30,
>>  }
>> 
>>  -- using c-ts-common-baseline-indent-rule we get:
>>  local my_table = { -- there is a comment here
>>                     x_offset = 12,
>>                     y_offset = 30,
>>  }
>> 
>> And similarly for arguments & parameters:
>> 
>>  -- current:
>>  very_fun(-- do the very fun stuff
>>      "This is a string",
>>      3.1415926535897932,
>>      { x = 1, y = 2 },
>>  )
>> 
>>  -- c-t-c-b-i-r:
>>  very_fun(-- do the very fun stuff
>>           "This is a string",
>>           3.1415926535897932,
>>           { x = 123, y = 99 },
>>  )
>> 
>> Is this something it could be extended to do or should I just
>> stick with custom rules for this kind of thing?
>
> The first example seems to work fine for me.

You’re right. I must of got Emacs into a funky state or had the
wrong file loaded or something.

> The second example is indeed a bug, I fixed it.

Works perfect now. Thanks.

> I tried 
>
> (defvar lua-ts--simple-indent-rules
>   `((lua
>      c-ts-common-baseline-indent-rule)))
>
> with
>
> (setq-local c-ts-common-indent-offset 'lua-ts-indent-offset)
> (setq-local c-ts-common-list-indent-style 'simple)
>
> (BTW you don’t need to set c-ts-common-indent-type-regexp-alist to use the baseline-indent-rule. I forgot to update the comment in Commentary.)
>
> Yuan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Apr 2025 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 67 days ago.

Previous Next


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