[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#70641: 29.1.90; default-indent-new-line cannot put comment delimiter
From: |
Yuan Fu |
Subject: |
bug#70641: 29.1.90; default-indent-new-line cannot put comment delimiter on c-ts-mode |
Date: |
Mon, 29 Apr 2024 21:57:18 -0700 |
> On Apr 29, 2024, at 12:42 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: 김희석 <hskimse1@gmail.com>
>> Date: Mon, 29 Apr 2024 11:12:35 +0900
>>
>>
>>
>> On c-mode, deurn default-indent-new-line auto-indent and
>> put delimitors on multiple lines of comment.
>>
>> For example, if there is comments like this:
>> /**
>> * Comment like
>> * this []
>> */
>> When I press M-j (default-indent-new-line) on the point [], on
>> c-mode, emacs indent and put comment delimiter automatically
>> like this:
>> /**
>> * Comment like
>> * this
>> * []
>> */
>> However on c-ts-mode, it does not works. It indents well, but
>> could not find or put the comment delimiter on new line when
>> I press M-j.
>> /**
>> * Comment like
>> * this
>> []
>> */
>> On c-ts-mode, I found that the default value of variable comment-multi-line
>> is nil, which was t on c-mode, and above behavior is happend when I set
>> this value to t. When it was nil, comment become like this:
>> /**
>> * Comment like
>> * this *//*
>> []
>> */
>> Which is intended behavior.
>
> c-mode defines a special value for comment-line-break-function,
> whereas c-ts-mode does not. Yuan, can you look into adding this?
This sounds like #70074. I’ve recently added a c-ts-mode version of
comment-line-break-function on master. (That function works for any C-like
language.)
>
>> Also, on c-mode, when I write multiple lines of comment with first line
>> of comment is "/**", (like above examples) that block is set to have
>> the same font-lock face as string to make it easier to read, but
>> in c-ts-mode that behavior doesn't happen and they all have
>> the same face.
>
> That's a completely separate issue, which should have been reported
> separately. It looks like c-mode uses font-lock-doc-face in those
> comments, not font-lock-comment-face. See the various uses of
> c-font-lock-doc-comments in cc-fonts.el. AFAIR, these features are
> beginning to be supported by the tree-sitter grammar itself, we just
> need to use that in our font-lock definitions? Yuan, any comments?
Some languages formally defines different kinds of comments and the grammar
tend to make the distinction between them. C grammar doesn’t make that
distinction, everything is just comment.
That doesn’t stop us from adding a font-lock rule that fontifies /** comments
in doc-face though. We can totally do that.
Yuan