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#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation Date: Sat, 17 Dec 2022 23:14:08 +0100 Message-ID: <87wn6psmof.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11297"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com To: 60169@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 17 23:15:28 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 1p6fSq-0002ih-Dj for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Dec 2022 23:15:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6fST-0003Nl-DI; Sat, 17 Dec 2022 17:15:05 -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 1p6fSR-0003NG-TB for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 17:15: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 1p6fSQ-0007am-WB for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 17:15:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6fSQ-0002Of-Di; Sat, 17 Dec 2022 17:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: casouri@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Dec 2022 22:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60169 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: casouri@gmail.com Original-Received: via spool by submit@debbugs.gnu.org id=B.16713152579173 (code B ref -1); Sat, 17 Dec 2022 22:15:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Dec 2022 22:14:17 +0000 Original-Received: from localhost ([127.0.0.1]:58241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6fRh-0002Nt-4t for submit@debbugs.gnu.org; Sat, 17 Dec 2022 17:14:17 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:46980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6fRf-0002Nn-Ke for submit@debbugs.gnu.org; Sat, 17 Dec 2022 17:14:16 -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 1p6fRf-0003In-FF for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 17:14:15 -0500 Original-Received: from out2.migadu.com ([2001:41d0:2:aacc::]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6fRd-0007XC-HL for bug-gnu-emacs@gnu.org; Sat, 17 Dec 2022 17:14:15 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. Received-SPF: pass client-ip=2001:41d0:2:aacc::; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, 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-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:251314 Archived-At: --=-=-= Content-Type: text/plain Hi Yuan! Can you install this for me? Thanks in advance, Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Indentation-fixes-for-jsx-tsx.patch >From ef710150559b2e865d918024edb6beea46d290b3 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 17 Dec 2022 23:11:57 +0100 Subject: [PATCH] Indentation fixes for jsx/tsx * lisp/progmodes/js.el (js--treesit-indent-rules): Simplify the rules. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--indent-rules): Simplify the rules --- lisp/progmodes/js.el | 11 +++++------ lisp/progmodes/typescript-ts-mode.el | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index a776ff91f9..8c1ee495c2 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3451,14 +3451,13 @@ js--treesit-indent-rules ((parent-is "statement_block") parent-bol js-indent-level) ;; JSX - ((parent-is "jsx_opening_element") parent js-indent-level) - ((match "<" "jsx_fragment") parent 0) - ((parent-is "jsx_fragment") parent js-indent-level) + ((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_element") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset) ((node-is "jsx_closing_element") parent 0) - ((node-is "jsx_text") parent js-indent-level) - ((parent-is "jsx_element") parent js-indent-level) ((node-is "/") parent 0) - ((parent-is "jsx_self_closing_element") parent js-indent-level))))) + ((node-is ">") parent 0))))) (defvar js--treesit-keywords '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index e7bd65c5e2..890d0a8134 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -95,13 +95,13 @@ typescript-ts-mode--indent-rules ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset) ,@(when (eq language 'tsx) - `(((parent-is "jsx_opening_element") parent typescript-ts-mode-indent-offset) - ((match "<" "jsx_fragment") parent 0) - ((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset) + `(((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_element") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset) + ((node-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset) ((node-is "jsx_closing_element") parent 0) - ((parent-is "jsx_element") parent typescript-ts-mode-indent-offset) ((node-is "/") parent 0) - ((parent-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset))) + ((node-is ">") parent 0))) (no-node parent-bol 0)))) (defvar typescript-ts-mode--keywords -- 2.34.1 --=-=-=--