From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59763: 29.0.60; Filling for c-ts-mode Date: Mon, 26 Dec 2022 23:03:36 +0100 Message-ID: <87zgb9g6vb.fsf@thornhill.no> References: Reply-To: Theodor Thornhill Mime-Version: 1.0 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="36826"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, 59763@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 26 23:04:25 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 1p9va3-0009NG-VY for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Dec 2022 23:04:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9vZk-0005JP-T6; Mon, 26 Dec 2022 17:04:04 -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 1p9vZj-0005GI-2c for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 17:04:03 -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 1p9vZi-0003hg-7V for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 17:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p9vZh-0003oQ-Ps for bug-gnu-emacs@gnu.org; Mon, 26 Dec 2022 17:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Dec 2022 22:04: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.167209222614630 (code B ref 59763); Mon, 26 Dec 2022 22:04:01 +0000 Original-Received: (at 59763) by debbugs.gnu.org; 26 Dec 2022 22:03:46 +0000 Original-Received: from localhost ([127.0.0.1]:54284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9vZS-0003nu-Cy for submit@debbugs.gnu.org; Mon, 26 Dec 2022 17:03:46 -0500 Original-Received: from out-57.mta0.migadu.com ([91.218.175.57]:21055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9vZN-0003nf-EM for 59763@debbugs.gnu.org; Mon, 26 Dec 2022 17:03:44 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1672092218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s/cR3SauH1D9a5ocTYPBXxE8PMlYstGPKfwwjbDrn+s=; b=xfWzgwEgUuTsn1mYaCjk4TLba3j1AqA7PR7lqihOsPhBq+xPVVP95WrKr6xDkLIQRu2CGi sz6q1Ho/vnDzanF0K97azMUltqCwQ2Sq9ZLxzdkyWhQTaQrvXnxvvHz931u66QBMk8oHzx RoHDtMV/K87lJdu09N6Ubr/KDnmZW2K6UeYaDVfusFRa79k9F58go/IX/wjfhLTNLIyHLK PaKMkUlx7RO1JQOTSyNlNHU3fJ43OqrvIi9VU7VOjsMMjH/o29Gl6AxMN7GT/9gkZO39mE 4Ws5NA+++tKfFnUSO8EeSbWk1V44PA+BIgVCX5juzI5h0MWRpFH32XOvpNtxsw== In-Reply-To: X-Migadu-Flow: FLOW_OUT 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:251920 Archived-At: Yuan Fu writes: > 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 f= illing >>>>>>>>> function. Below is the function I have in my init.el, could someo= ne 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 ha= ve the time to try >>>>>>>>> it out and see how well it works. >>>>>>>>=20 >>>>>>>> Thanks. >>>>>>>>=20 >>>>>>>> From 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 com= ment'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 cou= rse. >>>>>>> >>>>>>> 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 mode= s 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 tree= sit.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). > Sure. I just don't like it when these namespaces blend too much. But your call :-) Theo