Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 15 Nov 2022 14:22:25 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 15 09:22:25 2022 Received: from localhost ([127.0.0.1]:53569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouwpU-0003sg-Qn for submit <at> debbugs.gnu.org; Tue, 15 Nov 2022 09:22:25 -0500 Received: from out2.migadu.com ([188.165.223.204]:21438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouwpS-0003sY-0d for 59251 <at> debbugs.gnu.org; Tue, 15 Nov 2022 09:22:23 -0500 Date: Tue, 15 Nov 2022 15:22:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668522140; 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=3WjCLuMONhq1cB6/JM+5/0gD5khEj69G6bze7qRnXTg=; b=KBvEvl9sdIcIpdEAYjXuw0aCY2C6J351aiReBFJbJB/JJ09ADhDC4HNXaV8+2m5yVBsdax PJrwUkijUvN8W8elNnd4brDLUxhY48vRWshYVmJzQTms6J3mUvKFat2hsEiY9c8PrzU+aH WgeNAayLsm/tXDwnAqnunG1yr2XlTCRW18krjYJkuKCTYPTP6lyk3jFs7o7hZgdpO89rfZ 5a0rYDBJUunQ/wt6NPeLiThNf3FxjB1fHUGRXJ3KIvrNUObE90HOkwRVFRJreLtHOdoS3D NpOU/TxX16DvoaiQCMXa9rKtBRximKY01tX+izx/zBQED5LFvdFWYtMH7yksYg== X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. From: Theodor Thornhill <theo@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: =?US-ASCII?Q?Re=3A_bug=2359251=3A_Acknowledgement_=2829=2E0=2E50?= =?US-ASCII?Q?=3B_Fix-some-inconsistencies-in-ts-modes=29?= In-Reply-To: <83v8ngif01.fsf@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> <877czy2ex4.fsf@HIDDEN> <83v8ngif01.fsf@HIDDEN> Message-ID: <14C598CA-691C-43B5-BF6F-2A4E488299CD@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, casouri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) On 15 November 2022 13:22:38 CET, Eli Zaretskii <eliz@gnu=2Eorg> wrote: >> Cc: 59251@debbugs=2Egnu=2Eorg >> Date: Mon, 14 Nov 2022 08:06:31 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@gnu=2Eorg> >>=20 >> > + (setq-local comment-style c-ts-mode-comment-style) >> > >> > Why don=E2=80=99t we let users set comment style themselves? Does cc-= mode have a similar variable? >> > >>=20 >> You have a point=2E Simplified the patch=2E > >This still makes it a fixed value that cannot be easily customized? >Or did I miss something? You could set it through the defcustom that was included
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 15 Nov 2022 12:22:34 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 15 07:22:34 2022 Received: from localhost ([127.0.0.1]:53275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouuxV-0006uh-Q3 for submit <at> debbugs.gnu.org; Tue, 15 Nov 2022 07:22:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1ouuxU-0006uT-9a for 59251 <at> debbugs.gnu.org; Tue, 15 Nov 2022 07:22:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1ouuxN-0006QW-Sb; Tue, 15 Nov 2022 07:22:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=4T0QsOWwOMzewh8GyaKAJlBS/TbelpjwZM8uiu8wHB8=; b=LolIl7omPAVEozHc0iek tZnGbWbK1BIWW8hARPmZnQmlFhaWJ91s+kxS3F9S0eWCo/wL8pTAvojg8JBJwGbfL5wkt7CsSQ3Px VNfYodGCKx2BM9wpOET3lCUeCJ7nJRTJJHeWezsgqmk9MfCnTMU3TuylzFXpoT7E4qYUtNwCPUZ+a 4yncr4H448kbnCfpwCG73Hp6r8jXYw6/ZvCSikIWyk7+STENJGDwt+5FOXXGGo+1iwfsktjTIMCD4 UYSZX8XA25/4JeA9HBgfP+GUmim9xal6/PD4blOItxQnLiH556bR5EmvX80IYthKBPsUo3CLdirDw twkaJc/1MShgkA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1ouuxN-0006Fe-14; Tue, 15 Nov 2022 07:22:25 -0500 Date: Tue, 15 Nov 2022 14:22:38 +0200 Message-Id: <83v8ngif01.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Theodor Thornhill <theo@HIDDEN> In-Reply-To: <877czy2ex4.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN) Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> <877czy2ex4.fsf@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, casouri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Cc: 59251 <at> debbugs.gnu.org > Date: Mon, 14 Nov 2022 08:06:31 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> > > > + (setq-local comment-style c-ts-mode-comment-style) > > > > Why don’t we let users set comment style themselves? Does cc-mode have a similar variable? > > > > You have a point. Simplified the patch. This still makes it a fixed value that cannot be easily customized? Or did I miss something?
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 19:12:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 14 14:12:40 2022 Received: from localhost ([127.0.0.1]:50874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouesq-0002O4-6k for submit <at> debbugs.gnu.org; Mon, 14 Nov 2022 14:12:40 -0500 Received: from out0.migadu.com ([94.23.1.103]:53423) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouesn-0002Nv-UI for 59251 <at> debbugs.gnu.org; Mon, 14 Nov 2022 14:12:39 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668453156; 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: in-reply-to:in-reply-to:references:references; bh=nbgHsgX8bhDLOEh4vOtJP/WSeCwqsZc9L81dFE8IyLY=; b=x/qj9iCGWQUZEnwExqod9zbRw1ScS0qiK8+eNFj7MW6DWT/Z6hz4nSxu6QZFnov+inUnsY XmUTUbbB1d1ewx6MVl4y478uzuHbkDPie8z2CDjEbHV8YFkMc+TJ9igLIYHWSMD8QgDBIm Li+LkmQly2Vncp/EtlTelFBp/sNqp7WbY7uolmhKNx60xO8apK9Rklakr0DnZsHGT0kJSL zdwgP5QSmzq/U3JktEZpJI8PP04pmLtLrOHKQqbmRX2+HxfTVN9bH5UK+kv5cKCDpuNWCk 2FPbnA4ksZG6VKkM3+wiSzbpL8lSF+dFwemg5/zECF2DJVJwWg3GfKjHZRh66A== From: Theodor Thornhill <theo@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#59251: 29.0.50; Fix-some-inconsistencies-in-ts-modes In-Reply-To: <834jv1jrah.fsf@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <834jv1jrah.fsf@HIDDEN> Date: Mon, 14 Nov 2022 20:12:29 +0100 Message-ID: <87k03xl59e.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, casouri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> Cc: casouri@HIDDEN >> Date: Sun, 13 Nov 2022 21:42:19 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> >> >> BTW, should we do the same thing we did with js-mode - add a js-ts-mode >> and don't change the js.el file at all? We could either go the same >> route as c-ts-mode, where we define both c and c++ in the same file, or >> keep them separate. What do you think? > > From my POV, it is best not to introduce new modes if that is > possible. That way, we minimize confusion and allow users to adapt > more easily. Only where the new mode is radically different from the > old one and cannot be easily be an optional addition to the old one, > is a completely new mode justified. Then I think we should do something like one of the first suggestions I made weeks ago - separate the inits so that as little as possible is shared between them. If we do that, then it would at least make sense to merge css and javascript.
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 19:02:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 14 14:02:35 2022 Received: from localhost ([127.0.0.1]:50869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouej5-0002AQ-2g for submit <at> debbugs.gnu.org; Mon, 14 Nov 2022 14:02:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1ouej2-0002AC-Oe for 59251 <at> debbugs.gnu.org; Mon, 14 Nov 2022 14:02:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1oueix-0003Bk-Eh; Mon, 14 Nov 2022 14:02:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=52orqUoJuYDh0YgQnnF3YXb40DbJBDkTuI28S51f/y0=; b=RoZBlaBYmRH/9NgzQE8o LRWrRasMoeSCreF53xUv8pd2mKV70pOWJjC1wHYxpIJaRVIxmk6RXuwAnGVLCcvxeVQjGWkCfjxjs Jj7IibZ391aRfPgywzAW4pN+WOOs2dUfaveYCWev8az1kJpUJm/CLEBym8JiMryO7VsgVJwDbfXFH pslOqKkPcJJXt11wvKsCHw07zrkWM27S1UuDQzBwKnv0Az+JPEKdANOGypr3ERRZPvEGYO4M8pz1x NS8jqHGcx9bxtpzvjaRE+JdlugwMFct9+Fw+lEMzyE/FIsidyyTHUrp2+WnOVzg29A646+udMLSx1 4GiifJ83fj/x2Q==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1oueiw-000777-U2; Mon, 14 Nov 2022 14:02:27 -0500 Date: Mon, 14 Nov 2022 21:02:39 +0200 Message-Id: <8335aljr5c.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Yuan Fu <casouri@HIDDEN> In-Reply-To: <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> (message from Yuan Fu on Sun, 13 Nov 2022 16:51:52 -0800) Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, theo@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Cc: 59251 <at> debbugs.gnu.org > From: Yuan Fu <casouri@HIDDEN> > Date: Sun, 13 Nov 2022 16:51:52 -0800 > > + (setq-local comment-style c-ts-mode-comment-style) > > Why don’t we let users set comment style themselves? Does cc-mode have a similar variable? It's a minor mode there, see "C-c C-k" (c-toggle-comment-style).
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 18:59:30 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 14 13:59:30 2022 Received: from localhost ([127.0.0.1]:50864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1oueg6-00024S-IP for submit <at> debbugs.gnu.org; Mon, 14 Nov 2022 13:59:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1oueg4-00024E-M2 for 59251 <at> debbugs.gnu.org; Mon, 14 Nov 2022 13:59:29 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1ouefz-0002Pb-4g; Mon, 14 Nov 2022 13:59:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5AlmNGspRjg8XoGoBEWU5NxGqTJoVwKmEmQSAORNn8M=; b=dpAorUuj4p9i a8T6cR8khoEtMziHjcA1JYNqEggx8/5Ir2fTOK7DnUdLHzDJleCg6XXT64THXZW+nUAGaQIr5AJk+ ul/z+R2jZViIxCTG5A1b2VhzoTxNJh488N8ACbyO7uFxNyqvH3eRBOk8bp1MhXF1SchS0q+MprTcQ PL2nwDTLD+pFrlcagv86acKG+xlORBEiw0DJLDnLn0OcFGjvZkilieJifjGw7SAyJ1hlaTUufJRsG gACXowvwkpd7xVY91z/P7Hl6hNs13m9i0HY/P57SEmtrly8sxLBMRkV28A5gF2Cx5eEPFjLNRsO8d bWaGhZv/t0hMLMfgDkDrrA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1ouefy-0006oX-IV; Mon, 14 Nov 2022 13:59:22 -0500 Date: Mon, 14 Nov 2022 20:59:34 +0200 Message-Id: <834jv1jrah.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Theodor Thornhill <theo@HIDDEN> In-Reply-To: <87k03ya8no.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN) Subject: Re: bug#59251: 29.0.50; Fix-some-inconsistencies-in-ts-modes References: <87k03ya8no.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, casouri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Cc: casouri@HIDDEN > Date: Sun, 13 Nov 2022 21:42:19 +0100 > From: Theodor Thornhill via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> > > BTW, should we do the same thing we did with js-mode - add a js-ts-mode > and don't change the js.el file at all? We could either go the same > route as c-ts-mode, where we define both c and c++ in the same file, or > keep them separate. What do you think? From my POV, it is best not to introduce new modes if that is possible. That way, we minimize confusion and allow users to adapt more easily. Only where the new mode is radically different from the old one and cannot be easily be an optional addition to the old one, is a completely new mode justified.
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 09:25:20 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 14 04:25:20 2022 Received: from localhost ([127.0.0.1]:48925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouViS-0003vI-1D for submit <at> debbugs.gnu.org; Mon, 14 Nov 2022 04:25:20 -0500 Received: from mail-pl1-f176.google.com ([209.85.214.176]:46887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1ouViP-0003v0-G8 for 59251 <at> debbugs.gnu.org; Mon, 14 Nov 2022 04:25:18 -0500 Received: by mail-pl1-f176.google.com with SMTP id l2so9500925pld.13; Mon, 14 Nov 2022 01:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=mD2BSXakn7+YuQluNLk79SDRApX624IcEV7aWlZMkz8=; b=Ef7JiKUa8D0fUcFgCgtoEevOt0sy429YgJ4188CyZIsBC0juSW3y/5E4sTa6DikYw+ VnSizDlkF+IcVfLLafyu2e/KClQaZkeYdYMUaf398yjSGqXUcACWdAMdayXfh7nUeolQ YqQRlbxSUqXO9ht/eg0XhlfklVWvpheSw7xXUkwB4W8C5UGEb223ji7lD8illcwBR+mF +4ivPyKHT7NsVIPllv5WeM3ck7GZU6fb+3qeA6COS9epzVfh0iDpWBkWexS88YHtrLCM oXdnzLwEHvpJ5x1MywE9JLdqrRr3SLEsSm5tRxQ4Ehgqg16NpdaXz24LwrpUpaYG0icx KLnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=mD2BSXakn7+YuQluNLk79SDRApX624IcEV7aWlZMkz8=; b=xYOwMWkpT1H0B6OgaAyNBRj2FmWJamHBkPuneXA8vCQNScgr3aY8t7IsR4DzU9eJuf Yv9u7iZNY5jkApFbzEqNWawtPH7ei4bSJ3QJtMIrm1UCRdRBLDsFNyRlp372Ancb2mzC ZnhMTinw/7QE9UfA59oONjQ4kLZc6dZKWoOToPH630ycRePZwi5HMQkQk1YkfOEEQ7KJ 4nUBEm+wARQE9LXgcsu5VzcrMjMzn4qxdw8pXhdaxIKjRRss18JFvVM8lt6P3HUH1c/k p1zqEroa+M2t4YvApSNkGzIoA3eA1RyujLcG+Od8isMXUs6CLRlNf8XfDFg0hoiyNQgC Xhgw== X-Gm-Message-State: ANoB5plIJujE2gmW6CwgKmNeKW1Dq3T6wrYMDscyMhXAgT54kULy9xfl UEu5qrEtb3rNE11ZW+LVE6A= X-Google-Smtp-Source: AA0mqf5pRKV9JlJTgMlZSbNmJmlH5z6vk6IZelk3jMagd1PlUWQfQTrgTyOMvbSPmX4ht/fHfWmZZw== X-Received: by 2002:a17:902:7e01:b0:186:b38a:9c4a with SMTP id b1-20020a1709027e0100b00186b38a9c4amr12466529plm.163.1668417911712; Mon, 14 Nov 2022 01:25:11 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id k137-20020a62848f000000b00572552feef3sm136852pfd.51.2022.11.14.01.25.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2022 01:25:11 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <877czy2ex4.fsf@HIDDEN> Date: Mon, 14 Nov 2022 01:25:09 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <54E210C8-9CE7-49AE-811E-BF367D070031@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> <877czy2ex4.fsf@HIDDEN> To: Theodor Thornhill <theo@HIDDEN> X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org, done-59251 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Nov 13, 2022, at 11:06 PM, Theodor Thornhill <theo@HIDDEN> = wrote: >=20 > Yuan Fu <casouri@HIDDEN> writes: >=20 >>> On Nov 13, 2022, at 3:01 PM, Theodor Thornhill via Bug reports for = GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@HIDDEN> = wrote: >>>=20 >>> Theodor Thornhill <theo@HIDDEN> writes: >>>=20 >>>> Added a few more finishes. >>>=20 >>> Aaand another. Last one for now. I promise=E2=80=A6 >>=20 >> Cool! Some comments: >>=20 >> +(defcustom c-ts-mode-font-lock-feature-list >> + '((comment preprocessor operator constant string literal keyword) >> + (type definition expression statement) >> + ()) >> + "Language constructs to font-lock. >> + >> +See `treesit-font-lock-feature-list' for description of how to >> +use this variable. Supported features are as defined in >> +`c-ts-mode--font-lock-settings'." >> + :version "29.1" >> + :type 'list >> + :safe 'listp >> + :group 'c) >> + >>=20 >> I think Stefan M=E2=80=99s opinion is to make feature-list private, = and let >> users add/remove features. Right now they can add/remove features = with >> treesit-recompute-feature-list. I guess we can keep them as = defvar=E2=80=99s >> for now, so people as the option to redefine this list should they >> want to. (One argument against having them as custom options is that, >> if a user sets it as a custom option, they will miss out on future >> changes to this variable.) >>=20 >>=20 >> + (setq-local comment-style c-ts-mode-comment-style) >>=20 >> Why don=E2=80=99t we let users set comment style themselves? Does = cc-mode have a similar variable? >>=20 >=20 > You have a point. Simplified the patch. >=20 > Theo >=20 > <0001-Fix-some-inconsistencies-in-ts-modes.patch> Thanks, merged and pushed. Yuan
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 07:06:45 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 14 02:06:45 2022 Received: from localhost ([127.0.0.1]:48827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouTYK-0000S2-V3 for submit <at> debbugs.gnu.org; Mon, 14 Nov 2022 02:06:45 -0500 Received: from out2.migadu.com ([188.165.223.204]:22007) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouTYF-0000Rn-4S for 59251 <at> debbugs.gnu.org; Mon, 14 Nov 2022 02:06:43 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668409596; 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: in-reply-to:in-reply-to:references:references; bh=99/mejPMpV6lAWCEbk7URV8IjvmCsq+XhyMBgnCvK6Q=; b=1BMoWeEObgXIAVNvCAIcvwm6coLhf2aWTpVsI2qTT4JSKAIKrPMid+WzwisT9hPjql8ASX MfhY1Oo/Mb991Ub9jxO/zsTDTTQyXQ4A4ARYXzRCUp+761tdP0LuUCzyjbz79mgHSvJZ5h d6UHxp/FwzMMDl6ZZ0C2Mg0coQIXHXr5/nkx5SrUIuY9J33Q04pc7kuQQXSmjlzoaDaR5s edkkSYXKQynrq458D0aPUPZrQProIlpT8bynPHbzAwRbaciVpyB7YrUVfkI6bRF2VXgQ5H pSYEOo1Nojudx8GjpgtYxzzxFWB9mWAVRkAMekXLgpfcr7nZ4psSHJeIu8OuoQ== From: Theodor Thornhill <theo@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) In-Reply-To: <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> Date: Mon, 14 Nov 2022 08:06:31 +0100 Message-ID: <877czy2ex4.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Yuan Fu <casouri@HIDDEN> writes: >> On Nov 13, 2022, at 3:01 PM, Theodor Thornhill via Bug reports for GNU E= macs, the Swiss army knife of text editors <bug-gnu-emacs@HIDDEN> wrote: >>=20 >> Theodor Thornhill <theo@HIDDEN> writes: >>=20 >>> Added a few more finishes. >>=20 >> Aaand another. Last one for now. I promise=E2=80=A6 > > Cool! Some comments: > > +(defcustom c-ts-mode-font-lock-feature-list > + '((comment preprocessor operator constant string literal keyword) > + (type definition expression statement) > + ()) > + "Language constructs to font-lock. > + > +See `treesit-font-lock-feature-list' for description of how to > +use this variable. Supported features are as defined in > +`c-ts-mode--font-lock-settings'." > + :version "29.1" > + :type 'list > + :safe 'listp > + :group 'c) > + > > I think Stefan M=E2=80=99s opinion is to make feature-list private, and l= et > users add/remove features. Right now they can add/remove features with > treesit-recompute-feature-list. I guess we can keep them as defvar=E2=80= =99s > for now, so people as the option to redefine this list should they > want to. (One argument against having them as custom options is that, > if a user sets it as a custom option, they will miss out on future > changes to this variable.) > > > + (setq-local comment-style c-ts-mode-comment-style) > > Why don=E2=80=99t we let users set comment style themselves? Does cc-mode= have a similar variable? > You have a point. Simplified the patch. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-inconsistencies-in-ts-modes.patch From 60d1dcf08d2d5fc365958263dafa0e731bfbc110 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill <theo@HIDDEN> Date: Mon, 14 Nov 2022 08:03:11 +0100 Subject: [PATCH] Fix some inconsistencies in *-ts-modes (c-ts-mode--base-mode): Extract comment-* so that we can separate between C and C++. (c-ts-mode, c++-ts-mode): Set comment-* variables. * lisp/progmodes/css-ts-mode.el (css-ts-mode): Add electric-indent. * lisp/progmodes/java-ts-mode.el (java-ts-mode--imenu): Add categories. Only display categories that exist in the file. (java-ts-mode): Add electric-indent. * lisp/progmodes/json-ts-mode.el (json-ts-mode): Add electric-indent. * lisp/progmodes/ts-mode.el (ts-mode--font-lock-settings): Whitespace cleanup. (ts-mode): Add electric-indent. --- lisp/progmodes/c-ts-mode.el | 20 +++++++++------ lisp/progmodes/css-ts-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 45 +++++++++++++++++++++++++--------- lisp/progmodes/json-ts-mode.el | 39 ++++++++++++++++++----------- lisp/progmodes/ts-mode.el | 13 +++++++++- 5 files changed, 89 insertions(+), 33 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5617ea7d7c..8d18c23da9 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -33,6 +33,7 @@ (defcustom c-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `c-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'c) @@ -44,6 +45,7 @@ c-ts-mode-indent-style one of the supplied styles doesn't suffice a function could be set instead. This function is expected return a list that follows the form of `treesit-simple-indent-rules'." + :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) (symbol :tag "K&R" 'k&r) (symbol :tag "Linux" 'linux) @@ -396,14 +398,8 @@ c-ts-mode--imenu ;;;###autoload (define-derived-mode c-ts-mode--base-mode prog-mode "C" "Major mode for editing C, powered by tree-sitter." - :group 'c :syntax-table c-ts-mode--syntax-table - ;; Comments. - (setq-local comment-start "// ") - (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") - (setq-local comment-end "") - ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "specifier" @@ -415,7 +411,7 @@ c-ts-mode--base-mode ;; Electric (setq-local electric-indent-chars - (append "{}():;," electric-indent-chars)) + (append "{}():;," electric-indent-chars)) ;; Imenu. (setq-local imenu-create-index-function #'c-ts-mode--imenu) @@ -436,6 +432,11 @@ c-ts-mode (treesit-parser-create 'c) + ;; Comments. + (setq-local comment-start "/* ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end " */") + (setq-local treesit-simple-indent-rules (c-ts-mode--set-indent-style 'c)) @@ -452,6 +453,11 @@ c++-ts-mode (unless (treesit-ready-p nil 'cpp) (error "Tree-sitter for C++ isn't available")) + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/css-ts-mode.el b/lisp/progmodes/css-ts-mode.el index e22bf99c6c..d0f104eac3 100644 --- a/lisp/progmodes/css-ts-mode.el +++ b/lisp/progmodes/css-ts-mode.el @@ -34,6 +34,7 @@ (defcustom css-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'css) @@ -114,6 +115,10 @@ css-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules css-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp "rule_set") ;; Font-lock. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 5ec7da9f5c..ee75753027 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -29,10 +29,10 @@ ;;; Code: (require 'treesit) -(require 'rx) (defcustom java-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `java-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'java) @@ -241,18 +241,38 @@ java-ts-mode--imenu-1 (defun java-ts-mode--imenu () "Return Imenu alist for the current buffer." (let* ((node (treesit-buffer-root-node)) - (tree (treesit-induce-sparse-tree - node (rx (or "class_declaration" - "interface_declaration" - "enum_declaration" - "record_declaration" - "method_declaration"))))) - (java-ts-mode--imenu-1 tree))) + (class-tree + `("Class" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^class_declaration$")))) + (interface-tree + `("Interface" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^interface_declaration$")))) + (enum-tree + `("Enum" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^enum_declaration$")))) + (record-tree + `("Record" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^record_declaration$")))) + (method-tree + `("Method" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^method_declaration$"))))) + (cl-remove-if + #'null + `(,(when (cdr class-tree) class-tree) + ,(when (cdr interface-tree) interface-tree) + ,(when (cdr enum-tree) enum-tree) + ,(when (cdr record-tree) record-tree) + ,(when (cdr method-tree) method-tree))))) ;;;###autoload (define-derived-mode java-ts-mode prog-mode "Java" "Major mode for editing Java, powered by tree-sitter." - :group 'c + :group 'java :syntax-table java-ts-mode--syntax-table (unless (treesit-ready-p nil 'java) @@ -268,9 +288,12 @@ java-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. - (setq-local treesit-defun-type-regexp - (rx (or "declaration"))) + (setq-local treesit-defun-type-regexp "declaration") ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 686640f98a..c1d3d283b8 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -33,6 +33,7 @@ (defcustom json-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'json) @@ -67,20 +68,26 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'json - :feature 'minimal + :feature 'comment :override t - `((pair - key: (_) @font-lock-string-face) - - (string) @font-lock-string-face - - (number) @font-lock-constant-face - - [(null) (true) (false)] @font-lock-constant-face - - (escape_sequence) @font-lock-constant-face - - (comment) @font-lock-comment-face)) + '((comment) @font-lock-comment-face) + :language 'json + :feature 'string + :override t + '((escape_sequence) @font-lock-constant-face + (string) @font-lock-string-face) + :language 'json + :feature 'number + :override t + '((number) @font-lock-constant-face) + :language 'json + :feature 'constant + :override t + '([(null) (true) (false)] @font-lock-constant-face) + :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face))) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -127,6 +134,10 @@ json-ts-mode (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules json-ts--indent-rules) @@ -137,7 +148,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((minimal) () ())) + '((comment string number) (constant pair) ())) ;; Imenu. (setq-local imenu-create-index-function #'json-ts-mode--imenu) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index f4dfa2ae95..c5a6f5fc60 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -30,6 +30,7 @@ (defcustom ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'typescript) @@ -100,7 +101,6 @@ ts-mode--keywords (defvar ts-mode--font-lock-settings (treesit-font-lock-rules - :language 'tsx :override t :feature 'comment @@ -271,18 +271,26 @@ ts-mode ((treesit-ready-p nil 'tsx) ;; Tree-sitter. (treesit-parser-create 'tsx) + ;; Comments. (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules ts-mode--indent-rules) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" "function_declaration" "lexical_declaration"))) + ;; Font-lock. (setq-local treesit-font-lock-settings ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list @@ -291,9 +299,12 @@ ts-mode (property pattern jsx))) ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) + ;; Which-func (use imenu). (setq-local which-func-functions nil) + (treesit-major-mode-setup)) + ;; Elisp. (t (js-mode) -- 2.34.1 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 14 Nov 2022 00:52:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 19:52:08 2022 Received: from localhost ([127.0.0.1]:48687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouNhn-0007ln-UD for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 19:52:08 -0500 Received: from mail-pf1-f182.google.com ([209.85.210.182]:46802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1ouNhi-0007lF-AZ for 59251 <at> debbugs.gnu.org; Sun, 13 Nov 2022 19:52:06 -0500 Received: by mail-pf1-f182.google.com with SMTP id b29so9615285pfp.13 for <59251 <at> debbugs.gnu.org>; Sun, 13 Nov 2022 16:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=UELP9NcPLWRekmhgLojwpHZNQIZOBcTT7xT2bQ8C8RM=; b=ZcbzmgGOdRfjIpRmRpflPlGCN1braWlY5ODG7YKtEVEY3R0RlXB0NEQrHrqNYfsWw8 VK/u9v4n/49XCRAYSOHpJqtIDRVgKeynzSiYEoJkmlhVKPMUwxFvXDeGD8JKE74GHjDs YJKovcXRpigv57tex9DN3wiah9k79grQjxzAeC8ScoZmxNwE020O8+QBg6QBGUK/Y7AR 9fNW51zq6sc1jdAybaY48isx+dCUVthI/Tl71SriNSt/AfO6jdLxlMA0UGC7ckG61VaZ NmUTi5VBNI4COfEvNFUNxElFr+ojtm5tdJsrSo81Il9oeRXUrG7kW9WvtwHj8bekOq4e IIDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=UELP9NcPLWRekmhgLojwpHZNQIZOBcTT7xT2bQ8C8RM=; b=hj/6XdNwecNOeX/ziholCnewaw6Yq9PK0B31A0SY2jdiibs79ndqBGn1AptOZSy4Yj Cy00lShlr/8k7u947WFGEmzriuBKE+fzE1N+a/B3p+31dOpbZ3vXq1QpMS13Tjc1EM3R yH2Txu7Qtz+Y8pY05P6HeEQe20oR/b+62+WQeF9sWcJRzW8f9XLNfmmyPZTRm8m0ZmqO HB99+zHEC4wUyn0qz864f7QiNVZSyp9+MxpB4qHgotIc5SUUujbVtsAB4ii0tSPnlydN s3E3IsN2UvxgOJgRWJWCQWMiD7nmuHfzbj0f1Orlgt/gLxY02zrljKRKfbfRyGuQqCO6 RthQ== X-Gm-Message-State: ANoB5plLAkvu5dbKEd0oAzcW3eoHtEGr/WcWMIs87JE/ZvXHoGEOJHL6 I3M9OzqLFzz5NiPLxcx/6X0= X-Google-Smtp-Source: AA0mqf7bLzoek9glDZMnMTAqpycGrJYioXR0/n4l5IQIHIISVyMOjviZhDHLkl/vetjTdzpQqDjU4w== X-Received: by 2002:a63:5650:0:b0:458:5e:5388 with SMTP id g16-20020a635650000000b00458005e5388mr9702480pgm.168.1668387113689; Sun, 13 Nov 2022 16:51:53 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id w2-20020a63d742000000b0046fb6e0e691sm4789875pgi.6.2022.11.13.16.51.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2022 16:51:53 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <87a64u31d0.fsf@HIDDEN> Date: Sun, 13 Nov 2022 16:51:52 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <6C5721BF-2FA2-45A4-A970-483D662A6414@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> <87a64u31d0.fsf@HIDDEN> To: Theodor Thornhill <theo@HIDDEN> X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 59251 Cc: 59251 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Nov 13, 2022, at 3:01 PM, Theodor Thornhill via Bug reports for GNU = Emacs, the Swiss army knife of text editors <bug-gnu-emacs@HIDDEN> = wrote: >=20 > Theodor Thornhill <theo@HIDDEN> writes: >=20 >> Added a few more finishes. >=20 > Aaand another. Last one for now. I promise=E2=80=A6 Cool! Some comments: +(defcustom c-ts-mode-font-lock-feature-list + '((comment preprocessor operator constant string literal keyword) + (type definition expression statement) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`c-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'c) + I think Stefan M=E2=80=99s opinion is to make feature-list private, and = let users add/remove features. Right now they can add/remove features = with treesit-recompute-feature-list. I guess we can keep them as = defvar=E2=80=99s for now, so people as the option to redefine this list = should they want to. (One argument against having them as custom options = is that, if a user sets it as a custom option, they will miss out on = future changes to this variable.) + (setq-local comment-style c-ts-mode-comment-style) Why don=E2=80=99t we let users set comment style themselves? Does = cc-mode have a similar variable? Yuan
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 13 Nov 2022 23:02:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 18:02:05 2022 Received: from localhost ([127.0.0.1]:48600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouLzF-000563-PC for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 18:02:05 -0500 Received: from out0.migadu.com ([94.23.1.103]:29113) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouLz9-00055l-GW for 59251 <at> debbugs.gnu.org; Sun, 13 Nov 2022 18:02:00 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668380514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RwMCcU9alIu2ymQWUnwkLJd6naqjzkmGqwF4hOUzL4o=; b=GAnASOkq0T9PZ5fPjohZWQ9qZTqNl15Z/V0h2Zhgm7RYD2bAF1lXQFGGjosvzRN6uMU1KV bhFFi1RM0wRXprWpfXulLuiCsVKrc+HwKQaIuv2bVRyCiZhrEN7p5JAZknE0r1sL3p8eop kcn9/7nU1EGAHdDDhzSAmeNuS4qADIay9NjzRHdvePsUqE+MjQ9DdW0tK1LzXZ2Pt1Z9yw GWq60lELOp/yjmcVu/2Z5B/Vof+SsiGqxFP7Z9D94gJqUsqru4RBrMxxKhsRG1UM2gbi35 ZCq5194PUUAzseZCxJgL3e4YrXfjyGtK7igKDP1LGkMRgSlAZgFrOkDgYNFvwg== From: Theodor Thornhill <theo@HIDDEN> To: 59251 <at> debbugs.gnu.org Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) In-Reply-To: <87cz9qa4ab.fsf@HIDDEN> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> <87cz9qa4ab.fsf@HIDDEN> Date: Mon, 14 Nov 2022 00:01:47 +0100 Message-ID: <87a64u31d0.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59251 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Theodor Thornhill <theo@HIDDEN> writes: > Added a few more finishes. Aaand another. Last one for now. I promise... Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-inconsistencies-in-ts-modes.patch From d36a86b28609f1d060cf282bcdf75bdbef46b909 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill <theo@HIDDEN> Date: Sun, 13 Nov 2022 21:37:01 +0100 Subject: [PATCH] Fix some inconsistencies in *-ts-modes * lisp/progmodes/c-ts-mode.el (c-ts-mode-comment-style): New defcustom. (c-ts-mode-font-lock-feature-list): New defcustom. (c-ts-mode--base-mode): Extract comment-* so that we can separate between C and C++. Use the new font-lock-feature-list defcustom. (c-ts-mode, c++-ts-mode): Set comment-* variables. * lisp/progmodes/css-ts-mode.el (css-ts-mode): Add electric-indent. * lisp/progmodes/java-ts-mode.el (java-ts-mode-font-lock-feature-list): New defcustom. (java-ts-mode--imenu): Add categories. Only display categories that exist in the file. (java-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/json-ts-mode.el (json-ts-mode-font-lock-feature-list): New defcustom. (json-ts-mode--font-lock-settings): Make much more granular font lock features. (json-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/ts-mode.el (ts-mode-font-lock-feature-list): New defcustom. (ts-mode--font-lock-settings): Whitespace cleanup. (ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. --- lisp/progmodes/c-ts-mode.el | 47 +++++++++++++++++++------ lisp/progmodes/css-ts-mode.el | 5 +++ lisp/progmodes/java-ts-mode.el | 63 ++++++++++++++++++++++++++-------- lisp/progmodes/json-ts-mode.el | 51 +++++++++++++++++++-------- lisp/progmodes/ts-mode.el | 32 ++++++++++++++--- 5 files changed, 156 insertions(+), 42 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5617ea7d7c..eacc167909 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -31,8 +31,30 @@ (require 'treesit) (require 'rx) +(defcustom c-ts-mode-comment-style 'multi-line + "The comment style as decided by `comment-styles'" + :version "29.1" + :type 'symbol + :safe 'symbolp + :group 'c) + +(defcustom c-ts-mode-font-lock-feature-list + '((comment preprocessor operator constant string literal keyword) + (type definition expression statement) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`c-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'c) + (defcustom c-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `c-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'c) @@ -44,6 +66,7 @@ c-ts-mode-indent-style one of the supplied styles doesn't suffice a function could be set instead. This function is expected return a list that follows the form of `treesit-simple-indent-rules'." + :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) (symbol :tag "K&R" 'k&r) (symbol :tag "Linux" 'linux) @@ -396,14 +419,8 @@ c-ts-mode--imenu ;;;###autoload (define-derived-mode c-ts-mode--base-mode prog-mode "C" "Major mode for editing C, powered by tree-sitter." - :group 'c :syntax-table c-ts-mode--syntax-table - ;; Comments. - (setq-local comment-start "// ") - (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") - (setq-local comment-end "") - ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "specifier" @@ -415,16 +432,14 @@ c-ts-mode--base-mode ;; Electric (setq-local electric-indent-chars - (append "{}():;," electric-indent-chars)) + (append "{}():;," electric-indent-chars)) ;; Imenu. (setq-local imenu-create-index-function #'c-ts-mode--imenu) (setq-local which-func-functions nil) (setq-local treesit-font-lock-feature-list - '((comment preprocessor operator constant string literal keyword) - (type definition expression statement) - (error)))) + c-ts-mode-font-lock-feature-list)) ;;;###autoload (define-derived-mode c-ts-mode c-ts-mode--base-mode "C" @@ -436,6 +451,12 @@ c-ts-mode (treesit-parser-create 'c) + ;; Comments. + (setq-local comment-start "/* ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end " */") + (setq-local comment-style c-ts-mode-comment-style) + (setq-local treesit-simple-indent-rules (c-ts-mode--set-indent-style 'c)) @@ -452,6 +473,12 @@ c++-ts-mode (unless (treesit-ready-p nil 'cpp) (error "Tree-sitter for C++ isn't available")) + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + (setq-local comment-style c-ts-mode-comment-style) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/css-ts-mode.el b/lisp/progmodes/css-ts-mode.el index e22bf99c6c..d0f104eac3 100644 --- a/lisp/progmodes/css-ts-mode.el +++ b/lisp/progmodes/css-ts-mode.el @@ -34,6 +34,7 @@ (defcustom css-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'css) @@ -114,6 +115,10 @@ css-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules css-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp "rule_set") ;; Font-lock. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 5ec7da9f5c..9977802f84 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -29,10 +29,24 @@ ;;; Code: (require 'treesit) -(require 'rx) + +(defcustom java-ts-mode-font-lock-feature-list + '((basic comment keyword constant string operator) + (type definition expression literal annotation) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`java-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'java) (defcustom java-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `java-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'java) @@ -241,18 +255,38 @@ java-ts-mode--imenu-1 (defun java-ts-mode--imenu () "Return Imenu alist for the current buffer." (let* ((node (treesit-buffer-root-node)) - (tree (treesit-induce-sparse-tree - node (rx (or "class_declaration" - "interface_declaration" - "enum_declaration" - "record_declaration" - "method_declaration"))))) - (java-ts-mode--imenu-1 tree))) + (class-tree + `("Class" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^class_declaration$")))) + (interface-tree + `("Interface" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^interface_declaration$")))) + (enum-tree + `("Enum" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^enum_declaration$")))) + (record-tree + `("Record" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^record_declaration$")))) + (method-tree + `("Method" . ,(java-ts-mode--imenu-1 + (treesit-induce-sparse-tree + node "^method_declaration$"))))) + (cl-remove-if + #'null + `(,(when (cdr class-tree) class-tree) + ,(when (cdr interface-tree) interface-tree) + ,(when (cdr enum-tree) enum-tree) + ,(when (cdr record-tree) record-tree) + ,(when (cdr method-tree) method-tree))))) ;;;###autoload (define-derived-mode java-ts-mode prog-mode "Java" "Major mode for editing Java, powered by tree-sitter." - :group 'c + :group 'java :syntax-table java-ts-mode--syntax-table (unless (treesit-ready-p nil 'java) @@ -268,16 +302,17 @@ java-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. - (setq-local treesit-defun-type-regexp - (rx (or "declaration"))) + (setq-local treesit-defun-type-regexp "declaration") ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((basic comment keyword constant string operator) - (type definition expression literal annotation) - ())) + java-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'java-ts-mode--imenu) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 686640f98a..f852cbcf58 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -31,8 +31,21 @@ (require 'treesit) (require 'rx) +(defcustom json-ts-mode-font-lock-feature-list + '((comment string number) (constant pair) ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`json-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'json) + (defcustom json-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'json) @@ -67,20 +80,26 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'json - :feature 'minimal + :feature 'comment :override t - `((pair - key: (_) @font-lock-string-face) - - (string) @font-lock-string-face - - (number) @font-lock-constant-face - - [(null) (true) (false)] @font-lock-constant-face - - (escape_sequence) @font-lock-constant-face - - (comment) @font-lock-comment-face)) + '((comment) @font-lock-comment-face) + :language 'json + :feature 'string + :override t + '((escape_sequence) @font-lock-constant-face + (string) @font-lock-string-face) + :language 'json + :feature 'number + :override t + '((number) @font-lock-constant-face) + :language 'json + :feature 'constant + :override t + '([(null) (true) (false)] @font-lock-constant-face) + :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face))) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -127,6 +146,10 @@ json-ts-mode (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules json-ts--indent-rules) @@ -137,7 +160,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((minimal) () ())) + json-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'json-ts-mode--imenu) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index f4dfa2ae95..4f6a3f970b 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -28,8 +28,23 @@ (require 'rx) (require 'js) +(defcustom ts-mode-font-lock-feature-list + '((comment declaration) + (string keyword identifier expression constant) + (property pattern jsx)) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'typescript) + (defcustom ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'typescript) @@ -100,7 +115,6 @@ ts-mode--keywords (defvar ts-mode--font-lock-settings (treesit-font-lock-rules - :language 'tsx :override t :feature 'comment @@ -271,29 +285,39 @@ ts-mode ((treesit-ready-p nil 'tsx) ;; Tree-sitter. (treesit-parser-create 'tsx) + ;; Comments. (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules ts-mode--indent-rules) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" "function_declaration" "lexical_declaration"))) + ;; Font-lock. (setq-local treesit-font-lock-settings ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment declaration) - (string keyword identifier expression constant) - (property pattern jsx))) + ts-mode-font-lock-feature-list) + ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) + ;; Which-func (use imenu). (setq-local which-func-functions nil) + (treesit-major-mode-setup)) + ;; Elisp. (t (js-mode) -- 2.34.1 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at 59251) by debbugs.gnu.org; 13 Nov 2022 22:16:58 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 17:16:58 2022 Received: from localhost ([127.0.0.1]:48564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouLHd-0003xG-Df for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 17:16:58 -0500 Received: from out0.migadu.com ([94.23.1.103]:41681) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouLHZ-0003wq-Ix for 59251 <at> debbugs.gnu.org; Sun, 13 Nov 2022 17:16:56 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668377811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jzhLEGRKKg/oLa8lFA0OJP2aeVZD2XFyFupnW6L/U38=; b=VFoKcjXl/E4c55ZM/ASc4SOaUT+X73lAP9QJwTniGwDblAzoReUk1qljCR2gGUMX9nijoq Z/LkpUKlgauD0ZI9BCtD4TMf3LMz56IA3pLwt7FdaKBGURi42Ai9iq9ttAXNVY/rejX8Cy ecUltS0QjGMjNq2hVD2W37H4H8aOPOb8DHEMmtNtXgb5vbp9H/VK1Emv3gWKLRYdgHHHQw VKGFDyTnT1QUy+Gmxfh2jGIfMkBZAMtbd/PR9Cue5y0xpZulR18wlPPqEn68rc0noStvbC CkHngYRrf5gmSJXqFyKOH0owXp8MQRM0bLJ+XVLAK7dF3pOtRRG8oAS4HtsH3g== From: Theodor Thornhill <theo@HIDDEN> To: 59251 <at> debbugs.gnu.org Subject: Re: bug#59251: Acknowledgement (29.0.50; Fix-some-inconsistencies-in-ts-modes) In-Reply-To: <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> References: <87k03ya8no.fsf@HIDDEN> <handler.59251.B.16683721605982.ack <at> debbugs.gnu.org> Date: Sun, 13 Nov 2022 23:16:44 +0100 Message-ID: <87cz9qa4ab.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59251 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Added a few more finishes. Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-inconsistencies-in-ts-modes.patch From bcbdc0a1261cd442aef8cd6bf0a80772eb0cda77 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill <theo@HIDDEN> Date: Sun, 13 Nov 2022 21:37:01 +0100 Subject: [PATCH] Fix some inconsistencies in *-ts-modes * lisp/progmodes/c-ts-mode.el (c-ts-mode-comment-style): New defcustom. (c-ts-mode-font-lock-feature-list): New defcustom. (c-ts-mode--base-mode): Extract comment-* so that we can separate between C and C++. Use the new font-lock-feature-list defcustom. (c-ts-mode, c++-ts-mode): Set comment-* variables. * lisp/progmodes/css-ts-mode.el (css-ts-mode): Add electric-indent. * lisp/progmodes/java-ts-mode.el (java-ts-mode-font-lock-feature-list): New defcustom. (java-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/json-ts-mode.el (json-ts-mode-font-lock-feature-list): New defcustom. (json-ts-mode--font-lock-settings): Make much more granular font lock features. (json-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/ts-mode.el (ts-mode-font-lock-feature-list): New defcustom. (ts-mode--font-lock-settings): Whitespace cleanup. (ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. --- lisp/progmodes/c-ts-mode.el | 47 ++++++++++++++++++++++++------- lisp/progmodes/css-ts-mode.el | 5 ++++ lisp/progmodes/java-ts-mode.el | 25 ++++++++++++++--- lisp/progmodes/json-ts-mode.el | 51 ++++++++++++++++++++++++---------- lisp/progmodes/ts-mode.el | 32 ++++++++++++++++++--- 5 files changed, 128 insertions(+), 32 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5617ea7d7c..eacc167909 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -31,8 +31,30 @@ (require 'treesit) (require 'rx) +(defcustom c-ts-mode-comment-style 'multi-line + "The comment style as decided by `comment-styles'" + :version "29.1" + :type 'symbol + :safe 'symbolp + :group 'c) + +(defcustom c-ts-mode-font-lock-feature-list + '((comment preprocessor operator constant string literal keyword) + (type definition expression statement) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`c-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'c) + (defcustom c-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `c-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'c) @@ -44,6 +66,7 @@ c-ts-mode-indent-style one of the supplied styles doesn't suffice a function could be set instead. This function is expected return a list that follows the form of `treesit-simple-indent-rules'." + :version "29.1" :type '(choice (symbol :tag "Gnu" 'gnu) (symbol :tag "K&R" 'k&r) (symbol :tag "Linux" 'linux) @@ -396,14 +419,8 @@ c-ts-mode--imenu ;;;###autoload (define-derived-mode c-ts-mode--base-mode prog-mode "C" "Major mode for editing C, powered by tree-sitter." - :group 'c :syntax-table c-ts-mode--syntax-table - ;; Comments. - (setq-local comment-start "// ") - (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") - (setq-local comment-end "") - ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "specifier" @@ -415,16 +432,14 @@ c-ts-mode--base-mode ;; Electric (setq-local electric-indent-chars - (append "{}():;," electric-indent-chars)) + (append "{}():;," electric-indent-chars)) ;; Imenu. (setq-local imenu-create-index-function #'c-ts-mode--imenu) (setq-local which-func-functions nil) (setq-local treesit-font-lock-feature-list - '((comment preprocessor operator constant string literal keyword) - (type definition expression statement) - (error)))) + c-ts-mode-font-lock-feature-list)) ;;;###autoload (define-derived-mode c-ts-mode c-ts-mode--base-mode "C" @@ -436,6 +451,12 @@ c-ts-mode (treesit-parser-create 'c) + ;; Comments. + (setq-local comment-start "/* ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end " */") + (setq-local comment-style c-ts-mode-comment-style) + (setq-local treesit-simple-indent-rules (c-ts-mode--set-indent-style 'c)) @@ -452,6 +473,12 @@ c++-ts-mode (unless (treesit-ready-p nil 'cpp) (error "Tree-sitter for C++ isn't available")) + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + (setq-local comment-style c-ts-mode-comment-style) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/css-ts-mode.el b/lisp/progmodes/css-ts-mode.el index e22bf99c6c..d0f104eac3 100644 --- a/lisp/progmodes/css-ts-mode.el +++ b/lisp/progmodes/css-ts-mode.el @@ -34,6 +34,7 @@ (defcustom css-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'css) @@ -114,6 +115,10 @@ css-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules css-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp "rule_set") ;; Font-lock. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 5ec7da9f5c..82343e6c52 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -31,8 +31,23 @@ (require 'treesit) (require 'rx) +(defcustom java-ts-mode-font-lock-feature-list + '((basic comment keyword constant string operator) + (type definition expression literal annotation) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`java-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'java) + (defcustom java-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `java-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'java) @@ -252,7 +267,7 @@ java-ts-mode--imenu ;;;###autoload (define-derived-mode java-ts-mode prog-mode "Java" "Major mode for editing Java, powered by tree-sitter." - :group 'c + :group 'java :syntax-table java-ts-mode--syntax-table (unless (treesit-ready-p nil 'java) @@ -268,6 +283,10 @@ java-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "declaration"))) @@ -275,9 +294,7 @@ java-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((basic comment keyword constant string operator) - (type definition expression literal annotation) - ())) + java-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'java-ts-mode--imenu) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 686640f98a..f852cbcf58 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -31,8 +31,21 @@ (require 'treesit) (require 'rx) +(defcustom json-ts-mode-font-lock-feature-list + '((comment string number) (constant pair) ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`json-ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'json) + (defcustom json-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'json) @@ -67,20 +80,26 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'json - :feature 'minimal + :feature 'comment :override t - `((pair - key: (_) @font-lock-string-face) - - (string) @font-lock-string-face - - (number) @font-lock-constant-face - - [(null) (true) (false)] @font-lock-constant-face - - (escape_sequence) @font-lock-constant-face - - (comment) @font-lock-comment-face)) + '((comment) @font-lock-comment-face) + :language 'json + :feature 'string + :override t + '((escape_sequence) @font-lock-constant-face + (string) @font-lock-string-face) + :language 'json + :feature 'number + :override t + '((number) @font-lock-constant-face) + :language 'json + :feature 'constant + :override t + '([(null) (true) (false)] @font-lock-constant-face) + :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face))) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -127,6 +146,10 @@ json-ts-mode (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules json-ts--indent-rules) @@ -137,7 +160,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((minimal) () ())) + json-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'json-ts-mode--imenu) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index f4dfa2ae95..4f6a3f970b 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -28,8 +28,23 @@ (require 'rx) (require 'js) +(defcustom ts-mode-font-lock-feature-list + '((comment declaration) + (string keyword identifier expression constant) + (property pattern jsx)) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`ts-mode--font-lock-settings'." + :version "29.1" + :type 'list + :safe 'listp + :group 'typescript) + (defcustom ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." + :version "29.1" :type 'integer :safe 'integerp :group 'typescript) @@ -100,7 +115,6 @@ ts-mode--keywords (defvar ts-mode--font-lock-settings (treesit-font-lock-rules - :language 'tsx :override t :feature 'comment @@ -271,29 +285,39 @@ ts-mode ((treesit-ready-p nil 'tsx) ;; Tree-sitter. (treesit-parser-create 'tsx) + ;; Comments. (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules ts-mode--indent-rules) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" "function_declaration" "lexical_declaration"))) + ;; Font-lock. (setq-local treesit-font-lock-settings ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment declaration) - (string keyword identifier expression constant) - (property pattern jsx))) + ts-mode-font-lock-feature-list) + ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) + ;; Which-func (use imenu). (setq-local which-func-functions nil) + (treesit-major-mode-setup)) + ;; Elisp. (t (js-mode) -- 2.34.1 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 13 Nov 2022 20:42:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 13 15:42:40 2022 Received: from localhost ([127.0.0.1]:48451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ouJoN-0001YQ-Tf for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 15:42:40 -0500 Received: from lists.gnu.org ([209.51.188.17]:37890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1ouJoL-0001YH-4K for submit <at> debbugs.gnu.org; Sun, 13 Nov 2022 15:42:38 -0500 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 <theo@HIDDEN>) id 1ouJoK-0002Ya-L8 for bug-gnu-emacs@HIDDEN; Sun, 13 Nov 2022 15:42:36 -0500 Received: from out0.migadu.com ([2001:41d0:2:267::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <theo@HIDDEN>) id 1ouJoG-00028V-51 for bug-gnu-emacs@HIDDEN; Sun, 13 Nov 2022 15:42:36 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1668372146; 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; bh=1AQ4Gw0rpCBGtGHTLfY154loMPe0yKRejh4hDidDazQ=; b=Ld2TMi9nRclfQ/TZT6nEefASGBOY8+v/WgGngP2hRuZNGvlh4DjtQLtKbJsb6puSYhvyYm cYcg2pIy5cOYYRkhEmlUJMS8UA/is61/wFQtF2ZJgE/jKZ5ttAZecL6mA+osCBwtC7uHPF 6e4Hpr3vguqqni8AFQSIIJIpuUUqtxm3RZpzK63KeaTJEj+7hRgwyJLWG4hBsQJEq62Fyb JezPcvfD4eiNd13bmWAgS5Hkeb6cT0fouFDduoQYOlaH0ajTtydXVbbac1Y7zGZINez4Nj bItKsWUg4xOWyzdpOUehGk6/r9ABuP4FVNFDttxJgAjxQTtFOzrGt25drySwlw== From: Theodor Thornhill <theo@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 29.0.50; Fix-some-inconsistencies-in-ts-modes Date: Sun, 13 Nov 2022 21:42:19 +0100 Message-ID: <87k03ya8no.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:2:267::; envelope-from=theo@HIDDEN; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: casouri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hi Yuan! I've make some changes to my *-ts-modes, and would appreciate a second opinion as well as a push to the feature/tree-sitter branch :-) I've extracted some of the relevant mode-init variables into defcustoms so that users can tweak their behavior. It also seems I forgot some electric indent configs in some of the other files, so I added that aswell. BTW, should we do the same thing we did with js-mode - add a js-ts-mode and don't change the js.el file at all? We could either go the same route as c-ts-mode, where we define both c and c++ in the same file, or keep them separate. What do you think? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-some-inconsistencies-in-ts-modes.patch From 0c2181a0bd3dbcf8c896404932fbd8eb2d2ee897 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill <theo@HIDDEN> Date: Sun, 13 Nov 2022 21:37:01 +0100 Subject: [PATCH] Fix some inconsistencies in *-ts-modes * lisp/progmodes/c-ts-mode.el (c-ts-mode-comment-style): New defcustom. (c-ts-mode-font-lock-feature-list): New defcustom. (c-ts-mode--base-mode): Extract comment-* so that we can separate between C and C++. Use the new font-lock-feature-list defcustom. (c-ts-mode, c++-ts-mode): Set comment-* variables. * lisp/progmodes/css-ts-mode.el (css-ts-mode): Add electric-indent. * lisp/progmodes/java-ts-mode.el (java-ts-mode-font-lock-feature-list): New defcustom. (java-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/json-ts-mode.el (json-ts-mode-font-lock-feature-list): New defcustom. (json-ts-mode--font-lock-settings): Make much more granular font lock features. (json-ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. * lisp/progmodes/ts-mode.el (ts-mode-font-lock-feature-list): New defcustom. (ts-mode--font-lock-settings): Whitespace cleanup. (ts-mode): Add electric-indent and use the font-lock-feature-list defcustom. --- lisp/progmodes/c-ts-mode.el | 42 ++++++++++++++++++++++------- lisp/progmodes/css-ts-mode.el | 4 +++ lisp/progmodes/java-ts-mode.el | 21 ++++++++++++--- lisp/progmodes/json-ts-mode.el | 49 ++++++++++++++++++++++++---------- lisp/progmodes/ts-mode.el | 30 ++++++++++++++++++--- 5 files changed, 116 insertions(+), 30 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 5617ea7d7c..75ab5ed737 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -31,6 +31,25 @@ (require 'treesit) (require 'rx) +(defcustom c-ts-mode-comment-style 'multi-line + "The comment style as decided by `comment-styles'" + :type 'symbol + :safe 'symbolp + :group 'c) + +(defcustom c-ts-mode-font-lock-feature-list + '((comment preprocessor operator constant string literal keyword) + (type definition expression statement) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`c-ts-mode--font-lock-settings'." + :type 'list + :safe 'listp + :group 'c) + (defcustom c-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `c-ts-mode'." :type 'integer @@ -399,11 +418,6 @@ c-ts-mode--base-mode :group 'c :syntax-table c-ts-mode--syntax-table - ;; Comments. - (setq-local comment-start "// ") - (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") - (setq-local comment-end "") - ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "specifier" @@ -415,16 +429,14 @@ c-ts-mode--base-mode ;; Electric (setq-local electric-indent-chars - (append "{}():;," electric-indent-chars)) + (append "{}():;," electric-indent-chars)) ;; Imenu. (setq-local imenu-create-index-function #'c-ts-mode--imenu) (setq-local which-func-functions nil) (setq-local treesit-font-lock-feature-list - '((comment preprocessor operator constant string literal keyword) - (type definition expression statement) - (error)))) + c-ts-mode-font-lock-feature-list)) ;;;###autoload (define-derived-mode c-ts-mode c-ts-mode--base-mode "C" @@ -436,6 +448,12 @@ c-ts-mode (treesit-parser-create 'c) + ;; Comments. + (setq-local comment-start "/* ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end " */") + (setq-local comment-style c-ts-mode-comment-style) + (setq-local treesit-simple-indent-rules (c-ts-mode--set-indent-style 'c)) @@ -452,6 +470,12 @@ c++-ts-mode (unless (treesit-ready-p nil 'cpp) (error "Tree-sitter for C++ isn't available")) + ;; Comments. + (setq-local comment-start "// ") + (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") + (setq-local comment-end "") + (setq-local comment-style c-ts-mode-comment-style) + (treesit-parser-create 'cpp) (setq-local treesit-simple-indent-rules diff --git a/lisp/progmodes/css-ts-mode.el b/lisp/progmodes/css-ts-mode.el index e22bf99c6c..8cb6074043 100644 --- a/lisp/progmodes/css-ts-mode.el +++ b/lisp/progmodes/css-ts-mode.el @@ -114,6 +114,10 @@ css-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules css-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp "rule_set") ;; Font-lock. diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 5ec7da9f5c..8aed2db9c6 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -31,6 +31,19 @@ (require 'treesit) (require 'rx) +(defcustom java-ts-mode-font-lock-feature-list + '((basic comment keyword constant string operator) + (type definition expression literal annotation) + ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`java-ts-mode--font-lock-settings'." + :type 'list + :safe 'listp + :group 'java) + (defcustom java-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `java-ts-mode'." :type 'integer @@ -268,6 +281,10 @@ java-ts-mode ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "declaration"))) @@ -275,9 +292,7 @@ java-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((basic comment keyword constant string operator) - (type definition expression literal annotation) - ())) + java-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'java-ts-mode--imenu) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 686640f98a..140ad5b523 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -31,6 +31,17 @@ (require 'treesit) (require 'rx) +(defcustom json-ts-mode-font-lock-feature-list + '((comment string number) (constant pair) ()) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`json-ts-mode--font-lock-settings'." + :type 'list + :safe 'listp + :group 'json) + (defcustom json-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." :type 'integer @@ -67,20 +78,26 @@ json-ts--indent-rules (defvar json-ts-mode--font-lock-settings (treesit-font-lock-rules :language 'json - :feature 'minimal + :feature 'comment :override t - `((pair - key: (_) @font-lock-string-face) - - (string) @font-lock-string-face - - (number) @font-lock-constant-face - - [(null) (true) (false)] @font-lock-constant-face - - (escape_sequence) @font-lock-constant-face - - (comment) @font-lock-comment-face)) + '((comment) @font-lock-comment-face) + :language 'json + :feature 'string + :override t + '((escape_sequence) @font-lock-constant-face + (string) @font-lock-string-face) + :language 'json + :feature 'number + :override t + '((number) @font-lock-constant-face) + :language 'json + :feature 'constant + :override t + '([(null) (true) (false)] @font-lock-constant-face) + :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face))) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -127,6 +144,10 @@ json-ts-mode (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules json-ts--indent-rules) @@ -137,7 +158,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((minimal) () ())) + json-ts-mode-font-lock-feature-list) ;; Imenu. (setq-local imenu-create-index-function #'json-ts-mode--imenu) diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index f4dfa2ae95..73f8c38238 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -28,6 +28,19 @@ (require 'rx) (require 'js) +(defcustom ts-mode-font-lock-feature-list + '((comment declaration) + (string keyword identifier expression constant) + (property pattern jsx)) + "Language constructs to font-lock. + +See `treesit-font-lock-feature-list' for description of how to +use this variable. Supported features are as defined in +`ts-mode--font-lock-settings'." + :type 'list + :safe 'listp + :group 'typescript) + (defcustom ts-mode-indent-offset 2 "Number of spaces for each indentation step in `ts-mode'." :type 'integer @@ -100,7 +113,6 @@ ts-mode--keywords (defvar ts-mode--font-lock-settings (treesit-font-lock-rules - :language 'tsx :override t :feature 'comment @@ -271,29 +283,39 @@ ts-mode ((treesit-ready-p nil 'tsx) ;; Tree-sitter. (treesit-parser-create 'tsx) + ;; Comments. (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + + ;; Electric + (setq-local electric-indent-chars + (append "{}():;," electric-indent-chars)) + ;; Indent. (setq-local treesit-simple-indent-rules ts-mode--indent-rules) + ;; Navigation. (setq-local treesit-defun-type-regexp (rx (or "class_declaration" "method_definition" "function_declaration" "lexical_declaration"))) + ;; Font-lock. (setq-local treesit-font-lock-settings ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((comment declaration) - (string keyword identifier expression constant) - (property pattern jsx))) + ts-mode-font-lock-feature-list) + ;; Imenu. (setq-local imenu-create-index-function #'js--treesit-imenu) + ;; Which-func (use imenu). (setq-local which-func-functions nil) + (treesit-major-mode-setup)) + ;; Elisp. (t (js-mode) -- 2.34.1 --=-=-=--
Theodor Thornhill <theo@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#59251
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.