all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 60169@debbugs.gnu.org
Cc: casouri@gmail.com
Subject: bug#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation
Date: Sat, 17 Dec 2022 23:14:08 +0100	[thread overview]
Message-ID: <87wn6psmof.fsf@thornhill.no> (raw)

[-- Attachment #1: Type: text/plain, Size: 66 bytes --]


Hi Yuan!

Can you install this for me?

Thanks in advance,
Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Indentation-fixes-for-jsx-tsx.patch --]
[-- Type: text/x-diff, Size: 3037 bytes --]

From ef710150559b2e865d918024edb6beea46d290b3 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
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


             reply	other threads:[~2022-12-17 22:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17 22:14 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-17 23:36 ` bug#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wn6psmof.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60169@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.