GNU bug report logs - #59763
29.0.60; Filling for c-ts-mode

Previous Next

Package: emacs;

Reported by: Yuan Fu <casouri <at> gmail.com>

Date: Fri, 2 Dec 2022 05:34:01 UTC

Severity: wishlist

Found in version 29.0.60

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

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 59763 in the body.
You can then email your comments to 59763 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 bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Fri, 02 Dec 2022 05:34:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yuan Fu <casouri <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 02 Dec 2022 05:34:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Bug Report Emacs <bug-gnu-emacs <at> gnu.org>
Subject: 29.0.60; Filling for c-ts-mode
Date: Thu, 1 Dec 2022 21:33:06 -0800
IMO For c-ts-mode to be usable we need to have at least a basic filling
function. Below is the function I have in my init.el, could someone have
a look and see if it’s good? Alternatively we could copy out the comment
and fill it in a temp buffer with c-mode, but I didn’t have the time to try
it out and see how well it works.

(defun ts-c-fill-paragraph (&optional arg)
  (interactive)
  (let* ((node (treesit-node-at (point)))
         (start (treesit-node-start node))
         (end (treesit-node-end node))
         (pstart (save-excursion
                   (forward-paragraph -1)
                   (skip-syntax-forward "-")
                   (point)))
         (pend (save-excursion
                 (forward-paragraph 1)
                 (point))))
    (when (equal (treesit-node-type node) "comment")
      (fill-region (max start pstart) (min end pend)))
    t))

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Fri, 02 Dec 2022 14:59:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Fri, 02 Dec 2022 16:58:14 +0200
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Thu, 1 Dec 2022 21:33:06 -0800
> 
> 
> IMO For c-ts-mode to be usable we need to have at least a basic filling
> function. Below is the function I have in my init.el, could someone have
> a look and see if it’s good? Alternatively we could copy out the comment
> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
> it out and see how well it works.

Thanks.

From quick testing, I see a problem:

  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
    the newline between the two lines of the comment, and invoke the
    function.  Observe how the first non-blank character of the comment's
    second line is aligned with the "/*" on the previous line, not with the
    text after "/*" as I'd expect.

Btw, this command should be bound to M-q in ts-c-mode.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 03 Dec 2022 00:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Sat, 03 Dec 2022 00:55:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Theodor Thornhill <theo <at> thornhill.no>, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Fri, 2 Dec 2022 16:54:43 -0800

> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>> 
>> 
>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>> function. Below is the function I have in my init.el, could someone have
>> a look and see if it’s good? Alternatively we could copy out the comment
>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>> it out and see how well it works.
> 
> Thanks.
> 
> From quick testing, I see a problem:
> 
>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>    the newline between the two lines of the comment, and invoke the
>    function.  Observe how the first non-blank character of the comment's
>    second line is aligned with the "/*" on the previous line, not with the
>    text after "/*" as I'd expect.

I see. I’ll need to look at how cc-mode fill comments.

> 
> Btw, this command should be bound to M-q in ts-c-mode.

Will do, once our fill function works well. BTW, Theo, if you have any idea, don’t hesitate to go ahead :-) No obligations, of course.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Mon, 05 Dec 2022 11:48:02 GMT) Full text and rfc822 format available.

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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Mon, 05 Dec 2022 12:47:05 +0100
Yuan Fu <casouri <at> gmail.com> writes:

>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> 
>>> From: Yuan Fu <casouri <at> gmail.com>
>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>> 
>>> 
>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>> function. Below is the function I have in my init.el, could someone have
>>> a look and see if it’s good? Alternatively we could copy out the comment
>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>> it out and see how well it works.
>> 
>> Thanks.
>> 
>> From quick testing, I see a problem:
>> 
>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>    the newline between the two lines of the comment, and invoke the
>>    function.  Observe how the first non-blank character of the comment's
>>    second line is aligned with the "/*" on the previous line, not with the
>>    text after "/*" as I'd expect.
>
> I see. I’ll need to look at how cc-mode fill comments.
>
>> 
>> Btw, this command should be bound to M-q in ts-c-mode.
>
> Will do, once our fill function works well. BTW, Theo, if you have any
> idea, don’t hesitate to go ahead :-) No obligations, of course.
>
> Yuan

Sure!  Added to my list :)  I had a function at some point that used
c-mode to do this. I'll see if I can polish it a little.

Theo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Sat, 24 Dec 2022 08:37:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Sat, 24 Dec 2022 00:36:21 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> Yuan Fu <casouri <at> gmail.com> writes:
>
>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>> 
>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>> 
>>>> 
>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>> function. Below is the function I have in my init.el, could someone have
>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>> it out and see how well it works.
>>> 
>>> Thanks.
>>> 
>>> From quick testing, I see a problem:
>>> 
>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>    the newline between the two lines of the comment, and invoke the
>>>    function.  Observe how the first non-blank character of the comment's
>>>    second line is aligned with the "/*" on the previous line, not with the
>>>    text after "/*" as I'd expect.
>>
>> I see. I’ll need to look at how cc-mode fill comments.
>>
>>> 
>>> Btw, this command should be bound to M-q in ts-c-mode.
>>
>> Will do, once our fill function works well. BTW, Theo, if you have any
>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>
>> Yuan
>
> Sure!  Added to my list :)  I had a function at some point that used
> c-mode to do this. I'll see if I can polish it a little.

I did some work in filling, it should work like cc-mode in like 90% of
the cases now, yay!

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Sat, 24 Dec 2022 08:45:02 GMT) Full text and rfc822 format available.

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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Sat, 24 Dec 2022 09:42:30 +0100

On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>
>Theodor Thornhill <theo <at> thornhill.no> writes:
>
>> Yuan Fu <casouri <at> gmail.com> writes:
>>
>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>> 
>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>> 
>>>>> 
>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>> function. Below is the function I have in my init.el, could someone have
>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>> it out and see how well it works.
>>>> 
>>>> Thanks.
>>>> 
>>>> From quick testing, I see a problem:
>>>> 
>>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>    the newline between the two lines of the comment, and invoke the
>>>>    function.  Observe how the first non-blank character of the comment's
>>>>    second line is aligned with the "/*" on the previous line, not with the
>>>>    text after "/*" as I'd expect.
>>>
>>> I see. I’ll need to look at how cc-mode fill comments.
>>>
>>>> 
>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>
>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>
>>> Yuan
>>
>> Sure!  Added to my list :)  I had a function at some point that used
>> c-mode to do this. I'll see if I can polish it a little.
>
>I did some work in filling, it should work like cc-mode in like 90% of
>the cases now, yay!
>
>Yuan

Nice! For all cc-ts-modes?

Theo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Sun, 25 Dec 2022 01:31:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: eliz <at> gnu.org, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Sat, 24 Dec 2022 17:30:35 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>
>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>
>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>
>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>> 
>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>> 
>>>>>> 
>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>> it out and see how well it works.
>>>>> 
>>>>> Thanks.
>>>>> 
>>>>> From quick testing, I see a problem:
>>>>> 
>>>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>    the newline between the two lines of the comment, and invoke the
>>>>>    function.  Observe how the first non-blank character of the comment's
>>>>>    second line is aligned with the "/*" on the previous line, not with the
>>>>>    text after "/*" as I'd expect.
>>>>
>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>
>>>>> 
>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>
>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>
>>>> Yuan
>>>
>>> Sure!  Added to my list :)  I had a function at some point that used
>>> c-mode to do this. I'll see if I can polish it a little.
>>
>>I did some work in filling, it should work like cc-mode in like 90% of
>>the cases now, yay!
>>
>>Yuan
>
> Nice! For all cc-ts-modes?

I only added for c and c++, but support for other modes should be
identical. And I think we should have something equivalent to cc-mode’s
init which sets up things that are the same in all C-like languages,
basically comments and filling.

But I wonder where should we put it, I guess it’s fine to leave it in
c-ts-mode, since there really isn’t much code. Having other modes to
require c-ts-mode shouldn’t be a big problem, I think?

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Sun, 25 Dec 2022 07:34:02 GMT) Full text and rfc822 format available.

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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>
Cc: eliz <at> gnu.org, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Sun, 25 Dec 2022 08:33:19 +0100

On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>
>Theodor Thornhill <theo <at> thornhill.no> writes:
>
>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>
>>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>>
>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>
>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>> 
>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>> 
>>>>>>> 
>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>> it out and see how well it works.
>>>>>> 
>>>>>> Thanks.
>>>>>> 
>>>>>> From quick testing, I see a problem:
>>>>>> 
>>>>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>    the newline between the two lines of the comment, and invoke the
>>>>>>    function.  Observe how the first non-blank character of the comment's
>>>>>>    second line is aligned with the "/*" on the previous line, not with the
>>>>>>    text after "/*" as I'd expect.
>>>>>
>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>
>>>>>> 
>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>
>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>
>>>>> Yuan
>>>>
>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>> c-mode to do this. I'll see if I can polish it a little.
>>>
>>>I did some work in filling, it should work like cc-mode in like 90% of
>>>the cases now, yay!
>>>
>>>Yuan
>>
>> Nice! For all cc-ts-modes?
>
>I only added for c and c++, but support for other modes should be
>identical. And I think we should have something equivalent to cc-mode’s
>init which sets up things that are the same in all C-like languages,
>basically comments and filling.
>
>But I wonder where should we put it, I guess it’s fine to leave it in
>c-ts-mode, since there really isn’t much code. Having other modes to
>require c-ts-mode shouldn’t be a big problem, I think?
>
>Yuan

How about just having treesit-utils.el, or something like that? There are probably many things in the future that will be common among modes, yet won't really warrant inheritance. I think we have such an example in js/typescript too, iirc.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Mon, 26 Dec 2022 21:32:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: eliz <at> gnu.org, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Mon, 26 Dec 2022 13:31:08 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>
>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>
>>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>
>>>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>
>>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>>
>>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>> 
>>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>>> 
>>>>>>>> 
>>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>>> it out and see how well it works.
>>>>>>> 
>>>>>>> Thanks.
>>>>>>> 
>>>>>>> From quick testing, I see a problem:
>>>>>>> 
>>>>>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>>    the newline between the two lines of the comment, and invoke the
>>>>>>>    function.  Observe how the first non-blank character of the comment's
>>>>>>>    second line is aligned with the "/*" on the previous line, not with the
>>>>>>>    text after "/*" as I'd expect.
>>>>>>
>>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>>
>>>>>>> 
>>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>>
>>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>>
>>>>>> Yuan
>>>>>
>>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>>> c-mode to do this. I'll see if I can polish it a little.
>>>>
>>>>I did some work in filling, it should work like cc-mode in like 90% of
>>>>the cases now, yay!
>>>>
>>>>Yuan
>>>
>>> Nice! For all cc-ts-modes?
>>
>>I only added for c and c++, but support for other modes should be
>>identical. And I think we should have something equivalent to cc-mode’s
>>init which sets up things that are the same in all C-like languages,
>>basically comments and filling.

I added indent and filling for other C-like modes.

>>But I wonder where should we put it, I guess it’s fine to leave it in
>>c-ts-mode, since there really isn’t much code. Having other modes to
>>require c-ts-mode shouldn’t be a big problem, I think?
>>
>>Yuan
>
> How about just having treesit-utils.el, or something like that? There
> are probably many things in the future that will be common among
> modes, yet won't really warrant inheritance. I think we have such an
> example in js/typescript too, iirc.

If it’s shared across all tree-sitter modes, it should be in treesit.el,
of course. We are talking about things shared by tree-sitter C-like
modes, so the scope is smaller.

Since right now it’s only a handful functions, I made other modes
require c-ts-mode.el. In the future if things accumulate, we can put
things into a separate file (c-ts-mode-common.el or something).

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Mon, 26 Dec 2022 22:04:01 GMT) Full text and rfc822 format available.

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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>
Cc: eliz <at> gnu.org, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Mon, 26 Dec 2022 23:03:36 +0100
Yuan Fu <casouri <at> gmail.com> writes:

> Theodor Thornhill <theo <at> thornhill.no> writes:
>
>> On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>
>>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>>
>>>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>>
>>>>>Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>
>>>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>>>
>>>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>>> 
>>>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>>>> it out and see how well it works.
>>>>>>>> 
>>>>>>>> Thanks.
>>>>>>>> 
>>>>>>>> From quick testing, I see a problem:
>>>>>>>> 
>>>>>>>>  . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>>>    the newline between the two lines of the comment, and invoke the
>>>>>>>>    function.  Observe how the first non-blank character of the comment's
>>>>>>>>    second line is aligned with the "/*" on the previous line, not with the
>>>>>>>>    text after "/*" as I'd expect.
>>>>>>>
>>>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>>>
>>>>>>>> 
>>>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>>>
>>>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>>>
>>>>>>> Yuan
>>>>>>
>>>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>>>> c-mode to do this. I'll see if I can polish it a little.
>>>>>
>>>>>I did some work in filling, it should work like cc-mode in like 90% of
>>>>>the cases now, yay!
>>>>>
>>>>>Yuan
>>>>
>>>> Nice! For all cc-ts-modes?
>>>
>>>I only added for c and c++, but support for other modes should be
>>>identical. And I think we should have something equivalent to cc-mode’s
>>>init which sets up things that are the same in all C-like languages,
>>>basically comments and filling.
>
> I added indent and filling for other C-like modes.
>
>>>But I wonder where should we put it, I guess it’s fine to leave it in
>>>c-ts-mode, since there really isn’t much code. Having other modes to
>>>require c-ts-mode shouldn’t be a big problem, I think?
>>>
>>>Yuan
>>
>> How about just having treesit-utils.el, or something like that? There
>> are probably many things in the future that will be common among
>> modes, yet won't really warrant inheritance. I think we have such an
>> example in js/typescript too, iirc.
>
> If it’s shared across all tree-sitter modes, it should be in treesit.el,
> of course. We are talking about things shared by tree-sitter C-like
> modes, so the scope is smaller.
>
> Since right now it’s only a handful functions, I made other modes
> require c-ts-mode.el. In the future if things accumulate, we can put
> things into a separate file (c-ts-mode-common.el or something).
>

Sure.  I just don't like it when these namespaces blend too much.  But
your call :-)

Theo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Mon, 26 Dec 2022 22:52:01 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Mon, 26 Dec 2022 14:51:08 -0800

> On Dec 26, 2022, at 2:03 PM, Theodor Thornhill <theo <at> thornhill.no> wrote:
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
>> Theodor Thornhill <theo <at> thornhill.no> writes:
>> 
>>> On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>> 
>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>> 
>>>>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>>> 
>>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>> 
>>>>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>>>> 
>>>>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>>>> 
>>>>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>>>>> it out and see how well it works.
>>>>>>>>> 
>>>>>>>>> Thanks.
>>>>>>>>> 
>>>>>>>>> From quick testing, I see a problem:
>>>>>>>>> 
>>>>>>>>> . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>>>>   the newline between the two lines of the comment, and invoke the
>>>>>>>>>   function.  Observe how the first non-blank character of the comment's
>>>>>>>>>   second line is aligned with the "/*" on the previous line, not with the
>>>>>>>>>   text after "/*" as I'd expect.
>>>>>>>> 
>>>>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>>>> 
>>>>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>>>> 
>>>>>>>> Yuan
>>>>>>> 
>>>>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>>>>> c-mode to do this. I'll see if I can polish it a little.
>>>>>> 
>>>>>> I did some work in filling, it should work like cc-mode in like 90% of
>>>>>> the cases now, yay!
>>>>>> 
>>>>>> Yuan
>>>>> 
>>>>> Nice! For all cc-ts-modes?
>>>> 
>>>> I only added for c and c++, but support for other modes should be
>>>> identical. And I think we should have something equivalent to cc-mode’s
>>>> init which sets up things that are the same in all C-like languages,
>>>> basically comments and filling.
>> 
>> I added indent and filling for other C-like modes.
>> 
>>>> But I wonder where should we put it, I guess it’s fine to leave it in
>>>> c-ts-mode, since there really isn’t much code. Having other modes to
>>>> require c-ts-mode shouldn’t be a big problem, I think?
>>>> 
>>>> Yuan
>>> 
>>> How about just having treesit-utils.el, or something like that? There
>>> are probably many things in the future that will be common among
>>> modes, yet won't really warrant inheritance. I think we have such an
>>> example in js/typescript too, iirc.
>> 
>> If it’s shared across all tree-sitter modes, it should be in treesit.el,
>> of course. We are talking about things shared by tree-sitter C-like
>> modes, so the scope is smaller.
>> 
>> Since right now it’s only a handful functions, I made other modes
>> require c-ts-mode.el. In the future if things accumulate, we can put
>> things into a separate file (c-ts-mode-common.el or something).
>> 
> 
> Sure.  I just don't like it when these namespaces blend too much.  But
> your call :-)

It can be treesit-c-common.el or something. We’ll figure it out when the time comes ;-)

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59763; Package emacs. (Mon, 26 Dec 2022 23:01:02 GMT) Full text and rfc822 format available.

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

From: Theodor Thornhill <theo <at> thornhill.no>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59763 <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Tue, 27 Dec 2022 00:00:42 +0100
Yuan Fu <casouri <at> gmail.com> writes:

>> On Dec 26, 2022, at 2:03 PM, Theodor Thornhill <theo <at> thornhill.no> wrote:
>> 
>> Yuan Fu <casouri <at> gmail.com> writes:
>> 
>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>> 
>>>> On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>> 
>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>> 
>>>>>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>>>> 
>>>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>>> 
>>>>>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>>>>> 
>>>>>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>>>>> 
>>>>>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>>>>>> it out and see how well it works.
>>>>>>>>>> 
>>>>>>>>>> Thanks.
>>>>>>>>>> 
>>>>>>>>>> From quick testing, I see a problem:
>>>>>>>>>> 
>>>>>>>>>> . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>>>>>   the newline between the two lines of the comment, and invoke the
>>>>>>>>>>   function.  Observe how the first non-blank character of the comment's
>>>>>>>>>>   second line is aligned with the "/*" on the previous line, not with the
>>>>>>>>>>   text after "/*" as I'd expect.
>>>>>>>>> 
>>>>>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>>>>> 
>>>>>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>>>>> 
>>>>>>>>> Yuan
>>>>>>>> 
>>>>>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>>>>>> c-mode to do this. I'll see if I can polish it a little.
>>>>>>> 
>>>>>>> I did some work in filling, it should work like cc-mode in like 90% of
>>>>>>> the cases now, yay!
>>>>>>> 
>>>>>>> Yuan
>>>>>> 
>>>>>> Nice! For all cc-ts-modes?
>>>>> 
>>>>> I only added for c and c++, but support for other modes should be
>>>>> identical. And I think we should have something equivalent to cc-mode’s
>>>>> init which sets up things that are the same in all C-like languages,
>>>>> basically comments and filling.
>>> 
>>> I added indent and filling for other C-like modes.
>>> 
>>>>> But I wonder where should we put it, I guess it’s fine to leave it in
>>>>> c-ts-mode, since there really isn’t much code. Having other modes to
>>>>> require c-ts-mode shouldn’t be a big problem, I think?
>>>>> 
>>>>> Yuan
>>>> 
>>>> How about just having treesit-utils.el, or something like that? There
>>>> are probably many things in the future that will be common among
>>>> modes, yet won't really warrant inheritance. I think we have such an
>>>> example in js/typescript too, iirc.
>>> 
>>> If it’s shared across all tree-sitter modes, it should be in treesit.el,
>>> of course. We are talking about things shared by tree-sitter C-like
>>> modes, so the scope is smaller.
>>> 
>>> Since right now it’s only a handful functions, I made other modes
>>> require c-ts-mode.el. In the future if things accumulate, we can put
>>> things into a separate file (c-ts-mode-common.el or something).
>>> 
>> 
>> Sure.  I just don't like it when these namespaces blend too much.  But
>> your call :-)
>
> It can be treesit-c-common.el or something. We’ll figure it out when the time comes ;-)
>

Yep :)
Theo




Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Sat, 07 Jan 2023 23:12:02 GMT) Full text and rfc822 format available.

Notification sent to Yuan Fu <casouri <at> gmail.com>:
bug acknowledged by developer. (Sat, 07 Jan 2023 23:12:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 59763-done <at> debbugs.gnu.org
Subject: Re: bug#59763: 29.0.60; Filling for c-ts-mode
Date: Sat, 7 Jan 2023 15:11:07 -0800
Theodor Thornhill <theo <at> thornhill.no> writes:

> Yuan Fu <casouri <at> gmail.com> writes:
>
>>> On Dec 26, 2022, at 2:03 PM, Theodor Thornhill <theo <at> thornhill.no> wrote:
>>> 
>>> Yuan Fu <casouri <at> gmail.com> writes:
>>> 
>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>> 
>>>>> On 25 December 2022 02:30:35 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>>> 
>>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>> 
>>>>>>> On 24 December 2022 09:36:21 CET, Yuan Fu <casouri <at> gmail.com> wrote:
>>>>>>>> 
>>>>>>>> Theodor Thornhill <theo <at> thornhill.no> writes:
>>>>>>>> 
>>>>>>>>> Yuan Fu <casouri <at> gmail.com> writes:
>>>>>>>>> 
>>>>>>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> From: Yuan Fu <casouri <at> gmail.com>
>>>>>>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> IMO For c-ts-mode to be usable we need to have at least a basic filling
>>>>>>>>>>>> function. Below is the function I have in my init.el, could someone have
>>>>>>>>>>>> a look and see if it’s good? Alternatively we could copy out the comment
>>>>>>>>>>>> and fill it in a temp buffer with c-mode, but I didn’t have the time to try
>>>>>>>>>>>> it out and see how well it works.
>>>>>>>>>>> 
>>>>>>>>>>> Thanks.
>>>>>>>>>>> 
>>>>>>>>>>> From quick testing, I see a problem:
>>>>>>>>>>> 
>>>>>>>>>>> . Visit dispnew.c and go to the comment that starts on line 324.  Delete
>>>>>>>>>>>   the newline between the two lines of the comment, and invoke the
>>>>>>>>>>>   function.  Observe how the first non-blank character of the comment's
>>>>>>>>>>>   second line is aligned with the "/*" on the previous line, not with the
>>>>>>>>>>>   text after "/*" as I'd expect.
>>>>>>>>>> 
>>>>>>>>>> I see. I’ll need to look at how cc-mode fill comments.
>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> Btw, this command should be bound to M-q in ts-c-mode.
>>>>>>>>>> 
>>>>>>>>>> Will do, once our fill function works well. BTW, Theo, if you have any
>>>>>>>>>> idea, don’t hesitate to go ahead :-) No obligations, of course.
>>>>>>>>>> 
>>>>>>>>>> Yuan
>>>>>>>>> 
>>>>>>>>> Sure!  Added to my list :)  I had a function at some point that used
>>>>>>>>> c-mode to do this. I'll see if I can polish it a little.
>>>>>>>> 
>>>>>>>> I did some work in filling, it should work like cc-mode in like 90% of
>>>>>>>> the cases now, yay!
>>>>>>>> 
>>>>>>>> Yuan
>>>>>>> 
>>>>>>> Nice! For all cc-ts-modes?
>>>>>> 
>>>>>> I only added for c and c++, but support for other modes should be
>>>>>> identical. And I think we should have something equivalent to cc-mode’s
>>>>>> init which sets up things that are the same in all C-like languages,
>>>>>> basically comments and filling.
>>>> 
>>>> I added indent and filling for other C-like modes.
>>>> 
>>>>>> But I wonder where should we put it, I guess it’s fine to leave it in
>>>>>> c-ts-mode, since there really isn’t much code. Having other modes to
>>>>>> require c-ts-mode shouldn’t be a big problem, I think?
>>>>>> 
>>>>>> Yuan
>>>>> 
>>>>> How about just having treesit-utils.el, or something like that? There
>>>>> are probably many things in the future that will be common among
>>>>> modes, yet won't really warrant inheritance. I think we have such an
>>>>> example in js/typescript too, iirc.
>>>> 
>>>> If it’s shared across all tree-sitter modes, it should be in treesit.el,
>>>> of course. We are talking about things shared by tree-sitter C-like
>>>> modes, so the scope is smaller.
>>>> 
>>>> Since right now it’s only a handful functions, I made other modes
>>>> require c-ts-mode.el. In the future if things accumulate, we can put
>>>> things into a separate file (c-ts-mode-common.el or something).
>>>> 
>>> 
>>> Sure.  I just don't like it when these namespaces blend too much.  But
>>> your call :-)
>>
>> It can be treesit-c-common.el or something. We’ll figure it out when the time comes ;-)
>>
>
> Yep :)
> Theo

I’ve added this to other modes, closing this report.

Yuan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Feb 2023 12:24:05 GMT) Full text and rfc822 format available.

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

Previous Next


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