From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dmitry@gutov.dev, 70074@debbugs.gnu.org, davis.evan.m@gmail.com
Subject: bug#70074: 29.1; js-ts-mode doesn't define comment-line-break-function
Date: Sun, 21 Apr 2024 21:35:24 -0700 [thread overview]
Message-ID: <36DDEBAF-1288-4373-8879-05F833D12C65@gmail.com> (raw)
In-Reply-To: <86cyqka37g.fsf@gnu.org>
> On Apr 20, 2024, at 12:44 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
> Ping! Yuan, can we make some progress here?
>
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Mon, 8 Apr 2024 00:10:32 -0700
>> Cc: Eli Zaretskii <eliz@gnu.org>,
>> Evan Davis <davis.evan.m@gmail.com>,
>> 70074@debbugs.gnu.org
>>
>>
>>
>>> On Apr 4, 2024, at 5:28 PM, Dmitry Gutov <dmitry@gutov.dev> wrote:
>>>
>>> On 04/04/2024 15:32, Eli Zaretskii wrote:
>>>>> From:Evan Davis<davis.evan.m@gmail.com>
>>>>> Date: Fri, 29 Mar 2024 11:03:10 -0400
>>>>>
>>>>> js-ts-mode and js-mode behave differently when calling default-indent-new-line (M-j) within a multiline
>>>>> comment.
>>>>>
>>>>> Observed behavior:
>>>>> - in js-mode, M-j calls c-indent-new-comment-line, which correctly inserts a newline, indented to the correct
>>>>> column and prefixed with '*'
>>>>> - in js-ts-mode, M-j calls comment-indent-new-line, which inserts an indented newline without the prefix.
>>>>>
>>>>> Expected behavior:
>>>>> Block comments should be handled the same in both modes.
>>>>>
>>>>> Steps to reproduce:
>>>>> 1. emacs -Q
>>>>> 2. open a scratch buffer in js-ts-mode and enter text (without quotes) "/*"
>>>>> 3. press M-j
>>>>> 4. observe newline is created without star prefix
>>>>>
>>>>> Follow the same steps in js-mode to observe the desired behavior.
>>>> Dmitry, Yuan: any comments or suggestions?
>>>
>>> I suppose following in js-mode's footsteps and reusing this part of CC Mode is the obvious solution.
>>>
>>> I haven't looked at the implementation closely enough to suggest something else, but it'd of course be nice to be able to provide a self-contained, shorter re-implementation instead.
>>
>> Sounds good. I wasn’t aware of this command before. Let me add it to c-ts-common.el.
>>
>> Yuan
I looked at the implementation of c-indent-new-comment-line, it’s 178 lines of complicated control flow, handling all sorts of edge cases that I don’t understand. Sadly it’s pretty keeping coupled with the whole cc framework, so it’ll be pretty hard to take it out and reuse for c-ts-common.el.
So I added a new function c-ts-common-comment-indent-new-line. It’s probably nothing compare to c-indent-new-comment-line’s capabilities, but it can at least handle the usual cases that I can think of: indenting after //, after /*, after * inside a block comment, and after | inside a block comment.
For more advanced use-cases, we can wait until someone asks for them.
Evan, if you pull the latest master, M-j should now just work for js-ts-mode.
Yuan
next prev parent reply other threads:[~2024-04-22 4:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 15:03 bug#70074: 29.1; js-ts-mode doesn't define comment-line-break-function Evan Davis
2024-04-04 12:32 ` Eli Zaretskii
2024-04-05 0:28 ` Dmitry Gutov
2024-04-08 7:10 ` Yuan Fu
2024-04-20 7:44 ` Eli Zaretskii
2024-04-22 4:35 ` Yuan Fu [this message]
[not found] ` <CAMojjrcdN9Yk61Rh6Pen1LWJrZZieJ+-QQCELT=yu4svNh1Tdg@mail.gmail.com>
2024-04-23 4:27 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=36DDEBAF-1288-4373-8879-05F833D12C65@gmail.com \
--to=casouri@gmail.com \
--cc=70074@debbugs.gnu.org \
--cc=davis.evan.m@gmail.com \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).