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#59763: 29.0.60; Filling for c-ts-mode Date: Mon, 26 Dec 2022 13:31:08 -0800 Message-ID: References: <69D98973-6824-47B3-900F-6DBEE669932F@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.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="10228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, 59763@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 26 22:32:23 2022 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 1p9v53-0002Q2-Pp for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Dec 2022 22:32:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9v4q-0000jB-Mj; Mon, 26 Dec 2022 16:32:09 -0500 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 1p9v4k-0000is-Nc for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 16:32:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9v4k-00048C-4z for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 16:32:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p9v4j-0002sX-QM for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 16:32:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <69D98973-6824-47B3-900F-6DBEE669932F@gmail.com> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Dec 2022 21:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59763 X-GNU-PR-Package: emacs Original-Received: via spool by 59763-submit@debbugs.gnu.org id=B59763.167209027811001 (code B ref 59763); Mon, 26 Dec 2022 21:32:01 +0000 Original-Received: (at 59763) by debbugs.gnu.org; 26 Dec 2022 21:31:18 +0000 Original-Received: from localhost ([127.0.0.1]:54267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9v41-0002rM-SJ for submit@debbugs.gnu.org; Mon, 26 Dec 2022 16:31:18 -0500 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:46794) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9v3z-0002r6-GF for 59763@debbugs.gnu.org; Mon, 26 Dec 2022 16:31:16 -0500 Original-Received: by mail-pl1-f169.google.com with SMTP id jn22so11536761plb.13 for <59763@debbugs.gnu.org>; Mon, 26 Dec 2022 13:31:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=ea9X++Wk11XN3rDuUW9V44c55ssD0/eiIPK/O3FqsCY=; b=UcefBzo/8zbJJ1RzwvjAyaW7zo7jvl/mjqJGxRrYlS+WpVfnf/SEEeqzntexxmriWs hYJzxpZiKl2Lc6nbe0QFfLzqS8+CNdGl8DzgevrGcIdnI83SyWfi4A9jchUpcZOagAWz QPw80C1Kgp27+lxBC/WtyBa2hXp14cmIUE20YwizmZDzqXOL4zXprQPpZUisW6b1frnB 1gTHeoJQNQGxN0fj7X6GmUAdVr+JAKEh2DgVWLiaJRG0GL5fHHW4C86+mTRpKzuG3HFL KJinmZzx06gjPGExd+AgBS5vc9dIcqlejQ70t8Me7cdhrYEGdmtV2FppdEZ+8inHrVIF jKHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ea9X++Wk11XN3rDuUW9V44c55ssD0/eiIPK/O3FqsCY=; b=gtRkMTIq7BC4I1pRfDkacDZ1HOHRrs4LxxQcfETbaVHPWbugZy2mxqa0RLTx9OzhJu DYUUTc/j0mp+wqQynD++dyOnpvoJN2YQ4ECV1AEl369R9FFyy64v8LlRgWLaZwKxC6oD 1r2scNbBckEz4sau9PFE7eScrqusYyXuxjAGKOr7ueD1mFth2NZuB6uE7R5skt3FbjmS ZxjGRqnVpx3DpcUcY0z+DYImDRD1o1BsXOeaHphSHaU6VOPH6nVZl+NX3ixesv8nF4d8 rtdKnTnH8TtXKhKScxtuqI8KvpKdgnSsnyqYEHm3vnz5Zb5Q9q+BUtgxlWlR9RUky/eZ 7tUA== X-Gm-Message-State: AFqh2ko152D6gS14AUpIG9NnCP4E18DOt2/gl9WSKOYL5KDRcivdRPeu xEBt4gZLEMqtz3uioCp1/iUVhWt7TFM= X-Google-Smtp-Source: AMrXdXu84130acbXgQSwGlPXyzjqoteBlPwDWz+CfvuEX6ANhFLY6rYXNV0FUxOpGSAj95/QHLC67w== X-Received: by 2002:a05:6a20:d685:b0:ac:83e:a9dc with SMTP id it5-20020a056a20d68500b000ac083ea9dcmr26852201pzb.13.1672090269699; Mon, 26 Dec 2022 13:31:09 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id u12-20020a170902e80c00b0018968d1c6f3sm7587913plg.59.2022.12.26.13.31.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Dec 2022 13:31:09 -0800 (PST) X-Mailer: Apple Mail (2.3696.120.41.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:251918 Archived-At: Theodor Thornhill writes: > On 25 December 2022 02:30:35 CET, Yuan Fu wrote: >> >>Theodor Thornhill writes: >> >>> On 24 December 2022 09:36:21 CET, Yuan Fu wrote: >>>> >>>>Theodor Thornhill writes: >>>> >>>>> Yuan Fu writes: >>>>> >>>>>>> On Dec 2, 2022, at 6:58 AM, Eli Zaretskii wrote: >>>>>>>=20 >>>>>>>> From: Yuan Fu >>>>>>>> Date: Thu, 1 Dec 2022 21:33:06 -0800 >>>>>>>>=20 >>>>>>>>=20 >>>>>>>> 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=E2=80=99s good? Alternatively we could = copy out the comment >>>>>>>> and fill it in a temp buffer with c-mode, but I didn=E2=80=99t = have the time to try >>>>>>>> it out and see how well it works. >>>>>>>=20 >>>>>>> Thanks. >>>>>>>=20 >>>>>>> =46rom quick testing, I see a problem: >>>>>>>=20 >>>>>>> . 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=E2=80=99ll need to look at how cc-mode fill comments. >>>>>> >>>>>>>=20 >>>>>>> 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=E2=80=99t 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=E2=80=99s >>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=E2=80=99s fine to = leave it in >>c-ts-mode, since there really isn=E2=80=99t much code. Having other = modes to >>require c-ts-mode shouldn=E2=80=99t 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=E2=80=99s 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=E2=80=99s 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