From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#70074: 29.1; js-ts-mode doesn't define comment-line-break-function Date: Sun, 21 Apr 2024 21:35:24 -0700 Message-ID: <36DDEBAF-1288-4373-8879-05F833D12C65@gmail.com> References: <86msq971g0.fsf@gnu.org> <4b3706a2-84d8-43c4-95bb-02d6f8c450b0@gutov.dev> <8A759F5C-DA2B-43CC-BF19-3DEA98745986@gmail.com> <86cyqka37g.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30716"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 70074@debbugs.gnu.org, davis.evan.m@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 22 06:37:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rylQd-0007oq-Tj for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 Apr 2024 06:37:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rylQ9-0001C0-AU; Mon, 22 Apr 2024 00:36:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rylQ6-0001AO-Hz for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 00:36:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rylQ6-0000Ls-9W for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 00:36:46 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rylQL-00077x-Sx for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2024 00:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2024 04:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70074 X-GNU-PR-Package: emacs Original-Received: via spool by 70074-submit@debbugs.gnu.org id=B70074.171376056627045 (code B ref 70074); Mon, 22 Apr 2024 04:37:01 +0000 Original-Received: (at 70074) by debbugs.gnu.org; 22 Apr 2024 04:36:06 +0000 Original-Received: from localhost ([127.0.0.1]:45363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rylPQ-00071u-26 for submit@debbugs.gnu.org; Mon, 22 Apr 2024 00:36:05 -0400 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:43418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rylPJ-000705-S9 for 70074@debbugs.gnu.org; Mon, 22 Apr 2024 00:36:02 -0400 Original-Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e2c725e234so37437025ad.1 for <70074@debbugs.gnu.org>; Sun, 21 Apr 2024 21:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713760536; x=1714365336; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fJ0MGYxMSxcXbm1UwaqRkoEKs7TQs5LGCi8NcIpnkGE=; b=DjXmjyx9tnVvdRKQpcGisY5947+rELD3+a77waY6XbbhuXmFN3a+r8kNXJjmWpM80U huKxIhaWjsnzMGfrgYGAqgHfo/nmbRocrbENjXfN7XhHETrzYnqE9E+I/mHQiv1Pv+E1 AbNt/ej0tTmj1bDS3BQFoeatafGvADUKERyJCy1nfCT8uJ7K9njo3ryA1TF9VMxp5oGw VN3jnKcPObgzeNR59B7ExXBacm7lMkB9vX+Vi01F8eSlnzjLhyoGluIP9Tt7VHAJsjJB +6TMoW9Ko49+ImO1iqVEA1YmqL7NQecm4a5K35WRjVjBK5wPfvK01ABiqiVMS5s3Dh+7 7hjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713760536; x=1714365336; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fJ0MGYxMSxcXbm1UwaqRkoEKs7TQs5LGCi8NcIpnkGE=; b=CTHE+qTmPONmQrmWOZYGyjO0ixnzI/GOlNqIg5fvVI5GbzUppT+rpVBJNGJJCj0d18 F30nDSftb9TojvJeHv7b0nOsSJZc8P/CEu+M6vCv8DfJjzqAnd9Ki2n5I/YZG41+AzCf /c8cU0I2hW7hEVchfguQhR4V/35VAD1ArQqac5b72RktdExbgp2agXEkoY2OybRDxoEh 6c+dyNTCl25PnOeWapNmZ6PGMukEyetCZtyuDN34f5x+K1XvxTdSAA4jLucmUqD1nmAP GBlKgKBGVOb1jxYt9+OOddr3NyekCK1O6AuGYhj/y2O/FY7yb9dyVDAB4aMVCNd++l4U mZSQ== X-Forwarded-Encrypted: i=1; AJvYcCU1Hqn32MAqF1xHs2gFw0uwmtASPnF4swlk5L10nvA8ur+4iQ5xXhEE3qX+42L0dAZ4HeYJEjID/Y8EvcGDmyP0y+RE0ug= X-Gm-Message-State: AOJu0YzQWuLAcug6P++0Z162IFkWxtFgfFdBwbPU20JOKmbtLhE+vOcI al3LiIiKTeOTvUhqES9chCKgMLwHaFdCnaNuVr5IO6wxaIP7XDFz X-Google-Smtp-Source: AGHT+IGTHYAEq/MCQCBIdsR99+U3es7Ys9a5siO2toYsPV5rhhZlA3HKW58L+9hMV1FW/wbDdqjr0w== X-Received: by 2002:a17:902:a50c:b0:1e2:36d1:33fd with SMTP id s12-20020a170902a50c00b001e236d133fdmr13719584plq.27.1713760536116; Sun, 21 Apr 2024 21:35:36 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:641:300:4910:e4f6:f0b8:c91d:e40b]) by smtp.gmail.com with ESMTPSA id n6-20020a170903110600b001e668c1060bsm7067948plh.122.2024.04.21.21.35.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Apr 2024 21:35:35 -0700 (PDT) In-Reply-To: <86cyqka37g.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.700.6.1.1) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283795 Archived-At: > On Apr 20, 2024, at 12:44 AM, Eli Zaretskii wrote: >=20 > Ping! Yuan, can we make some progress here? >=20 >> From: Yuan Fu >> Date: Mon, 8 Apr 2024 00:10:32 -0700 >> Cc: Eli Zaretskii , >> Evan Davis , >> 70074@debbugs.gnu.org >>=20 >>=20 >>=20 >>> On Apr 4, 2024, at 5:28 PM, Dmitry Gutov wrote: >>>=20 >>> On 04/04/2024 15:32, Eli Zaretskii wrote: >>>>> From:Evan Davis >>>>> Date: Fri, 29 Mar 2024 11:03:10 -0400 >>>>>=20 >>>>> js-ts-mode and js-mode behave differently when calling = default-indent-new-line (M-j) within a multiline >>>>> comment. >>>>>=20 >>>>> 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. >>>>>=20 >>>>> Expected behavior: >>>>> Block comments should be handled the same in both modes. >>>>>=20 >>>>> 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 >>>>>=20 >>>>> Follow the same steps in js-mode to observe the desired behavior. >>>> Dmitry, Yuan: any comments or suggestions? >>>=20 >>> I suppose following in js-mode's footsteps and reusing this part of = CC Mode is the obvious solution. >>>=20 >>> 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. >>=20 >> Sounds good. I wasn=E2=80=99t aware of this command before. Let me = add it to c-ts-common.el. >>=20 >> Yuan I looked at the implementation of c-indent-new-comment-line, it=E2=80=99s = 178 lines of complicated control flow, handling all sorts of edge cases = that I don=E2=80=99t understand. Sadly it=E2=80=99s pretty keeping = coupled with the whole cc framework, so it=E2=80=99ll 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=E2=80=99= s probably nothing compare to c-indent-new-comment-line=E2=80=99s = 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=